X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=influences%2Fadmin.py;h=126cd5cea9ddd20232a6a5a9d6050b172e310eb7;hb=bf745388baa1473feae115368179cf54bd910087;hp=afdf6d7351b4e1a77d23819540483080ca2cbdba;hpb=3fdc7c9e5858d53c0d1863c9f9391ce520bb9c76;p=matthijs%2Fprojects%2Fxerxes.git diff --git a/influences/admin.py b/influences/admin.py index afdf6d7..126cd5c 100644 --- a/influences/admin.py +++ b/influences/admin.py @@ -1,5 +1,13 @@ from django.contrib import admin +from django.contrib.admin.util import unquote +from django.shortcuts import get_object_or_404, render_to_response +from django.template import RequestContext from xerxes.influences.models import Character, Influence +from django.contrib.contenttypes import generic +from threadedcomments.models import ThreadedComment +from django.utils.safestring import mark_safe +from django.utils.translation import ugettext as _ +from django.utils.encoding import force_unicode class CharacterAdmin(admin.ModelAdmin): list_filter=('status', 'player') @@ -13,5 +21,32 @@ class InfluenceAdmin(admin.ModelAdmin): search_fields=('character', 'summary', 'description', 'contact') list_display=('character', 'contact', 'summary', 'longterm', 'status') -admin.site.register(Influence, InfluenceAdmin) + class Media: + js = ('base/js/yahoo-dom-event.js', 'base/js/logger-debug.js') + css = {'all' : ('base/css/admin.css',)} + + def __call__(self, request, url): + if (url and url.endswith('/comments')): + return self.comments_view(request, unquote(url[:-9])) + else: + return super(InfluenceAdmin, self).__call__(request, url) + def comments_view(self, request, object_id): + model = self.model + opts = model._meta + obj = get_object_or_404(model, pk=object_id) + + comments = obj.get_comments(private=True) + + context = { + 'title' : _('Commentaar: %s') % force_unicode(obj), + 'root_path' : self.admin_site.root_path, + 'app_label' : self.model._meta.app_label, + 'object' : obj, + 'opts' : opts, + 'comments' : comments, + 'media' : mark_safe(self.media), + } + return render_to_response('admin/influences/influence/comments.html', context, RequestContext(request)) + +admin.site.register(Influence, InfluenceAdmin)