friends: fix relations
authorYury Yurevich <the.pythy@gmail.com>
Fri Apr 10 22:10:25 2009 +0700 (2 weeks ago)
changeset 140496e343d31501
parent 14023d37c0ccfd44
child 140584705cf22661
friends: fix relations
apps/friends/admin.py
apps/friends/models.py
templates/friends/index.html
templates/friends/sidebar.html
       1 --- a/apps/friends/admin.py	Fri Apr 10 21:48:33 2009 +0700
       2 +++ b/apps/friends/admin.py	Fri Apr 10 22:10:25 2009 +0700
       3 @@ -16,10 +16,10 @@
       4          (_('Multiuser/multisite support'), {'classes': ('collapse',),
       5                                              'fields': ('author', 'site',)}),
       6          (_('Relations'), {'classes': ('collapse',),
       7 -                          'fields': ('friendship_rel', 'physical_rel',
       8 -                                     'professional_rel', 'geographical_rel',
       9 -                                     'family_rel', 'romantic_rel',
      10 -                                     'identity_rel')}),
      11 +                          'fields': ('rel_friendship', 'rel_physical',
      12 +                                     'rel_professional', 'rel_geographical',
      13 +                                     'rel_family', 'rel_romantic',
      14 +                                     'rel_identity')}),
      15      )
      16  
      17  admin.site.register(FriendBlog, FriendBlogAdmin)
     1.1 --- a/apps/friends/models.py	Fri Apr 10 21:48:33 2009 +0700
     1.2 +++ b/apps/friends/models.py	Fri Apr 10 22:10:25 2009 +0700
     1.3 @@ -9,13 +9,13 @@
     1.4  class FriendBlog(AggregatedBlog):
     1.5      weight = models.IntegerField(_('Weight'), blank=True, default=0, help_text=_(u'You can order links by this field. Link with smaller number goes first.'))
     1.6  
     1.7 -    friendship_rel = models.CharField(_('Friendship relation'), max_length=20, choices=rels.FRIENDSHIP_REL, blank=True)
     1.8 -    physical_rel = models.CharField(_('Physical relation'), max_length=20, choices=rels.PHYSICAL_REL, blank=True)
     1.9 -    professional_rel =  models.CharField(_('Profesional relation'), max_length=20, choices=rels.PROFESSIONAL_REL, blank=True)
    1.10 -    geographical_rel = models.CharField(_('Geographical relation'), max_length=20, choices=rels.GEOGRAPHICAL_REL, blank=True)
    1.11 -    family_rel = models.CharField(_('Family relation'), max_length=20, choices=rels.FAMILY_REL, blank=True)
    1.12 -    romantic_rel = models.CharField(_('Romantic relation'), max_length=20, choices=rels.ROMANTIC_REL, blank=True)
    1.13 -    identity_rel = models.CharField(_('Identity relation'), max_length=20, choices=rels.IDENTITY_REL, blank=True)
    1.14 +    rel_friendship = models.CharField(_('Friendship relation'), max_length=20, choices=rels.FRIENDSHIP_REL, blank=True)
    1.15 +    rel_physical = models.CharField(_('Physical relation'), max_length=20, choices=rels.PHYSICAL_REL, blank=True)
    1.16 +    rel_professional =  models.CharField(_('Profesional relation'), max_length=20, choices=rels.PROFESSIONAL_REL, blank=True)
    1.17 +    rel_geographical = models.CharField(_('Geographical relation'), max_length=20, choices=rels.GEOGRAPHICAL_REL, blank=True)
    1.18 +    rel_family = models.CharField(_('Family relation'), max_length=20, choices=rels.FAMILY_REL, blank=True)
    1.19 +    rel_romantic = models.CharField(_('Romantic relation'), max_length=20, choices=rels.ROMANTIC_REL, blank=True)
    1.20 +    rel_identity = models.CharField(_('Identity relation'), max_length=20, choices=rels.IDENTITY_REL, blank=True)
    1.21      
    1.22      objects = FriendBlogManager()
    1.23      
    1.24 @@ -25,7 +25,13 @@
    1.25      def save(self, **kwargs):
    1.26          self.target = self.__class__._meta.app_label
    1.27          super(FriendBlog, self).save(**kwargs)
    1.28 -
    1.29 +    
    1.30 +    @property
    1.31 +    def relations(self):
    1.32 +        rels = ['rel_friendship', 'rel_physical', 'rel_professional',
    1.33 +                'rel_geographical', 'rel_family', 'rel_romantic', 'rel_identity']
    1.34 +        return ' '.join(getattr(self, x) for x in rels if getattr(self, x, None))
    1.35 +    
    1.36      @property
    1.37      def _post_class(self):
    1.38          """
     2.1 --- a/templates/friends/index.html	Fri Apr 10 21:48:33 2009 +0700
     2.2 +++ b/templates/friends/index.html	Fri Apr 10 22:10:25 2009 +0700
     2.3 @@ -26,7 +26,8 @@
     2.4  <div class="post_list">
     2.5  	{% for post in object_list %}
     2.6  	<div id="friend-post-{{ post.id }}" class="friend-post post">
     2.7 -		<h3 class="title"><a href="{{ post.get_absolute_url }}">{% autoescape off %}{{ post.title }}{% endautoescape %}</a> / <a href="{{ post.friend.link }}">{{ post.friend.name }}</a>
     2.8 +		<h3 class="title"><a href="{{ post.get_absolute_url }}">{% autoescape off %}{{ post.title }}{% endautoescape %}</a> /
     2.9 +		<nobr><a href="{{ post.friend.link }}"{% if post.friend.relations %} rel="{{ post.friend.relations }}"{% endif %}>{{ post.friend.name }}</a></nobr>
    2.10  		<a href="{{ post.blog.feed }}"><img src="{{ STATIC_URL }}/img/feed-icon-14x14.png" alt="feed" /></a></h3>
    2.11  		<div class="metadata">
    2.12  		    {{ post.posted|datelinks:"friends_" }} {{ post.posted|time }}
     3.1 --- a/templates/friends/sidebar.html	Fri Apr 10 21:48:33 2009 +0700
     3.2 +++ b/templates/friends/sidebar.html	Fri Apr 10 22:10:25 2009 +0700
     3.3 @@ -8,7 +8,7 @@
     3.4      {% if friends %}
     3.5      <ul>
     3.6      {% for friend in friends %}
     3.7 -        <li><a href="{{ friend.url }}">{{ friend.name }}</a> <a href="{{ friend.feed }}"><img src="{{ STATIC_URL }}/img/feed-icon-14x14.png" /></a></li>
     3.8 +        <li><a href="{{ friend.url }}"{% if friend.relations %} rel="{{ friend.relations }}"{% endif %}>{{ friend.name }}</a> <a href="{{ friend.feed }}"><img src="{{ STATIC_URL }}/img/feed-icon-14x14.png" /></a></li>
     3.9      {% endfor %}
    3.10      </ul>
    3.11      {% else %}