aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2011-08-11 22:54:11 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2011-08-11 22:54:11 -0500
commitba4858c5b4f639d0438b7a6d53a7a731424a430d (patch)
tree69ad17bc78d0b188fd6c9e75d40e4e390ca318fd
parent07934b442f7cd3abae18eecdf533de004f88e6b1 (diff)
parent788272f30034fb2f917496197e317226d21aad2e (diff)
downloadmediagoblin-ba4858c5b4f639d0438b7a6d53a7a731424a430d.tar.lz
mediagoblin-ba4858c5b4f639d0438b7a6d53a7a731424a430d.tar.xz
mediagoblin-ba4858c5b4f639d0438b7a6d53a7a731424a430d.zip
Merge branch 'master' into processing
Conflicts: mediagoblin/db/migrations.py
-rw-r--r--mediagoblin/auth/views.py21
-rw-r--r--mediagoblin/db/migrations.py10
-rw-r--r--mediagoblin/db/models.py7
-rw-r--r--mediagoblin/storage.py31
-rw-r--r--mediagoblin/submit/forms.py2
-rw-r--r--mediagoblin/templates/mediagoblin/submit/start.html5
-rw-r--r--mediagoblin/templates/mediagoblin/user_pages/media.html2
-rw-r--r--mediagoblin/templates/mediagoblin/utils/wtforms.html19
8 files changed, 50 insertions, 47 deletions
diff --git a/mediagoblin/auth/views.py b/mediagoblin/auth/views.py
index 121a8c8e..9120196f 100644
--- a/mediagoblin/auth/views.py
+++ b/mediagoblin/auth/views.py
@@ -45,20 +45,27 @@ def register(request):
if request.method == 'POST' and register_form.validate():
# TODO: Make sure the user doesn't exist already
- users_with_username = \
- request.db.User.find({
- 'username': request.POST['username'].lower()
- }).count()
+ users_with_username = request.db.User.find(
+ {'username': request.POST['username'].lower()}).count()
+ users_with_email = request.db.User.find(
+ {'email': request.POST['email'].lower()}).count()
+
+ extra_validation_passes = True
if users_with_username:
register_form.username.errors.append(
_(u'Sorry, a user with that name already exists.'))
+ extra_validation_passes = False
+ if users_with_email:
+ register_form.email.errors.append(
+ _(u'Sorry, that email address has already been taken.'))
+ extra_validation_passes = False
- else:
+ if extra_validation_passes:
# Create the user
user = request.db.User()
user['username'] = request.POST['username'].lower()
- user['email'] = request.POST['email']
+ user['email'] = request.POST['email'].lower()
user['pw_hash'] = auth_lib.bcrypt_gen_password_hash(
request.POST['password'])
user.save(validate=True)
@@ -159,7 +166,7 @@ def verify_email(request):
return redirect(
request, 'mediagoblin.user_pages.user_home',
- user=request.user['username'])
+ user=user['username'])
def resend_activation(request):
diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py
index 797d39de..36bca5b3 100644
--- a/mediagoblin/db/migrations.py
+++ b/mediagoblin/db/migrations.py
@@ -55,6 +55,16 @@ def mediaentry_mediafiles_main_to_original(database):
@RegisterMigration(3)
+def mediaentry_remove_thumbnail_file(database):
+ """
+ Use media_files['thumb'] instead of media_entries['thumbnail_file']
+ """
+ database['media_entries'].update(
+ {'thumbnail_file': {'$exists': True}},
+ {'$unset': {'thumbnail_file': 1}},
+
+
+@RegisterMigration(4)
def mediaentry_add_queued_task_id(database):
"""
Add the 'queued_task_id' field for entries that don't have it.
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py
index 23527e84..0dcb6ce8 100644
--- a/mediagoblin/db/models.py
+++ b/mediagoblin/db/models.py
@@ -171,8 +171,6 @@ class MediaEntry(Document):
- attachment_files: A list of "attachment" files, ones that aren't
critical to this piece of media but may be usefully relevant to people
viewing the work. (currently unused.)
-
- - thumbnail_file: Deprecated... we should remove this ;)
"""
__collection__ = 'media_entries'
@@ -199,10 +197,7 @@ class MediaEntry(Document):
# The following should be lists of lists, in appropriate file
# record form
- 'attachment_files': list,
-
- # This one should just be a single file record
- 'thumbnail_file': [unicode]}
+ 'attachment_files': list}
required_fields = [
'uploader', 'created', 'media_type', 'slug']
diff --git a/mediagoblin/storage.py b/mediagoblin/storage.py
index 88c748ce..3968fa29 100644
--- a/mediagoblin/storage.py
+++ b/mediagoblin/storage.py
@@ -290,16 +290,29 @@ class MountStorage(StorageInterface):
"""
Experimental "Mount" virtual Storage Interface
- This isn't an interface to some real storage, instead
- it's a redirecting interface, that redirects requests
- to other "StorageInterface"s.
- For example, requests for ["store1", "a"] to first
- storage with the path ["a"], etc.
+ This isn't an interface to some real storage, instead it's a
+ redirecting interface, that redirects requests to other
+ "StorageInterface"s.
+
+ For example, say you have the paths:
+
+ 1. ['user_data', 'cwebber', 'avatar.jpg']
+ 2. ['user_data', 'elrond', 'avatar.jpg']
+ 3. ['media_entries', '34352f304c3f4d0ad8ad0f043522b6f2', 'thumb.jpg']
+
+ You could mount media_entries under CloudFileStorage and user_data
+ under BasicFileStorage. Then 1 would be passed to
+ BasicFileStorage under the path ['cwebber', 'avatar.jpg'] and 3
+ would be passed to CloudFileStorage under
+ ['34352f304c3f4d0ad8ad0f043522b6f2', 'thumb.jpg'].
+
+ In other words, this is kind of like mounting /home/ and /etc/
+ under different filesystems on your operating system... but with
+ mediagoblin filestorages :)
- To set this up, you currently need to call the mount()
- method with the target path and a backend, that shall
- be available under that target path.
- You have to mount things in a sensible order,
+ To set this up, you currently need to call the mount() method with
+ the target path and a backend, that shall be available under that
+ target path. You have to mount things in a sensible order,
especially you can't mount ["a", "b"] before ["a"].
"""
def __init__(self, **kwargs):
diff --git a/mediagoblin/submit/forms.py b/mediagoblin/submit/forms.py
index 241d32dc..4519b057 100644
--- a/mediagoblin/submit/forms.py
+++ b/mediagoblin/submit/forms.py
@@ -22,11 +22,11 @@ from mediagoblin.util import fake_ugettext_passthrough as _
class SubmitStartForm(wtforms.Form):
+ file = wtforms.FileField(_('File'))
title = wtforms.TextField(
_('Title'),
[wtforms.validators.Length(min=0, max=500)])
description = wtforms.TextAreaField('Description of this work')
- file = wtforms.FileField(_('File'))
tags = wtforms.TextField(
_('Tags'),
[tag_length_validator])
diff --git a/mediagoblin/templates/mediagoblin/submit/start.html b/mediagoblin/templates/mediagoblin/submit/start.html
index eb34c2e2..3a40850d 100644
--- a/mediagoblin/templates/mediagoblin/submit/start.html
+++ b/mediagoblin/templates/mediagoblin/submit/start.html
@@ -24,10 +24,7 @@
method="POST" enctype="multipart/form-data">
<div class="grid_8 prefix_1 suffix_1 form_box">
<h1>{% trans %}Submit yer media{% endtrans %}</h1>
- {{ wtforms_util.render_field_div(submit_form.file) }}
- {{ wtforms_util.render_field_div(submit_form.title) }}
- {{ wtforms_util.render_textarea_div(submit_form.description) }}
- {{ wtforms_util.render_field_div(submit_form.tags) }}
+ {{ wtforms_util.render_divs(submit_form) }}
<div class="form_submit_buttons">
<input type="submit" value="{% trans %}Submit{% endtrans %}" class="button" />
</div>
diff --git a/mediagoblin/templates/mediagoblin/user_pages/media.html b/mediagoblin/templates/mediagoblin/user_pages/media.html
index afc0d903..9c0a1cca 100644
--- a/mediagoblin/templates/mediagoblin/user_pages/media.html
+++ b/mediagoblin/templates/mediagoblin/user_pages/media.html
@@ -55,7 +55,7 @@
<form action="{{ request.urlgen('mediagoblin.user_pages.media_post_comment',
user= media.uploader().username,
media=media._id) }}" method="POST">
- {{ wtforms_util.render_field_div(comment_form.comment_content) }}
+ {{ wtforms_util.render_divs(comment_form) }}
<div class="form_submit_buttons">
<input type="submit" value="{% trans %}Post comment!{% endtrans %}" class="button" />
</div>
diff --git a/mediagoblin/templates/mediagoblin/utils/wtforms.html b/mediagoblin/templates/mediagoblin/utils/wtforms.html
index e3d8e137..2639522a 100644
--- a/mediagoblin/templates/mediagoblin/utils/wtforms.html
+++ b/mediagoblin/templates/mediagoblin/utils/wtforms.html
@@ -34,25 +34,6 @@
</div>
{%- endmacro %}
-{# Generically render a textarea
- # ... mostly the same thing except it includes rows and cols #}
-{% macro render_textarea_div(field, rows=8, cols=20) %}
- <div class="form_field_box">
- <div class="form_field_label">{{ _(field.label.text) }}</div>
- {% if field.description -%}
- <div class="form_field_description">{{ _(field.description) }}</div>
- {%- endif %}
- <div class="form_field_input">{{ field(rows=rows, cols=cols) }}</div>
- {%- if field.errors -%}
- {% for error in field.errors %}
- <div class="form_field_error">
- {{ error }}
- </div>
- {% endfor %}
- {%- endif %}
- </div>
-{%- endmacro %}
-
{# Auto-render a form as a series of divs #}
{% macro render_divs(form) -%}
{% for field in form %}