On image submission, do not require title. If none entered, default to filename.
authorAaron Williamson <aaron@copiesofcopies.org>
Mon, 9 May 2011 04:06:38 +0000 (00:06 -0400)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 13 May 2011 04:38:02 +0000 (23:38 -0500)
mediagoblin/models.py
mediagoblin/submit/forms.py
mediagoblin/submit/views.py

index 69b1f4f01c90126f4301fc62e1d3cea0c2c0c114..5b2860386b1a85875d9527bb484f3f349a9197e4 100644 (file)
@@ -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,
index fe51e7fd3cda52b7724ac32b7ee93a6edf56536d..51ca349ddebb97c1452593f462a4e4bcd532ec1a 100644 (file)
@@ -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')
index 5e262f12aac2090013f1f91423a0c6c5c8906def..1b28e339272db95742cb0c687a60c216126f3aa5 100644 (file)
@@ -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(