Author: jtauber
Date: Sat Sep 27 02:37:21 2008
New Revision: 940
Added:
trunk/pinax/templates/zwitschern/followers.html
trunk/pinax/templates/zwitschern/following.html
Modified:
trunk/local_apps/zwitschern/urls.py
trunk/local_apps/zwitschern/views.py
trunk/pinax/templates/profiles/profile.html
trunk/pinax/templates/zwitschern/base.html
Log:
now show who the followers and followed of a user is
Modified: trunk/local_apps/zwitschern/urls.py
==============================================================================
--- trunk/local_apps/zwitschern/urls.py (original)
+++ trunk/local_apps/zwitschern/urls.py Sat Sep 27 02:37:21 2008
@@ -4,4 +4,7 @@
url(r'^$', 'zwitschern.views.personal', name='tweets_you_follow'),
url(r'^all/$', 'zwitschern.views.public', name='all_tweets'),
url(r'^(\d+)/$', 'zwitschern.views.single', name='single_tweet'),
+
+ url(r'^followers/(\w+)/$', 'zwitschern.views.followers',
name='tweet_followers'),
+ url(r'^following/(\w+)/$', 'zwitschern.views.following',
name='tweet_following'),
)
Modified: trunk/local_apps/zwitschern/views.py
==============================================================================
--- trunk/local_apps/zwitschern/views.py (original)
+++ trunk/local_apps/zwitschern/views.py Sat Sep 27 02:37:21 2008
@@ -2,6 +2,7 @@
from django.http import HttpResponseRedirect
from django.template import RequestContext
from django.contrib.auth.decorators import login_required
+from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from zwitschern.utils import twitter_account_for_user,
twitter_verify_credentials
@@ -64,3 +65,27 @@
return render_to_response(template_name, {
"tweet": tweet,
}, context_instance=RequestContext(request))
+
+
+def _follow_list(request, username, template_name):
+ # the only difference between followers/following views is template
+ # this function captures the similarity
+
+ other_user = get_object_or_404(User, username=username)
+
+ return render_to_response(template_name, {
+ "other_user": other_user,
+ }, context_instance=RequestContext(request))
+
+def followers(request, username,
template_name="zwitschern/followers.html"):
+ """
+ a list of users following the given user.
+ """
+ return _follow_list(request, username, template_name)
+
+
+def following(request, username,
template_name="zwitschern/following.html"):
+ """
+ a list of users the given user is following.
+ """
+ return _follow_list(request, username, template_name)
Modified: trunk/pinax/templates/profiles/profile.html
==============================================================================
--- trunk/pinax/templates/profiles/profile.html (original)
+++ trunk/pinax/templates/profiles/profile.html Sat Sep 27 02:37:21 2008
@@ -23,10 +23,13 @@
{% if other_user.get_profile.website %}<p><b>{%
trans "Website" %}</b>: <a href="{{ other_user.get_profile.website }}">{{
other_user.get_profile.website }}</a></p>{% endif %}
</div>
- <p><b>{% trans "Followers" %}</b>: {{ other_user.followers.count }}
- <b>{% trans "Following" %}</b>: {{ other_user.followed.count }}</p>
{% if user.is_authenticated %}
+ <p>
+ <a href="{% url tweet_followers other_user %}">{%
trans "Followers" %}</a>: {{ other_user.followers.count }}
+ <a href="{% url tweet_following other_user %}">{%
trans "Following" %}</a>: {{ other_user.followed.count }}
+ </p>
+
{% if is_me %}
<p><a href="#" onclick="$('#profile_form').toggle(); return
false;">{% trans "Edit profile" %}</a></p>
Modified: trunk/pinax/templates/zwitschern/base.html
==============================================================================
--- trunk/pinax/templates/zwitschern/base.html (original)
+++ trunk/pinax/templates/zwitschern/base.html Sat Sep 27 02:37:21 2008
@@ -8,5 +8,7 @@
<ul>
<li><a href="{% url tweets_you_follow %}">{% trans "Tweets You
Follow" %}</a></li>
<li><a href="{% url all_tweets %}">{% trans "All
Tweets" %}</a></li>
+ <li><a href="{% url tweet_followers request.user %}">{%
trans "Followers" %}</a></li>
+ <li><a href="{% url tweet_following request.user %}">{%
trans "Following" %}</a></li>
</ul>
{% endblock %}
Added: trunk/pinax/templates/zwitschern/followers.html
==============================================================================
--- (empty file)
+++ trunk/pinax/templates/zwitschern/followers.html Sat Sep 27 02:37:21 2008
@@ -0,0 +1,28 @@
+{% extends "zwitschern/base.html" %}
+
+{% load i18n %}
+{% load gravatar_tags %}
+
+{% block head_title %}{% blocktrans %}Followers of {{ other_user }}{%
endblocktrans %}{% endblock %}
+
+{% block body %}
+ <h1>{% blocktrans %}Followers of {{ other_user }}{%
endblocktrans %}</h1>
+
+ {% url profiles.views.profile other_user.username as other_user_url %}
+
+ <p>{% blocktrans %}Followers of <a href="{{ other_user_url }}">{{
other_user }}</a>'s tweets:{% endblocktrans %}</p>
+
+ {% if other_user.followers.all %}
+ {% for following in other_user.followers.all %}
+ {# @@@ this is common code from all profiles list -- refactor
#}
+ <div class="profile clearfix">
+ {# @@@ factor out style into css file #}
+ <div style="float: left;">{% gravatar following.follower
40 %}</div>
+ <div style="padding: 5px; margin-left: 50px;"><a href="{%
url profiles.views.profile following.follower.username %}">{{
following.follower }}</a></div>
+ </div>
+ {% endfor %}
+ {% else %}
+ <p>{% trans 'No followers.' %}</p>
+ {% endif %}
+
+{% endblock %}
\ No newline at end of file
Added: trunk/pinax/templates/zwitschern/following.html
==============================================================================
--- (empty file)
+++ trunk/pinax/templates/zwitschern/following.html Sat Sep 27 02:37:21 2008
@@ -0,0 +1,27 @@
+{% extends "zwitschern/base.html" %}
+
+{% load i18n %}
+{% load gravatar_tags %}
+
+{% block head_title %}{% blocktrans %}{{ other_user }} is Following{%
endblocktrans %}{% endblock %}
+
+{% block body %}
+ <h1>{% blocktrans %}{{ other_user }} is Following{%
endblocktrans %}</h1>
+
+ {% url profiles.views.profile other_user.username as other_user_url %}
+ <p>{% blocktrans %}Users whose tweets <a href="{{ other_user_url
}}">{{ other_user }}</a> is following:{% endblocktrans %}</p>
+
+ {% if other_user.followed.all %}
+ {% for following in other_user.followed.all %}
+ {# @@@ this is common code from all profiles list -- refactor
#}
+ <div class="profile clearfix">
+ {# @@@ factor out style into css file #}
+ <div style="float: left;">{% gravatar following.followed
40 %}</div>
+ <div style="padding: 5px; margin-left: 50px;"><a href="{%
url profiles.views.profile following.followed.username %}">{{
following.followed }}</a></div>
+ </div>
+ {% endfor %}
+ {% else %}
+ <p>{% trans 'Not following anyone.' %}</p>
+ {% endif %}
+
+{% endblock %}
\ No newline at end of file
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---