Author: leidel
Date: Sat Oct  4 11:29:30 2008
New Revision: 1009

Added:
    trunk/apps/local_apps/zwitschern/templates/zwitschern/
    trunk/apps/local_apps/zwitschern/templates/zwitschern/base.html
    trunk/apps/local_apps/zwitschern/templates/zwitschern/followers.html
    trunk/apps/local_apps/zwitschern/templates/zwitschern/following.html
    trunk/apps/local_apps/zwitschern/templates/zwitschern/friends_tweets.html
    trunk/apps/local_apps/zwitschern/templates/zwitschern/listing.html
    trunk/apps/local_apps/zwitschern/templates/zwitschern/personal.html
    trunk/apps/local_apps/zwitschern/templates/zwitschern/public.html
    trunk/apps/local_apps/zwitschern/templates/zwitschern/single.html
Modified:
    trunk/apps/local_apps/zwitschern/models.py
     
trunk/apps/local_apps/zwitschern/templates/notification/tweet_reply_received/teaser.html
    trunk/apps/local_apps/zwitschern/urls.py
    trunk/apps/local_apps/zwitschern/views.py

Log:
Added __unicode__ and get_absolute_url to Tweet model and added default  
templates

Modified: trunk/apps/local_apps/zwitschern/models.py
==============================================================================
--- trunk/apps/local_apps/zwitschern/models.py  (original)
+++ trunk/apps/local_apps/zwitschern/models.py  Sat Oct  4 11:29:30 2008
@@ -49,11 +49,18 @@
      sender = models.ForeignKey(User, related_name="sent_tweets",  
verbose_name=_('sender'))
      sent = models.DateTimeField(_('sent'), default=datetime.now)

+    def __unicode__(self):
+        return self.text
+
      def html(self):
          return format_tweet(self.text)

+    def get_absolute_url(self):
+        return ("single_tweet", [self.id])
+    get_absolute_url = models.permalink(get_absolute_url)
+
      class Meta:
-        ordering = ('-sent', )
+        ordering = ('-sent',)


  class TweetInstanceManager(models.Manager):

Modified:  
trunk/apps/local_apps/zwitschern/templates/notification/tweet_reply_received/teaser.html
==============================================================================
---  
trunk/apps/local_apps/zwitschern/templates/notification/tweet_reply_received/teaser.html
         
(original)
+++  
trunk/apps/local_apps/zwitschern/templates/notification/tweet_reply_received/teaser.html
         
Sat Oct  4 11:29:30 2008
@@ -1,2 +1,2 @@
-{% load i18n %}{% url profile_detail username=tweet.sender.username as  
profile_url %}{% url single_tweet tweet.id as reply_url %}
-{% blocktrans with tweet.sender as tweet_sender %}<a href="{{ profile_url  
}}">{{ tweet_sender }}</a> sent you a <a href="{{ reply_url }}">tweet  
reply</a>.{% endblocktrans %}
\ No newline at end of file
+{% load i18n %}{% url profile_detail username=tweet.sender.username as  
profile_url %}
+{% blocktrans with tweet.sender as tweet_sender and tweet.get_absolute_url  
as reply_url %}<a href="{{ profile_url }}">{{ tweet_sender }}</a> sent you  
a <a href="{{ reply_url }}">tweet reply</a>.{% endblocktrans %}
\ No newline at end of file

Added: trunk/apps/local_apps/zwitschern/templates/zwitschern/base.html
==============================================================================
--- (empty file)
+++ trunk/apps/local_apps/zwitschern/templates/zwitschern/base.html     Sat  
Oct  4 11:29:30 2008
@@ -0,0 +1,13 @@
+{% extends "site_base.html" %}
+
+{% load i18n %}
+
+{% block subnav %}
+    <ul>
+        <li><a href="{% url tweets_you_follow %}">{% trans "Tweets You  
Follow" %}</a></li>
+        <li><a href="{% url friends_tweets %}">{% trans "Friends'  
Tweets" %}</a></li>
+        <li><a href="{% url all_tweets %}">{% trans "All  
Tweets" %}</a></li>
+        <li><a href="{% url tweet_followers request.user %}">{%  
trans "Your Followers" %}</a></li>
+        <li><a href="{% url tweet_following request.user %}">{% trans "Who  
You Are Following" %}</a></li>
+    </ul>
+{% endblock %}

Added: trunk/apps/local_apps/zwitschern/templates/zwitschern/followers.html
==============================================================================
--- (empty file)
+++ trunk/apps/local_apps/zwitschern/templates/zwitschern/followers.html        
 
Sat Oct  4 11:29:30 2008
@@ -0,0 +1,25 @@
+{% extends "zwitschern/base.html" %}
+
+{% load i18n %}
+
+{% block head_title %}{% blocktrans %}Followers of {{ other_user }}{%  
endblocktrans %}{% endblock %}
+
+{% block body %}
+    <h1>{% blocktrans %}Followers of {{ other_user }}{%  
endblocktrans %}</h1>
+
+    <p>{% blocktrans with other_user.get_profile.get_absolute_url as  
other_user_url %}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">
+                <div><a href="{{  
following.follower.get_profile.get_absolute_url }}">{{ following.follower  
}}</a></div>
+            </div>
+        {% endfor %}
+    {% else %}
+        <p>{% trans 'No followers.' %}</p>
+    {% endif %}
+
+    {% url tweet_following other_user.username as tweet_following_url %}
+    <p>{% blocktrans %}Also see <a href="{{ tweet_following_url }}">who {{  
other_user }} is following</a>.{% endblocktrans %}
+{% endblock %}
\ No newline at end of file

Added: trunk/apps/local_apps/zwitschern/templates/zwitschern/following.html
==============================================================================
--- (empty file)
+++ trunk/apps/local_apps/zwitschern/templates/zwitschern/following.html        
 
Sat Oct  4 11:29:30 2008
@@ -0,0 +1,25 @@
+{% extends "zwitschern/base.html" %}
+
+{% load i18n %}
+
+{% block head_title %}{% blocktrans %}{{ other_user }} is Following{%  
endblocktrans %}{% endblock %}
+
+{% block body %}
+    <h1>{% blocktrans %}{{ other_user }} is Following{%  
endblocktrans %}</h1>
+
+    <p>{% blocktrans with other_user.get_profile.get_absolute_url as  
other_user_url %}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">
+                <div><a href="{{  
following.followed.get_profile.get_absolute_url }}">{{ following.followed  
}}</a></div>
+            </div>
+        {% endfor %}
+    {% else %}
+        <p>{% trans 'Not following anyone.' %}</p>
+    {% endif %}
+
+    {% url tweet_followers other_user.username as tweet_followers_url %}
+    <p>{% blocktrans %}Also see <a href="{{ tweet_followers_url }}">who is  
following</a> {{ other_user }}.{% endblocktrans %}
+{% endblock %}
\ No newline at end of file

Added:  
trunk/apps/local_apps/zwitschern/templates/zwitschern/friends_tweets.html
==============================================================================
--- (empty file)
+++  
trunk/apps/local_apps/zwitschern/templates/zwitschern/friends_tweets.html       
 
Sat Oct  4 11:29:30 2008
@@ -0,0 +1,25 @@
+{% extends "zwitschern/base.html" %}
+
+{% load i18n %}
+
+{% block head_title %}{% blocktrans %}Friends' Tweets{% endblocktrans %}{%  
endblock %}
+
+{% block body %}
+    <h2>{% trans "Friends' Tweets" %}</h2>
+
+    <p>{% trans "These are tweets from your friends:" %}</p>
+
+    {% if object_list %}
+        {% for tweet in object_list %}
+            <div class="tweet" id="t{{ tweet.id }}">
+                <a name="tweet-{{ tweet.id }}"></a>
+                <p><a href="{{ tweet.sender.get_profile.get_absolute_url  
}}"><b>{{ tweet.sender }}</b></a>
+                {{ tweet.html|safe|urlize }}</p>
+                <span class="timesince">{% blocktrans with tweet.sent| 
timesince as tweet_age %}{{ tweet_age }} ago{% endblocktrans %}</span>
+                <a class="reply" href="{% url  
tweets_you_follow %}?reply={{ tweet.sender }}">{% trans "reply" %}</a>
+             </div>
+        {% endfor %}
+    {% else %}
+        <p>{% blocktrans %}No tweets yet.{% endblocktrans %}</p>
+    {% endif %}
+{% endblock %}

Added: trunk/apps/local_apps/zwitschern/templates/zwitschern/listing.html
==============================================================================
--- (empty file)
+++ trunk/apps/local_apps/zwitschern/templates/zwitschern/listing.html  Sat  
Oct  4 11:29:30 2008
@@ -0,0 +1,19 @@
+{% load i18n %}
+
+{% if tweets %}
+    {% for tweet in tweets %}
+        <div class="tweet" id="t{{ tweet.id }}">
+            {% if prefix_sender %}<a href="{{  
tweet.sender.get_profile.get_absolute_url }}"><b>{{ tweet.sender  
}}</b></a>{% endif %}
+            {{ tweet.html|safe|urlize }}
+            <span class="timesince">{% blocktrans with tweet.sent| 
timesince as tweet_age %}{{ tweet_age }} ago{% endblocktrans %}</span>
+            <a class="reply" href="{% url tweets_you_follow %}?reply={{  
tweet.sender }}">{% trans "reply" %}</a>
+         </div>
+    {% endfor %}
+{% else %}
+    {% if are_mine %}
+        {% url tweets_you_follow as tweets_url %}
+        <p>{% blocktrans %}You haven't posted any <a href="{{ tweets_url  
}}">tweets</a> yet.{% endblocktrans %}</p>
+    {% else %}
+        <p>{% blocktrans %}There are currently no tweets to be listed.{%  
endblocktrans %}</p>
+    {% endif %}
+{% endif %}

Added: trunk/apps/local_apps/zwitschern/templates/zwitschern/personal.html
==============================================================================
--- (empty file)
+++ trunk/apps/local_apps/zwitschern/templates/zwitschern/personal.html Sat  
Oct  4 11:29:30 2008
@@ -0,0 +1,79 @@
+{% extends "zwitschern/base.html" %}
+
+{% load i18n %}
+{% load zwitschern %}
+
+{% block head_title %}{% blocktrans %}Tweets{% endblocktrans %}{%  
endblock %}
+
+{% block extra_head %}
+    <link rel="alternate" type="application/atom+xml" title="Tweets Feed  
for User {{ user.username|capfirst }}" href="/feeds/tweets/only/{{  
user.username }}/" />
+    <link rel="alternate" type="application/atom+xml" title="Tweets Feed  
for User {{ user.username|capfirst }} and friends"  
href="/feeds/tweets/with_friends/{{ user.username }}/" />
+{% endblock %}
+
+{% block body %}
+    <h1>{% trans "Tweets" %}</h1>
+
+    <form method="POST" action="{% url tweets_you_follow %}">
+        <p>{% trans "What are you doing?" %}</p>
+        {{ form.as_p }}
+        {% if twitter_authorized %}
+        <h2>{% trans "You have authorized a twitter account." %}</h2>
+        <input name="pub2twitter" type="checkbox" id="pub2twitter"  
value="yes" />
+        <label for="pub2twitter">{% trans "Publish to Twitter?" %}</label>
+        {% endif %}
+
+        {% if pownce_authorized %}
+        <h2>{% trans "You have authorized a pownce account." %}</h2>
+        <input name="pub2pownce" type="checkbox" id="pub2pownce"  
value="yes" />
+        <label for="pub2pownce">{% trans "Publish to Pownce?" %}</label>
+        {% endif %}
+
+        <p>
+            <span id="chars_left"></span> {% trans "chars left." %}
+            <input type="submit" value="{% trans "post" %}">
+        </p>
+    </form>
+
+    <p>{% blocktrans with user.followed.count as follow_count and  
user.followed.count|pluralize:_("person,people") as follow_name %}
+        These are tweets from the {{ follow_count }} {{ follow_name }} you  
are following (plus your own){% endblocktrans %}:
+    </p>
+
+    {% tweet_listing tweets 1 0 %}
+
+{% endblock %}
+
+{% block extra_body %}
+    <script>
+        $(document).ready(function() {
+            function update_chars_left() {
+                var max_len = 140;
+                var textarea = $('#new_tweet')[0];
+                var tweet_len = textarea.value.length;
+                if (tweet_len >= max_len) {
+                    textarea.value = textarea.value.substring(0, max_len);  
// truncate
+                    $('#chars_left').html("0");
+                } else {
+                    $('#chars_left').html(max_len - tweet_len);
+                }
+            }
+            $('#new_tweet').keyup(function() {
+                update_chars_left();
+            });
+            update_chars_left();
+            $('#new_tweet').focus();
+            {% if reply %}
+            var offset = {{ reply|length }} + 2;
+            var textarea = $('#new_tweet')[0];
+            if (textarea.setSelectionRange) { // Safari, Firefox
+                textarea.setSelectionRange(offset, offset);
+            } else if (textarea.createTextRange) { // IE
+                var range = textarea.createTextRange();
+                range.collapse(true);
+                range.moveEnd('character', offset);
+                range.moveStart('character', offset);
+                range.select();
+            }
+            {% endif %}
+        });
+    </script>
+{% endblock %}

Added: trunk/apps/local_apps/zwitschern/templates/zwitschern/public.html
==============================================================================
--- (empty file)
+++ trunk/apps/local_apps/zwitschern/templates/zwitschern/public.html   Sat  
Oct  4 11:29:30 2008
@@ -0,0 +1,19 @@
+{% extends "zwitschern/base.html" %}
+
+{% load i18n %}
+{% load zwitschern %}
+
+{% block head_title %}{% blocktrans %}Public Tweets{% endblocktrans %}{%  
endblock %}
+
+{% block extra_head %}
+    {# @@@ use url tag #}
+    <link rel="alternate" type="application/atom+xml" title="Tweets Feed  
for all users" href="/feeds/tweets/all/" />
+{% endblock %}
+
+{% block body %}
+    <h1>{% trans "All Tweets" %}</h1>
+
+    <p>{% trans "These are tweets from everyone:" %}</p>
+
+    {% tweet_listing tweets 1 0 %}
+{% endblock %}

Added: trunk/apps/local_apps/zwitschern/templates/zwitschern/single.html
==============================================================================
--- (empty file)
+++ trunk/apps/local_apps/zwitschern/templates/zwitschern/single.html   Sat  
Oct  4 11:29:30 2008
@@ -0,0 +1,23 @@
+{% extends "zwitschern/base.html" %}
+
+{% load i18n %}
+
+{% block head_title %}{% blocktrans %}Single Tweet{% endblocktrans %}{%  
endblock %}
+
+{% block body %}
+    <h1>{% trans "Single Tweet" %}</h1>
+
+    <p>
+    {% blocktrans with tweet.sender.username as tweet_sender %}
+        Here is a single tweet from {{ tweet_sender }}:
+    {% endblocktrans %}
+    </p>
+
+    <div class="tweet" id="t{{ tweet.id }}">
+        <a href="{{ tweet.sender.get_profile.get_absolute_url }}"><b>{{  
tweet.sender }}</b></a>
+        {{ tweet.html|safe|urlize }}
+        <span class="timesince">{{ tweet.sent|timesince }} ago</span>
+        <a class="reply" href="{% url tweets_you_follow %}?reply={{  
tweet.sender }}">reply</a>
+    </div>
+
+{% endblock %}
\ No newline at end of file

Modified: trunk/apps/local_apps/zwitschern/urls.py
==============================================================================
--- trunk/apps/local_apps/zwitschern/urls.py    (original)
+++ trunk/apps/local_apps/zwitschern/urls.py    Sat Oct  4 11:29:30 2008
@@ -4,7 +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/apps/local_apps/zwitschern/views.py
==============================================================================
--- trunk/apps/local_apps/zwitschern/views.py   (original)
+++ trunk/apps/local_apps/zwitschern/views.py   Sat Oct  4 11:29:30 2008
@@ -11,15 +11,14 @@
  from zwitschern.models import Tweet, TweetInstance
  from zwitschern.forms import TweetForm

[EMAIL PROTECTED]
  def personal(request, form_class=TweetForm,
-    template_name="zwitschern/personal.html", success_url=None):
+        template_name="zwitschern/personal.html", success_url=None):
      """
      just the tweets the current user is following
      """
      twitter_account = twitter_account_for_user(request.user)
      pownce_account  = pownce_account_for_user(request.user)
-
+
      if request.method == "POST":
          form = form_class(request.user, request.POST)
          if form.is_valid():
@@ -46,6 +45,7 @@
          "twitter_authorized": twitter_verify_credentials(twitter_account),
          "pownce_authorized": pownce_verify_credentials(pownce_account),
      }, context_instance=RequestContext(request))
+personal = login_required(personal)

  def public(request, template_name="zwitschern/public.html"):
      """
@@ -82,8 +82,8 @@
      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.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to