annotate potd/admin.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
rev   line source
gremmie@1 1 """
gremmie@1 2 This file contains the admin definitions for the POTD application.
gremmie@1 3 """
bgneal@267 4 from django.contrib import admin
bgneal@267 5 from django.conf import settings
gremmie@1 6
gremmie@1 7 from potd.models import Photo
gremmie@1 8 from potd.models import Current
gremmie@1 9 from potd.models import Sequence
gremmie@1 10
bgneal@267 11
bgneal@330 12 IMG_TAG = '<img src="%s" alt="thumbnail" />'
bgneal@330 13
bgneal@330 14
gremmie@1 15 class PhotoAdmin(admin.ModelAdmin):
bgneal@535 16 fields = ['photo', 'caption', 'description', 'user', 'potd_count']
bgneal@535 17 raw_id_fields = ['user']
bgneal@535 18 list_display = ['__unicode__', 'thumbnail']
bgneal@535 19 actions = ['regen_thumbnail']
bgneal@535 20 search_fields = ['caption', 'description']
gremmie@1 21
bgneal@267 22 class Media:
bgneal@267 23 js = settings.GPP_THIRD_PARTY_JS['tiny_mce']
bgneal@267 24
bgneal@330 25 def thumbnail(self, obj):
bgneal@330 26 return IMG_TAG % obj.thumb.url
bgneal@330 27 thumbnail.allow_tags = True
bgneal@330 28
bgneal@330 29 def regen_thumbnail(self, request, qs):
bgneal@330 30 """
bgneal@330 31 Regenerates the thumbnail for the selected photos.
bgneal@330 32 """
bgneal@330 33 for photo in qs:
bgneal@330 34 photo.generate_thumb()
bgneal@330 35 photo.save()
bgneal@330 36
bgneal@330 37 regen_thumbnail.short_description = "Regenerate thumbs for selected photos"
bgneal@330 38
bgneal@330 39
gremmie@1 40 class CurrentAdmin(admin.ModelAdmin):
bgneal@330 41 list_display = ('__unicode__', 'thumbnail')
gremmie@1 42 raw_id_fields = ('potd', )
gremmie@1 43
bgneal@330 44 def thumbnail(self, obj):
bgneal@330 45 return IMG_TAG % obj.potd.thumb.url
bgneal@330 46 thumbnail.allow_tags = True
bgneal@330 47
bgneal@330 48
gremmie@1 49 admin.site.register(Photo, PhotoAdmin)
gremmie@1 50 admin.site.register(Current, CurrentAdmin)
gremmie@1 51 admin.site.register(Sequence)