Merge branch 'master' into processing

Conflicts:
	mediagoblin/db/migrations.py
This commit is contained in:
Christopher Allan Webber 2011-08-11 22:54:11 -05:00
commit ba4858c5b4
8 changed files with 50 additions and 47 deletions

View File

@ -45,20 +45,27 @@ def register(request):
if request.method == 'POST' and register_form.validate(): if request.method == 'POST' and register_form.validate():
# TODO: Make sure the user doesn't exist already # TODO: Make sure the user doesn't exist already
users_with_username = \ users_with_username = request.db.User.find(
request.db.User.find({ {'username': request.POST['username'].lower()}).count()
'username': request.POST['username'].lower() users_with_email = request.db.User.find(
}).count() {'email': request.POST['email'].lower()}).count()
extra_validation_passes = True
if users_with_username: if users_with_username:
register_form.username.errors.append( register_form.username.errors.append(
_(u'Sorry, a user with that name already exists.')) _(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 # Create the user
user = request.db.User() user = request.db.User()
user['username'] = request.POST['username'].lower() 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( user['pw_hash'] = auth_lib.bcrypt_gen_password_hash(
request.POST['password']) request.POST['password'])
user.save(validate=True) user.save(validate=True)
@ -159,7 +166,7 @@ def verify_email(request):
return redirect( return redirect(
request, 'mediagoblin.user_pages.user_home', request, 'mediagoblin.user_pages.user_home',
user=request.user['username']) user=user['username'])
def resend_activation(request): def resend_activation(request):

View File

@ -55,6 +55,16 @@ def mediaentry_mediafiles_main_to_original(database):
@RegisterMigration(3) @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): def mediaentry_add_queued_task_id(database):
""" """
Add the 'queued_task_id' field for entries that don't have it. Add the 'queued_task_id' field for entries that don't have it.

View File

@ -171,8 +171,6 @@ class MediaEntry(Document):
- attachment_files: A list of "attachment" files, ones that aren't - attachment_files: A list of "attachment" files, ones that aren't
critical to this piece of media but may be usefully relevant to people critical to this piece of media but may be usefully relevant to people
viewing the work. (currently unused.) viewing the work. (currently unused.)
- thumbnail_file: Deprecated... we should remove this ;)
""" """
__collection__ = 'media_entries' __collection__ = 'media_entries'
@ -199,10 +197,7 @@ class MediaEntry(Document):
# The following should be lists of lists, in appropriate file # The following should be lists of lists, in appropriate file
# record form # record form
'attachment_files': list, 'attachment_files': list}
# This one should just be a single file record
'thumbnail_file': [unicode]}
required_fields = [ required_fields = [
'uploader', 'created', 'media_type', 'slug'] 'uploader', 'created', 'media_type', 'slug']

View File

@ -290,16 +290,29 @@ class MountStorage(StorageInterface):
""" """
Experimental "Mount" virtual Storage Interface Experimental "Mount" virtual Storage Interface
This isn't an interface to some real storage, instead This isn't an interface to some real storage, instead it's a
it's a redirecting interface, that redirects requests redirecting interface, that redirects requests to other
to other "StorageInterface"s. "StorageInterface"s.
For example, requests for ["store1", "a"] to first
storage with the path ["a"], etc.
To set this up, you currently need to call the mount() For example, say you have the paths:
method with the target path and a backend, that shall
be available under that target path. 1. ['user_data', 'cwebber', 'avatar.jpg']
You have to mount things in a sensible order, 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,
especially you can't mount ["a", "b"] before ["a"]. especially you can't mount ["a", "b"] before ["a"].
""" """
def __init__(self, **kwargs): def __init__(self, **kwargs):

View File

@ -22,11 +22,11 @@ from mediagoblin.util import fake_ugettext_passthrough as _
class SubmitStartForm(wtforms.Form): class SubmitStartForm(wtforms.Form):
file = wtforms.FileField(_('File'))
title = wtforms.TextField( title = wtforms.TextField(
_('Title'), _('Title'),
[wtforms.validators.Length(min=0, max=500)]) [wtforms.validators.Length(min=0, max=500)])
description = wtforms.TextAreaField('Description of this work') description = wtforms.TextAreaField('Description of this work')
file = wtforms.FileField(_('File'))
tags = wtforms.TextField( tags = wtforms.TextField(
_('Tags'), _('Tags'),
[tag_length_validator]) [tag_length_validator])

View File

@ -24,10 +24,7 @@
method="POST" enctype="multipart/form-data"> method="POST" enctype="multipart/form-data">
<div class="grid_8 prefix_1 suffix_1 form_box"> <div class="grid_8 prefix_1 suffix_1 form_box">
<h1>{% trans %}Submit yer media{% endtrans %}</h1> <h1>{% trans %}Submit yer media{% endtrans %}</h1>
{{ wtforms_util.render_field_div(submit_form.file) }} {{ wtforms_util.render_divs(submit_form) }}
{{ wtforms_util.render_field_div(submit_form.title) }}
{{ wtforms_util.render_textarea_div(submit_form.description) }}
{{ wtforms_util.render_field_div(submit_form.tags) }}
<div class="form_submit_buttons"> <div class="form_submit_buttons">
<input type="submit" value="{% trans %}Submit{% endtrans %}" class="button" /> <input type="submit" value="{% trans %}Submit{% endtrans %}" class="button" />
</div> </div>

View File

@ -55,7 +55,7 @@
<form action="{{ request.urlgen('mediagoblin.user_pages.media_post_comment', <form action="{{ request.urlgen('mediagoblin.user_pages.media_post_comment',
user= media.uploader().username, user= media.uploader().username,
media=media._id) }}" method="POST"> 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"> <div class="form_submit_buttons">
<input type="submit" value="{% trans %}Post comment!{% endtrans %}" class="button" /> <input type="submit" value="{% trans %}Post comment!{% endtrans %}" class="button" />
</div> </div>

View File

@ -34,25 +34,6 @@
</div> </div>
{%- endmacro %} {%- 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 #} {# Auto-render a form as a series of divs #}
{% macro render_divs(form) -%} {% macro render_divs(form) -%}
{% for field in form %} {% for field in form %}