1 from django.contrib import admin
2 from django.contrib.admin.util import unquote
3 from django.shortcuts import get_object_or_404, render_to_response
4 from django.template import RequestContext
5 from xerxes.influences.models import Character, Influence
6 from django.contrib.contenttypes import generic
7 from threadedcomments.models import ThreadedComment
8 from django.utils.safestring import mark_safe
9 from django.utils.translation import ugettext as _
10 from django.utils.encoding import force_unicode
12 class CharacterAdmin(admin.ModelAdmin):
13 list_filter=('status', 'player')
14 search_fields=('name',)
15 list_display=('player', 'name', 'status')
17 admin.site.register(Character, CharacterAdmin)
19 class InfluenceAdmin(admin.ModelAdmin):
20 list_filter=('character', 'status', 'longterm')
21 search_fields=('character', 'summary', 'description', 'contact')
22 list_display=('character', 'contact', 'summary', 'longterm', 'status')
25 js = ('base/js/yahoo-dom-event.js', 'base/js/logger-debug.js')
27 def __call__(self, request, url):
28 if (url and url.endswith('/comments')):
29 return self.comments_view(request, unquote(url[:-9]))
31 return super(InfluenceAdmin, self).__call__(request, url)
33 def comments_view(self, request, object_id):
36 obj = get_object_or_404(model, pk=object_id)
38 comments = obj.get_comments(private=True)
41 'title' : _('Commentaar: %s') % force_unicode(obj),
42 'root_path' : self.admin_site.root_path,
43 'app_label' : self.model._meta.app_label,
46 'comments' : comments,
47 'media' : mark_safe(self.media),
49 return render_to_response('admin/influences/influence/comments.html', context, RequestContext(request))
51 admin.site.register(Influence, InfluenceAdmin)