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
11 from forms import get_influence_comment_form
13 class CharacterAdmin(admin.ModelAdmin):
14 list_filter=('status', 'player')
15 search_fields=('name',)
16 list_display=('player', 'name', 'status')
18 admin.site.register(Character, CharacterAdmin)
20 class InfluenceAdmin(admin.ModelAdmin):
21 list_filter=('initiator', 'status', 'longterm', 'todo')
22 search_fields=('initiator', 'summary', 'description', 'contact')
23 list_display=('initiator', 'summary', 'longterm', 'status')
26 js = ('base/js/yahoo-dom-event.js', 'base/js/logger-debug.js')
27 css = {'all' : ('base/css/admin.css',)}
29 def __call__(self, request, url):
30 if (url and url.endswith('/comments')):
31 return self.comments_view(request, unquote(url[:-9]))
33 return super(InfluenceAdmin, self).__call__(request, url)
35 def comments_view(self, request, object_id):
38 obj = get_object_or_404(model, pk=object_id)
40 comments = obj.get_comments(private=True)
43 'title' : _('Commentaar: %s') % force_unicode(obj),
44 'root_path' : self.admin_site.root_path,
45 'app_label' : self.model._meta.app_label,
48 'comments' : comments,
49 'comment_form' : get_influence_comment_form(request.user.is_staff, None)(),
50 'media' : mark_safe(self.media),
52 return render_to_response('admin/influences/influence/comments.html', context, RequestContext(request))
54 admin.site.register(Influence, InfluenceAdmin)