From: jordan Date: Thu, 10 Mar 2011 02:17:56 +0000 (+0000) Subject: sync merge jambazov -> trunk X-Git-Tag: live~442 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/e0d5c785d7c2635a16b48cad54151b732c1842ea sync merge jambazov -> trunk git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@806 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/skins/default/templates/node/permanent_link.html b/forum/skins/default/templates/node/permanent_link.html new file mode 100644 index 0000000..0ea2941 --- /dev/null +++ b/forum/skins/default/templates/node/permanent_link.html @@ -0,0 +1,19 @@ +{% load i18n %} + +{% spaceless %} + + + + + +
+{% endspaceless %} + + diff --git a/forum/templatetags/node_tags.py b/forum/templatetags/node_tags.py index 720f822..aab4d99 100644 --- a/forum/templatetags/node_tags.py +++ b/forum/templatetags/node_tags.py @@ -82,13 +82,16 @@ def post_control(text, url, command=False, withprompt=False, confirm=False, titl def post_controls(post, user): controls = [] menu = [] + post_type = post.node_type - if user.is_authenticated(): - post_type = post.node_type - - if post_type == "answer": - controls.append(post_control(_('permanent link'), post.get_absolute_url(), title=_("answer permanent link"))) + # We show the link tool if the post is an Answer. It is visible to Guests too. + if post_type == "answer": + # Answer permanent link tool + controls.append(post_control(_('permanent link'), reverse('answer_permanent_link', kwargs={'id' : post.id}), + title=_("answer permanent link"), command=True, withprompt=True)) + # The other controls are visible only to authenticated users. + if user.is_authenticated(): edit_url = reverse('edit_' + post_type, kwargs={'id': post.id}) if user.can_edit_post(post): controls.append(post_control(_('edit'), edit_url)) diff --git a/forum/urls.py b/forum/urls.py index 2817521..f53ccae 100644 --- a/forum/urls.py +++ b/forum/urls.py @@ -83,8 +83,8 @@ urlpatterns += patterns('', name="delete_comment"), url(r'^%s(?P\d+)/$' % _('convert_comment/'), app.commands.convert_comment_to_answer, name="convert_comment"), - url(r'^%s(?P\d+)/$' % _('accept_answer/'), app.commands.accept_answer, name="accept_answer") - , + url(r'^%s(?P\d+)/$' % _('accept_answer/'), app.commands.accept_answer, name="accept_answer"), + url(r'^%s(?P\d+)/$' % _('answer_link/'), app.commands.answer_permanent_link, name="answer_permanent_link"), url(r'^%s(?P\d+)/$' % _('mark_favorite/'), app.commands.mark_favorite, name="mark_favorite") , url(r'^%s(?P\d+)/' % _('flag/'), app.commands.flag_post, name='flag_post'), diff --git a/forum/views/commands.py b/forum/views/commands.py index af6ad64..3d2f9d3 100644 --- a/forum/views/commands.py +++ b/forum/views/commands.py @@ -570,9 +570,13 @@ def related_questions(request): else: raise Http404() +@decorate.withfn(command) +def answer_permanent_link(request, id): + # Getting the current answer object + answer = get_object_or_404(Answer, id=id) + # Getting the current object URL -- the Application URL + the object relative URL + url = '%s%s' % (settings.APP_BASE_URL, answer.get_absolute_url()) - - - - + # Display the template + return render_to_response('node/permanent_link.html', { 'url' : url, })