# HG changeset patch # User Brian Neal # Date 1409609130 18000 # Node ID ab3deff7672a5b656b322b2e77acd3a808014521 # Parent 0f0ba45704b7e0c56f7a7eaa18edf7f0ddf90bef Private message refactoring: fix up various template issues. Added a template tag to generate the URL to send a PM to a user. This replaced the {% url 'messages-compose_to' username %} in various templates. diff -r 0f0ba45704b7 -r ab3deff7672a messages/templatetags/messages_tags.py --- a/messages/templatetags/messages_tags.py Mon Sep 01 16:38:06 2014 -0500 +++ b/messages/templatetags/messages_tags.py Mon Sep 01 17:05:30 2014 -0500 @@ -1,8 +1,10 @@ """ Template tags for the messages application. + """ from django import template from django.core.urlresolvers import reverse +from django.utils.http import urlquote from messages.models import Message @@ -13,3 +15,9 @@ def unread_messages(user): unread_count = Message.objects.unread_count(user) return {'unread_count': unread_count} + + +@register.simple_tag +def send_pm_url(username): + """Returns the URL to send a PM to a given username""" + return reverse('messages-compose') + '?to={}'.format(urlquote(username)) diff -r 0f0ba45704b7 -r ab3deff7672a sg101/templates/base.html --- a/sg101/templates/base.html Mon Sep 01 16:38:06 2014 -0500 +++ b/sg101/templates/base.html Mon Sep 01 17:05:30 2014 -0500 @@ -53,7 +53,7 @@
  • IRC
  • Member List
  • Member Map
  • -
  • Private Messages
  • +
  • Private Messages
  • Podcast
  • Polls
  • Photo of the Day
  • diff -r 0f0ba45704b7 -r ab3deff7672a sg101/templates/bio/members.html --- a/sg101/templates/bio/members.html Mon Sep 01 16:38:06 2014 -0500 +++ b/sg101/templates/bio/members.html Mon Sep 01 17:05:30 2014 -0500 @@ -1,6 +1,7 @@ {% extends 'bio/base.html' %} {% load cycle from future %} {% load bio_tags %} +{% load messages_tags %} {% block title %}Member List{% endblock %} {% block bio_css %} @@ -40,7 +41,7 @@ {{ u.profile.location }} {{ u.date_joined|date:"M. d, Y" }} - {% ifnotequal user u %} + {% ifnotequal user u %} PM{% endifnotequal %} {% if not u.profile.hide_email %} Email{% endif %} diff -r 0f0ba45704b7 -r ab3deff7672a sg101/templates/bio/view_profile.html --- a/sg101/templates/bio/view_profile.html Mon Sep 01 16:38:06 2014 -0500 +++ b/sg101/templates/bio/view_profile.html Mon Sep 01 17:05:30 2014 -0500 @@ -3,6 +3,7 @@ {% load elsewhere_tags %} {% load core_tags %} {% load forum_tags %} +{% load messages_tags %} {% block title %}User Profile for {{ subject.username }}{% endblock %} {% block custom_js %}