Ticket #45: 0001-On-image-submission-do-not-require-title.-If-none-en.patch

File 0001-On-image-submission-do-not-require-title.-If-none-en.patch, 2.8 KB (added by Aaron Williamson, 13 years ago)

0001-On-image-submission-do-not-require-title.-If-none-en.patch

  • mediagoblin/models.py

    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):  
    8989        'thumbnail_file': [unicode]}
    9090
    9191    required_fields = [
    92         'uploader', 'title', 'created', 'media_type']
     92        'uploader', 'created', 'media_type']
    9393
    9494    default_values = {
    9595        'created': datetime.datetime.utcnow,
  • mediagoblin/submit/forms.py

    diff --git a/mediagoblin/submit/forms.py b/mediagoblin/submit/forms.py
    index fe51e7f..51ca349 100644
    a b import wtforms  
    2121class SubmitStartForm(wtforms.Form):
    2222    title = wtforms.TextField(
    2323        'Title',
    24         [wtforms.validators.Length(min=1, max=500)])
     24        [wtforms.validators.Length(min=-1, max=500)])
    2525    description = wtforms.TextAreaField('Description of this work')
    2626    file = wtforms.FileField('File')
  • mediagoblin/submit/views.py

    diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py
    index 5e262f1..1b28e33 100644
    a b  
    1414# You should have received a copy of the GNU Affero General Public License
    1515# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1616
    17 
     17from os.path import splitext
    1818from cgi import FieldStorage
    1919
    2020from webob import Response, exc
    def submit_start(request):  
    3939            submit_form.file.errors.append(
    4040                u'You must provide a file.')
    4141        else:
     42            filename = request.POST['file'].filename
     43
    4244            # create entry and save in database
    4345            entry = request.db.MediaEntry()
    44             entry['title'] = request.POST['title']
     46            entry['title'] = request.POST['title'] or unicode(splitext(filename)[0])
    4547            entry['description'] = request.POST.get('description')
    4648            entry['media_type'] = u'image' # heh
    4749            entry['uploader'] = request.user
    def submit_start(request):  
    5456            queue_filepath = request.app.queue_store.get_unique_filepath(
    5557                ['media_entries',
    5658                 unicode(entry['_id']),
    57                  secure_filename(request.POST['file'].filename)])
     59                 secure_filename(filename)])
    5860
    5961            # queue appropriately
    6062            queue_file = request.app.queue_store.get_file(