]> git.openstreetmap.org Git - osqa.git/commitdiff
sync merge jambazov -> trunk
authorjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 10 Mar 2011 02:17:56 +0000 (02:17 +0000)
committerjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 10 Mar 2011 02:17:56 +0000 (02:17 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@806 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/skins/default/templates/node/permanent_link.html [new file with mode: 0644]
forum/templatetags/node_tags.py
forum/urls.py
forum/views/commands.py

diff --git a/forum/skins/default/templates/node/permanent_link.html b/forum/skins/default/templates/node/permanent_link.html
new file mode 100644 (file)
index 0000000..0ea2941
--- /dev/null
@@ -0,0 +1,19 @@
+{% 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>
index 720f822304406b729f712d87a57ba6f26dab6947..aab4d99ae350c142c2fcf142bb940ff7319ce639 100644 (file)
@@ -82,13 +82,16 @@ def post_control(text, url, command=False, withprompt=False, confirm=False, titl
 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
index 28175216aa20c91d0f31c7fbd15b74503d1ac3c4..f53ccae3530f4cca85ede58eb506b1156bb2f8a5 100644 (file)
@@ -83,8 +83,8 @@ urlpatterns += patterns('',
                             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'),
index af6ad644e8ee6466dad347890b9995e15722a214..3d2f9d32de268da53eb053e0f746b5b30577c3c7 100644 (file)
@@ -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, })