From d9d8b846ce9e5acbcb5d2ddca615f72fdff7df82 Mon Sep 17 00:00:00 2001
From: Aaron Williamson <aaron@copiesofcopies.org>
Date: Mon, 9 May 2011 00:06:38 -0400
Subject: [PATCH] On image submission, do not require title. If none entered,
default to filename.
---
mediagoblin/models.py | 2 +-
mediagoblin/submit/forms.py | 2 +-
mediagoblin/submit/views.py | 8 +++++---
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/mediagoblin/models.py b/mediagoblin/models.py
index 69b1f4f..5b28603 100644
a
|
b
|
class MediaEntry(Document):
|
89 | 89 | 'thumbnail_file': [unicode]} |
90 | 90 | |
91 | 91 | required_fields = [ |
92 | | 'uploader', 'title', 'created', 'media_type'] |
| 92 | 'uploader', 'created', 'media_type'] |
93 | 93 | |
94 | 94 | default_values = { |
95 | 95 | 'created': datetime.datetime.utcnow, |
diff --git a/mediagoblin/submit/forms.py b/mediagoblin/submit/forms.py
index fe51e7f..51ca349 100644
a
|
b
|
import wtforms
|
21 | 21 | class SubmitStartForm(wtforms.Form): |
22 | 22 | title = wtforms.TextField( |
23 | 23 | 'Title', |
24 | | [wtforms.validators.Length(min=1, max=500)]) |
| 24 | [wtforms.validators.Length(min=-1, max=500)]) |
25 | 25 | description = wtforms.TextAreaField('Description of this work') |
26 | 26 | file = wtforms.FileField('File') |
diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py
index 5e262f1..1b28e33 100644
a
|
b
|
|
14 | 14 | # You should have received a copy of the GNU Affero General Public License |
15 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 | | |
| 17 | from os.path import splitext |
18 | 18 | from cgi import FieldStorage |
19 | 19 | |
20 | 20 | from webob import Response, exc |
… |
… |
def submit_start(request):
|
39 | 39 | submit_form.file.errors.append( |
40 | 40 | u'You must provide a file.') |
41 | 41 | else: |
| 42 | filename = request.POST['file'].filename |
| 43 | |
42 | 44 | # create entry and save in database |
43 | 45 | entry = request.db.MediaEntry() |
44 | | entry['title'] = request.POST['title'] |
| 46 | entry['title'] = request.POST['title'] or unicode(splitext(filename)[0]) |
45 | 47 | entry['description'] = request.POST.get('description') |
46 | 48 | entry['media_type'] = u'image' # heh |
47 | 49 | entry['uploader'] = request.user |
… |
… |
def submit_start(request):
|
54 | 56 | queue_filepath = request.app.queue_store.get_unique_filepath( |
55 | 57 | ['media_entries', |
56 | 58 | unicode(entry['_id']), |
57 | | secure_filename(request.POST['file'].filename)]) |
| 59 | secure_filename(filename)]) |
58 | 60 | |
59 | 61 | # queue appropriately |
60 | 62 | queue_file = request.app.queue_store.get_file( |