--- /dev/null
+{% load i18n %}
+
+{% spaceless %}
+<table>
+ <tr>
+ <td><label for="permanent_link_url">{% trans "Permanent link" %}:</label></td>
+ <td><input id="permanent_link_url" readonly="readonly" type="text" value="{{ url }}" /></td>
+ </tr>
+</table>
+{% endspaceless %}
+
+<script type="text/javascript">
+$(document).ready(function() {
+ // We highlight the content of the text field on click event
+ $('#permanent_link_url').click(function() {
+ $(this).select();
+ })
+})
+</script>
def post_controls(post, user):\r
controls = []\r
menu = []\r
+ post_type = post.node_type\r
\r
- if user.is_authenticated():\r
- post_type = post.node_type\r
-\r
- if post_type == "answer":\r
- controls.append(post_control(_('permanent link'), post.get_absolute_url(), title=_("answer permanent link")))\r
+ # We show the link tool if the post is an Answer. It is visible to Guests too.\r
+ if post_type == "answer":\r
+ # Answer permanent link tool\r
+ controls.append(post_control(_('permanent link'), reverse('answer_permanent_link', kwargs={'id' : post.id}),\r
+ title=_("answer permanent link"), command=True, withprompt=True))\r
\r
+ # The other controls are visible only to authenticated users.\r
+ if user.is_authenticated():\r
edit_url = reverse('edit_' + post_type, kwargs={'id': post.id})\r
if user.can_edit_post(post):\r
controls.append(post_control(_('edit'), edit_url))\r
name="delete_comment"),
url(r'^%s(?P<id>\d+)/$' % _('convert_comment/'), app.commands.convert_comment_to_answer,
name="convert_comment"),
- url(r'^%s(?P<id>\d+)/$' % _('accept_answer/'), app.commands.accept_answer, name="accept_answer")
- ,
+ url(r'^%s(?P<id>\d+)/$' % _('accept_answer/'), app.commands.accept_answer, name="accept_answer"),
+ url(r'^%s(?P<id>\d+)/$' % _('answer_link/'), app.commands.answer_permanent_link, name="answer_permanent_link"),
url(r'^%s(?P<id>\d+)/$' % _('mark_favorite/'), app.commands.mark_favorite, name="mark_favorite")
,
url(r'^%s(?P<id>\d+)/' % _('flag/'), app.commands.flag_post, name='flag_post'),
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, })