annotate downloads/forms.py @ 693:ad69236e8501

For issue #52, update many 3rd party Javascript libraries. Updated to jquery 1.10.2, jquery ui 1.10.3. This broke a lot of stuff. - Found a newer version of the jquery cycle all plugin (3.0.3). - Updated JPlayer to 2.4.0. - Updated to MarkItUp 1.1.14. This also required me to add multiline attributes set to true on various buttons in the markdown set. - As per a stackoverflow post, added some code to get multiline titles in a jQuery UI dialog. They removed that functionality but allow you to put it back. Tweaked the MarkItUp preview CSS to show blockquotes in italic. Did not update TinyMCE at this time. I'm not using the JQuery version and this version appears to work ok for now. What I should do is make a repo for MarkItUp and do a vendor branch thing so I don't have to futz around diffing directories to figure out if I'll lose changes when I update.
author Brian Neal <bgneal@gmail.com>
date Wed, 04 Sep 2013 19:55:20 -0500
parents ee87ea74d46b
children 21c592cac71c
rev   line source
gremmie@1 1 """
gremmie@1 2 Forms for the downloads application.
gremmie@1 3 """
gremmie@1 4 import os
gremmie@1 5
gremmie@1 6 from django import forms
bgneal@6 7 from django.conf import settings
gremmie@1 8
bgneal@204 9 from downloads.models import PendingDownload
gremmie@1 10 from downloads.models import AllowedExtension
gremmie@1 11
gremmie@1 12
gremmie@1 13 class AddDownloadForm(forms.ModelForm):
gremmie@1 14 """Form to allow adding downloads."""
bgneal@312 15 title = forms.CharField(required=True,
bgneal@133 16 widget=forms.TextInput(attrs={'size': 64, 'maxlength': 64}))
bgneal@312 17 description = forms.CharField(required=False,
bgneal@133 18 widget=forms.Textarea(attrs={'class': 'markItUp smileyTarget'}))
gremmie@1 19
gremmie@1 20 def clean_file(self):
gremmie@1 21 file = self.cleaned_data['file']
gremmie@1 22 ext = os.path.splitext(file.name)[1]
gremmie@1 23 allowed_exts = AllowedExtension.objects.get_extension_list()
gremmie@1 24 if ext in allowed_exts:
gremmie@1 25 return file
gremmie@1 26 raise forms.ValidationError('The file extension "%s" is not allowed.' % ext)
gremmie@1 27
gremmie@1 28 class Meta:
bgneal@204 29 model = PendingDownload
gremmie@1 30 fields = ('title', 'category', 'description', 'file')
bgneal@312 31
gremmie@1 32 class Media:
gremmie@1 33 css = {
bgneal@133 34 'all': (settings.GPP_THIRD_PARTY_CSS['markitup'] +
bgneal@133 35 settings.GPP_THIRD_PARTY_CSS['jquery-ui'])
gremmie@1 36 }
bgneal@133 37 js = (settings.GPP_THIRD_PARTY_JS['markitup'] +
bgneal@133 38 settings.GPP_THIRD_PARTY_JS['jquery-ui'])