Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
commit 7516a395ab2fd648190fc7cdc0b6d0f074a1aa7c 2 parents 8b5e29b + 65b3ebe
@Fandekasp authored
View
2  massmedia/__init__.py
@@ -1,7 +1,7 @@
__version_info__ = {
'major': 0,
'minor': 8,
- 'micro': 6,
+ 'micro': 7,
'releaselevel': 'final',
'serial': 1
}
View
39 massmedia/admin.py
@@ -14,7 +14,7 @@
CollectionRelation, MediaTemplate)
import settings
from forms import (ImageCreationForm, VideoCreationForm, AudioCreationForm,
- FlashCreationForm, DocumentCreationForm)
+ FlashCreationForm, DocumentCreationForm, EmbedCreationForm)
from templatetags.media_widgets import snipshot_url
@@ -263,13 +263,48 @@ class Media:
'js/genericcollections.js',
)
+class EmbedAdmin(MediaAdmin):
+ fieldsets = (
+ (None, {'fields':('title', 'caption')}),
+ (_("Content"), {'fields':(('external_url', 'code',),)}),
+ (_("Credit"), {'fields':('author', 'one_off_author', 'reproduction_allowed')}),
+ (_("Metadata"), {'fields':('metadata', 'mime_type')}),
+ (_("Connections"), {'fields':('public', 'site')}),
+ (_("Widget"), {'fields':('width', 'height')}),
+ (_("Advanced options"), {
+ 'classes': ('collapse',),
+ 'fields': ('slug', 'widget_template',)
+ }),
+ )
+
+ add_fieldsets = (
+ (_("Content"),{'fields':('title', 'external_url', 'caption')}),
+ (_("Additional Info"), {
+ 'classes': ('collapse',),
+ 'fields': ('slug', 'creation_date', 'site')
+ })
+ )
+
+ add_form = EmbedCreationForm
+
+ if settings.USE_TAGGING:
+ fieldsets[4][1]['fields'] += ('categories',)
+
+ list_display = ('title', 'mime_type', 'public', 'creation_date')
+ list_filter = ('site', 'creation_date', 'public')
+ list_editable = ('public',)
+ prepopulated_fields = {'slug': ('title',)}
+ date_hierarchy = 'creation_date'
+ search_fields = ('caption', )
+
+
admin.site.register(Collection , CollectionAdmin)
admin.site.register(Image, ImageAdmin)
admin.site.register(Video, VideoAdmin)
admin.site.register(Audio, AudioAdmin)
admin.site.register(Flash, FlashAdmin)
admin.site.register(Document, DocumentAdmin)
-admin.site.register(Embed)
+admin.site.register(Embed, EmbedAdmin)
if not settings.FS_TEMPLATES:
admin.site.register(MediaTemplate)
View
1  massmedia/base_models.py
@@ -87,6 +87,7 @@ class Media(models.Model):
external_url = models.URLField(
_("External URL"),
blank=True, null=True,
+ verify_exists=False,
help_text=_("If this URL Field is set, the media will be pulled externally"))
mime_type = models.CharField(
_("MIME type"),
View
30 massmedia/forms.py
@@ -3,7 +3,7 @@
from django.contrib.sites.models import Site
import os, datetime
-from models import Image, Video, Audio, Flash, Document
+from models import Image, Video, Audio, Flash, Document, Embed
class ContentCreationForm(forms.ModelForm):
@@ -109,3 +109,31 @@ def clean(self):
if (not self.cleaned_data.has_key('file') or not self.cleaned_data['file']) and not self.cleaned_data['external_url']:
raise forms.ValidationError("You must include either a file or external url")
return super(DocumentCreationForm, self).clean()
+
+
+class EmbedCreationForm(forms.ModelForm):
+ """
+ A form that creates a piece of content from a file and title.
+ """
+ title = forms.CharField(max_length=255, widget=forms.TextInput(attrs={'size':85}))
+ external_url = forms.URLField(
+ required=False,
+ help_text="If this URLField is set, the media will be pulled externally")
+ code = forms.CharField(required=False, widget=forms.TextInput(attrs={'size':85}))
+ creation_date = forms.DateTimeField()
+
+ class Meta:
+ model = Embed
+
+ def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
+ initial=None, error_class=forms.util.ErrorList, label_suffix=':',
+ empty_permitted=False, instance=None):
+ # set a default creation date and add the current site
+ if not instance and (initial is not None and not initial.has_key('creation_date')):
+ initial['creation_date'] = datetime.datetime.now()
+ if not instance and (initial is not None and not initial.has_key('site')):
+ initial['site'] = Site.objects.get_current().id
+
+ super(EmbedCreationForm, self).__init__(data, files, auto_id, prefix, initial,
+ error_class, label_suffix,
+ empty_permitted, instance)
Please sign in to comment.
Something went wrong with that request. Please try again.