damned-lies r1226 - in trunk: . people teams templates/teams



Author: stephaner
Date: Fri Dec 19 16:58:07 2008
New Revision: 1226
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1226&view=rev

Log:
2008-12-19  StÃphane Raimbault  <stephane raimbault gmail com>

	* people/models.py: Added missing copyright and new methods for
	the committer.	
	* teams/models.py: Tips to keep the current performance.
	* teams/views.py:
	* templates/teams/team_base.html:
	* templates/teams/team_list.html: A coordinator is a usual team
	member with a different role.


Modified:
   trunk/ChangeLog
   trunk/people/models.py
   trunk/teams/models.py
   trunk/teams/views.py
   trunk/templates/teams/team_base.html
   trunk/templates/teams/team_list.html

Modified: trunk/people/models.py
==============================================================================
--- trunk/people/models.py	(original)
+++ trunk/people/models.py	Fri Dec 19 16:58:07 2008
@@ -1,5 +1,25 @@
-import datetime
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2008 Claude Paroz <claude 2xlibre net>.
+# Copyright (c) 2008 StÃphane Raimbault <stephane raimbault gmail com>.
+#
+# This file is part of Damned Lies.
+#
+# Damned Lies is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Damned Lies is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Damned Lies; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+import datetime
 from django.db import models
 from django.contrib.auth.models import User, UserManager
 
@@ -57,27 +77,37 @@
     def get_absolute_url(self):
         return ('person', [self.username])
 
+    def coordinates_teams(self):
+        from teams.models import Team
+        return Team.objects.filter(role__person__id=self.id).all()
+
+    def is_coordinator(self, team):
+        try:
+            self.role_set.get(team__id=team.id, role='coordinator')
+            return True
+        except:
+            return False
+        
     def is_committer(self, team):
         try:
-            self.role_set.get(team=team, role='committer')
+            self.role_set.get(team__id=team.id, role__in=['committer', 'coordinator'])
             return True
         except:
             return False
 
     def is_reviewer(self, team):
         try:
-            self.role_set.get(team=team, role='reviewer')
+            self.role_set.get(team__id=team.id, role__in=['reviewer', 'committer', 'coordinator'])
             return True
         except:
             return False
 
     def is_translator(self, team):
         try:
-            self.role_set.get(team=team, role='translator')
+            self.role_set.get(team__id=team.id)
             return True
         except:
             return False
 
     # Related names
     # - module: maintains_modules
-    # - team: coordinates_teams

Modified: trunk/teams/models.py
==============================================================================
--- trunk/teams/models.py	(original)
+++ trunk/teams/models.py	Fri Dec 19 16:58:07 2008
@@ -28,8 +28,6 @@
        The lang_code is generally used."""
 
     description = models.TextField()
-    # Don't confuse this relation with the 'groups' one
-    coordinator = models.ForeignKey(Person, related_name='coordinates_teams')
     members = models.ManyToManyField(Person, through='Role', related_name='teams')
     webpage_url = models.URLField(null=True, blank=True)
     mailing_list = models.EmailField(null=True, blank=True)
@@ -51,9 +49,14 @@
     
     def get_languages(self):
         return self.language_set.all()
-    
+
+    def get_coordinator(self):
+        # The join by role__team__id generates only one query and
+        # the same one by role__team=self two queries!
+        return Person.objects.get(role__team__id=self.id, role__role='coordinator')
+
     def get_members_by_role(self, role):
-        members = Person.objects.filter(role__team=self, role__role=role)
+        members = Person.objects.filter(role__team__id=self.id, role__role=role)
         return members
         
     def get_committers(self):

Modified: trunk/teams/views.py
==============================================================================
--- trunk/teams/views.py	(original)
+++ trunk/teams/views.py	Fri Dec 19 16:58:07 2008
@@ -59,7 +59,7 @@
                },
     )
 
-    if request.user.is_authenticated() and request.user == team.coordinator:
+    if request.user.is_authenticated() and request.user == team.get_coordinator():
         if request.method == 'POST':
             form_type = request.POST['form_type']
             roles = Role.objects.filter(team=team, role=form_type)

Modified: trunk/templates/teams/team_base.html
==============================================================================
--- trunk/templates/teams/team_base.html	(original)
+++ trunk/templates/teams/team_base.html	Fri Dec 19 16:58:07 2008
@@ -27,9 +27,9 @@
   {% endif %}
   
   </td><td valign="top">
-  {% if team.coordinator %}
+  {% if team.get_coordinator %}
     <h2>{% trans "Coordinator" %}</h2>
-    {% with team.coordinator as person %}
+    {% with team.get_coordinator as person %}
     {% with 0 as printroles %}
     {% include "person_base.html" %}
     {% endwith %}

Modified: trunk/templates/teams/team_list.html
==============================================================================
--- trunk/templates/teams/team_list.html	(original)
+++ trunk/templates/teams/team_list.html	Fri Dec 19 16:58:07 2008
@@ -18,12 +18,14 @@
       {% if team.webpage_url %}
         &mdash; <a href="{{ team.webpage_url }}">{{ team.webpage_url }}</a>
       {% endif %}
-      {% if team.coordinator.get_absolute_url %}
-        <br />
-        <span style="font-size: 80%;">
-          {% blocktrans with team.coordinator.get_absolute_url|safe as url and team.coordinator.name as name %}Coordinated by <a href="{{ url }}">{{ name }}</a>{% endblocktrans %}
-        </span>
+      {% with team.get_coordinator as coordinator %}
+      {% if coordinator %}
+      <br />
+      <span style="font-size: 80%;">
+        {% blocktrans with coordinator.get_absolute_url|safe as url and coordinator.name as name %}Coordinated by <a href="{{ url }}">{{ name }}</a>{% endblocktrans %}
+      </span>
       {% endif %}
+      {% endwith %}
     </li>
     {% endfor %}
     </ul>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]