aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Williamson <aaron@copiesofcopies.org>2011-05-09 00:06:38 -0400
committerChristopher Allan Webber <cwebber@dustycloud.org>2011-05-12 23:38:02 -0500
commitbb49e56f8c855ea567d61ad63f93610b31d4eb27 (patch)
treea7b8883003dc9fffcf2c260895c6e2493a375a4c
parent9a22d0a0232647c37bb9c8afc57deaf31f0ec9b2 (diff)
downloadmediagoblin-bb49e56f8c855ea567d61ad63f93610b31d4eb27.tar.lz
mediagoblin-bb49e56f8c855ea567d61ad63f93610b31d4eb27.tar.xz
mediagoblin-bb49e56f8c855ea567d61ad63f93610b31d4eb27.zip
On image submission, do not require title. If none entered, default to filename.
-rw-r--r--mediagoblin/models.py2
-rw-r--r--mediagoblin/submit/forms.py2
-rw-r--r--mediagoblin/submit/views.py8
3 files changed, 7 insertions, 5 deletions
diff --git a/mediagoblin/models.py b/mediagoblin/models.py
index 69b1f4f0..5b286038 100644
--- a/mediagoblin/models.py
+++ b/mediagoblin/models.py
@@ -89,7 +89,7 @@ class MediaEntry(Document):
'thumbnail_file': [unicode]}
required_fields = [
- 'uploader', 'title', 'created', 'media_type']
+ 'uploader', 'created', 'media_type']
default_values = {
'created': datetime.datetime.utcnow,
diff --git a/mediagoblin/submit/forms.py b/mediagoblin/submit/forms.py
index fe51e7fd..51ca349d 100644
--- a/mediagoblin/submit/forms.py
+++ b/mediagoblin/submit/forms.py
@@ -21,6 +21,6 @@ import wtforms
class SubmitStartForm(wtforms.Form):
title = wtforms.TextField(
'Title',
- [wtforms.validators.Length(min=1, max=500)])
+ [wtforms.validators.Length(min=-1, max=500)])
description = wtforms.TextAreaField('Description of this work')
file = wtforms.FileField('File')
diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py
index 5e262f12..1b28e339 100644
--- a/mediagoblin/submit/views.py
+++ b/mediagoblin/submit/views.py
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
+from os.path import splitext
from cgi import FieldStorage
from webob import Response, exc
@@ -39,9 +39,11 @@ def submit_start(request):
submit_form.file.errors.append(
u'You must provide a file.')
else:
+ filename = request.POST['file'].filename
+
# create entry and save in database
entry = request.db.MediaEntry()
- entry['title'] = request.POST['title']
+ entry['title'] = request.POST['title'] or unicode(splitext(filename)[0])
entry['description'] = request.POST.get('description')
entry['media_type'] = u'image' # heh
entry['uploader'] = request.user
@@ -54,7 +56,7 @@ def submit_start(request):
queue_filepath = request.app.queue_store.get_unique_filepath(
['media_entries',
unicode(entry['_id']),
- secure_filename(request.POST['file'].filename)])
+ secure_filename(filename)])
# queue appropriately
queue_file = request.app.queue_store.get_file(