From ceafe55f5acae09c6f51b72881a3d564bfe730fa Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 31 Oct 2008 17:44:27 +0100 Subject: [PATCH] Add a custom comment preview view for influences. --- influences/views.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/influences/views.py b/influences/views.py index a8b9a7d..1025efa 100644 --- a/influences/views.py +++ b/influences/views.py @@ -10,7 +10,7 @@ from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect, HttpResponseForbidden from django.views.generic.list_detail import object_detail, object_list from threadedcomments.models import ThreadedComment -from threadedcomments.views import free_comment +from threadedcomments.views import free_comment, _preview from xerxes.influences.models import Character from xerxes.influences.models import Influence from forms import get_influence_comment_form, InfluenceForm, CharacterForm @@ -89,6 +89,15 @@ def influence_list(request): os = Influence.objects.filter(character__player=request.user) return render_to_response('influences/influence_list.html', {'object_list' : os}, RequestContext(request)) +def influence_comment_preview(request, context_processors, extra_context, **kwargs): + # Use a custom template + kwargs['template'] = 'influences/influence_comment_preview.html' + # The base template to extend + extra_context['base'] = "influences/influence_detail.html" + # The object to be show in the influence detail + extra_context['object'] = get_object_or_404(Influence, pk=kwargs['object_id']) + return _preview(request, context_processors, extra_context, **kwargs) + @login_required def influence_detail(request, object_id): @@ -126,6 +135,7 @@ def influence_comment(request, object_id, edit_id=None): # that hardcodes the form_class. kwargs['model'] = ThreadedComment # Set a custom preview view + kwargs['preview'] = influence_comment_preview if parent_id: kwargs['prefix'] = "reply-to-%s" % (parent_id) return free_comment(request, object_id=object_id, edit_id=edit_id, **kwargs) -- 2.30.2