Merge branch 'master' into processing
Conflicts: mediagoblin/db/migrations.py
This commit is contained in:
commit
ba4858c5b4
@ -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):
|
||||
|
@ -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.
|
||||
|
@ -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']
|
||||
|
@ -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):
|
||||
|
@ -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])
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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 %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user