Add todo filter to Influence admin.
[matthijs/projects/xerxes.git] / influences / admin.py
index f3e882801f67314c8420580179a4df52921337c4..8abe6cc5334ec9c26847747d4b57baf6f5268216 100644 (file)
@@ -6,8 +6,9 @@ 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 views import get_influence_comment_form, quote_reply
+from django.utils.translation import ugettext as _
+from django.utils.encoding import force_unicode
+from forms import get_influence_comment_form
 
 class CharacterAdmin(admin.ModelAdmin):
     list_filter=('status', 'player')
@@ -17,12 +18,13 @@ class CharacterAdmin(admin.ModelAdmin):
 admin.site.register(Character, CharacterAdmin)
 
 class InfluenceAdmin(admin.ModelAdmin):
-    list_filter=('character', 'status', 'longterm')
+    list_filter=('character', 'status', 'longterm', 'todo')
     search_fields=('character', 'summary', 'description', 'contact')
     list_display=('character', 'contact', 'summary', 'longterm', 'status') 
 
     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')):
@@ -35,18 +37,16 @@ class InfluenceAdmin(admin.ModelAdmin):
         opts = model._meta
         obj = get_object_or_404(model, pk=object_id)
 
-        comments = ThreadedComment.objects.get_tree(obj)
-        # Annotate each comment with a proper reply form
-        for comment in comments:
-            initial = { 'comment' : quote_reply(comment) }
-            comment.reply_form = get_influence_comment_form(request.user.is_staff, comment)(initial=initial)
+        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,
+            'comment_form'  : get_influence_comment_form(request.user.is_staff, None)(),
             'media'         : mark_safe(self.media),
         }
         return render_to_response('admin/influences/influence/comments.html', context, RequestContext(request))