diff options
author | Aamir Khan <syst3m.w0rm@gmail.com> | 2012-07-05 11:53:09 -0400 |
---|---|---|
committer | Aamir Khan <syst3m.w0rm@gmail.com> | 2012-07-05 11:53:09 -0400 |
commit | 3db8dd7d9328e38fbc8eacf0f7553778bc31d94f (patch) | |
tree | ace66373e47453b92f8c7b7e51aae9c3c7e9c836 | |
parent | e39e81586dd268ce0cc5009f1c4b32a6985f8274 (diff) | |
download | hyperkitty-3db8dd7d9328e38fbc8eacf0f7553778bc31d94f.tar.gz hyperkitty-3db8dd7d9328e38fbc8eacf0f7553778bc31d94f.tar.xz hyperkitty-3db8dd7d9328e38fbc8eacf0f7553778bc31d94f.zip |
Display message snippet on user profile page
-rw-r--r-- | models.py | 11 | ||||
-rw-r--r-- | templates/base.html | 2 | ||||
-rw-r--r-- | templates/user_profile.html | 30 | ||||
-rw-r--r-- | templatetags/poll_extras.py | 5 |
4 files changed, 45 insertions, 3 deletions
@@ -1,7 +1,13 @@ from django.db import models from django.contrib.auth.models import User +from django.conf import settings + +from kittystore.kittysastore import KittySAStore + from gsoc.utils import log +STORE = KittySAStore(settings.KITTYSTORE_URL) + class Rating(models.Model): # @TODO: instead of list_address, user list model from kittystore? @@ -36,6 +42,11 @@ class UserProfile(models.Model): except Rating.DoesNotExist: votes = {} + for vote in votes: + list_name = vote.list_address.split('@')[0] + message = STORE.get_email(list_name, vote.messageid) + vote.message = message + return votes votes = property(_get_votes) diff --git a/templates/base.html b/templates/base.html index ee1f66e..0ae6d4c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -3,7 +3,7 @@ <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="ROBOTS" content="INDEX, FOLLOW" /> - <title>{% block title %}{{ app_name }}{% endblock %}</title> + <title>{% block title %}{{ app_name|title }}{% endblock %}</title> <meta name="author" content="" /> <meta name="dc.language" content="en" /> <link rel="stylesheet" type="text/css" media="all" href="{{ STATIC_URL }}css/normalize.css" /> diff --git a/templates/user_profile.html b/templates/user_profile.html index 057ef6b..f0aa27e 100644 --- a/templates/user_profile.html +++ b/templates/user_profile.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load i18n %} +{% load poll_extras %} {% block content %} <h1>User Profile <span>- {{ user }}</span></h1> @@ -32,12 +33,37 @@ </tr> </tbody> </table> - <h2> Votes : </h2> + <h3> Up Votes : </h3> <ul> {% for vote in user_profile.votes %} - <li><a href="/message/{{vote.list_address}}/{{vote.messageid}}">{{ vote.vote }}</a></li> + {% if vote.vote == 1 %} + <li> + {% if vote.message.content|trimString|length > 0 %} + <a href="/message/{{vote.list_address}}/{{vote.messageid}}">{{ vote.message.content|truncatechars:20 }}</a> + {% else %} + <a href="/message/{{vote.list_address}}/{{vote.messageid}}">Message is empty</a> + {% endif %} + </li> + {% endif %} {% endfor %} </ul> + <h3> Down Votes : </h3> + + <ul> + {% for vote in user_profile.votes %} + {% if vote.vote == -1 %} + <li> + {% if vote.message.content|trimString|length > 0 %} + <a href="/message/{{vote.list_address}}/{{vote.messageid}}">{{ vote.message.content|truncatechars:20 }}</a> + {% else %} + <a href="/message/{{vote.list_address}}/{{vote.messageid}}">Message is empty</a> + {% endif %} + </li> + {% endif %} + {% endfor %} + </ul> + + {% endblock %} diff --git a/templatetags/poll_extras.py b/templatetags/poll_extras.py index bdfbbc5..a5f1032 100644 --- a/templatetags/poll_extras.py +++ b/templatetags/poll_extras.py @@ -1,9 +1,14 @@ from django import template from django.http import HttpRequest from django.utils.datastructures import SortedDict +import re register = template.Library() +@register.filter(name="trimString") +def trimString(str): + return re.sub('\s+', ' ', str) + @register.filter(name='sort') def listsort(value): if isinstance(value, dict): |