diff --git a/mediagoblin/submit/forms.py b/mediagoblin/submit/forms.py
index c5bacc4..69d211e 100644
a
|
b
|
|
16 | 16 | |
17 | 17 | |
18 | 18 | import wtforms |
19 | | |
| 19 | from wtforms.ext.sqlalchemy.fields import QuerySelectField |
20 | 20 | from mediagoblin import mg_globals |
21 | 21 | from mediagoblin.tools.text import tag_length_validator |
22 | 22 | from mediagoblin.tools.translate import lazy_pass_to_ugettext as _ |
… |
… |
def get_submit_start_form(form, **kwargs):
|
50 | 50 | _('License'), |
51 | 51 | [wtforms.validators.Optional(),], |
52 | 52 | choices=licenses_as_choices()) |
| 53 | collection = QuerySelectField( |
| 54 | _('Collection'), |
| 55 | allow_blank=True, blank_text=_('-- Select --'), get_label='title',) |
53 | 56 | max_file_size = wtforms.HiddenField('') |
54 | 57 | upload_limit = wtforms.HiddenField('') |
55 | 58 | uploaded = wtforms.HiddenField('') |
diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py
index eae4a1e..3c7d659 100644
a
|
b
|
import logging
|
23 | 23 | |
24 | 24 | _log = logging.getLogger(__name__) |
25 | 25 | |
26 | | |
| 26 | from mediagoblin.db.models import Collection |
| 27 | from mediagoblin.tools.federation import create_activity |
27 | 28 | from mediagoblin.tools.translate import pass_to_ugettext as _ |
28 | 29 | from mediagoblin.tools.response import render_to_response, redirect |
29 | 30 | from mediagoblin.decorators import require_active_login, user_has_privilege |
… |
… |
from mediagoblin.media_types import FileTypeNotSupported
|
33 | 34 | from mediagoblin.submit.lib import \ |
34 | 35 | check_file_field, submit_media, get_upload_file_limits, \ |
35 | 36 | FileUploadLimit, UserUploadLimit, UserPastUploadLimit |
| 37 | from mediagoblin.user_pages.lib import add_media_to_collection |
36 | 38 | |
37 | 39 | |
38 | 40 | @require_active_login |
… |
… |
def submit_start(request):
|
49 | 51 | max_file_size=max_file_size, |
50 | 52 | upload_limit=upload_limit, |
51 | 53 | uploaded=request.user.uploaded) |
| 54 | submit_form.collection.query = Collection.query.filter_by( |
| 55 | actor=request.user.id, |
| 56 | type=Collection.USER_DEFINED_TYPE |
| 57 | ).order_by(Collection.title) |
52 | 58 | |
53 | 59 | if request.method == 'POST' and submit_form.validate(): |
54 | 60 | if not check_file_field(request, 'file'): |
… |
… |
def submit_start(request):
|
56 | 62 | _(u'You must provide a file.')) |
57 | 63 | else: |
58 | 64 | try: |
59 | | submit_media( |
| 65 | media = submit_media( |
60 | 66 | mg_app=request.app, user=request.user, |
61 | 67 | submitted_file=request.files['file'], |
62 | 68 | filename=request.files['file'].filename, |
… |
… |
def submit_start(request):
|
67 | 73 | upload_limit=upload_limit, max_file_size=max_file_size, |
68 | 74 | urlgen=request.urlgen) |
69 | 75 | |
| 76 | if submit_form.collection.data: |
| 77 | add_media_to_collection( |
| 78 | submit_form.collection.data, media) |
| 79 | create_activity( |
| 80 | "add", media, request.user, target=collection) |
| 81 | |
70 | 82 | add_message(request, SUCCESS, _('Woohoo! Submitted!')) |
71 | 83 | |
72 | 84 | return redirect(request, "mediagoblin.user_pages.user_home", |