damned-lies r1126 - in branches/djamnedlies: . people stats stats/management/commands teams templates templates/people templates/stats



Author: stephaner
Date: Sun Nov  2 21:54:38 2008
New Revision: 1126
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1126&view=rev

Log:
2008-11-02  StÃphane Raimbault  <stephane raimbault gmail com>

	Moved person components to their own 'people application.
	
	* TODO: Updated.
	* people/admin.py: Moved from stats.admin
	* people/models.py: Used name relation in translates()
	* people/urls.py: Generic views only.
	* stats/admin.py: Updated with new Team and Person models.
	* stats/management/commands/migrate.py: Idem. 
	* stats/models.py: Removed Person class.
	* stats/urls.py: 
	* stats/utils.py:
	* stats/views.py: Removed old views.
	* teams/admin.py:
	* teams/models.py: Renamed model relation from managed_teams to
	coordinates.	
	* teams/urls.py: Restored pageSection.
	* templates/people.html:
	* templates/people/person_detail.html: Removed hack.
	* templates/people/person_list.html:
	* templates/person_base.html: Used get_absolute_url.
	* templates/stats/person_detail.html:
	* urls.py:


Added:
   branches/djamnedlies/people/
   branches/djamnedlies/people/__init__.py
   branches/djamnedlies/people/admin.py
   branches/djamnedlies/people/models.py
   branches/djamnedlies/people/urls.py
   branches/djamnedlies/teams/admin.py
   branches/djamnedlies/templates/people/
   branches/djamnedlies/templates/people/person_detail.html   (contents, props changed)
      - copied, changed from r1122, /branches/djamnedlies/templates/stats/person_detail.html
   branches/djamnedlies/templates/people/person_list.html
      - copied, changed from r1122, /branches/djamnedlies/templates/people.html
Removed:
   branches/djamnedlies/templates/people.html
   branches/djamnedlies/templates/stats/person_detail.html
Modified:
   branches/djamnedlies/ChangeLog
   branches/djamnedlies/TODO
   branches/djamnedlies/stats/admin.py
   branches/djamnedlies/stats/management/commands/migrate.py
   branches/djamnedlies/stats/models.py
   branches/djamnedlies/stats/urls.py
   branches/djamnedlies/stats/utils.py
   branches/djamnedlies/stats/views.py
   branches/djamnedlies/teams/models.py
   branches/djamnedlies/teams/urls.py
   branches/djamnedlies/templates/person_base.html
   branches/djamnedlies/urls.py

Modified: branches/djamnedlies/TODO
==============================================================================
--- branches/djamnedlies/TODO	(original)
+++ branches/djamnedlies/TODO	Sun Nov  2 21:54:38 2008
@@ -1,6 +1,4 @@
 Things left to do:
  * i18n (translation for strings in database?)
- * we could use username instead of person_id (get_absolute_url must
-   be updated accordingly) in urls.py
  * Still a webroot in stats_show.html
-
+ * Replace maintains and translates by the relation names
\ No newline at end of file

Added: branches/djamnedlies/people/__init__.py
==============================================================================

Added: branches/djamnedlies/people/admin.py
==============================================================================
--- (empty file)
+++ branches/djamnedlies/people/admin.py	Sun Nov  2 21:54:38 2008
@@ -0,0 +1,4 @@
+from django.contrib import admin
+from people.models import Person
+
+admin.site.register(Person)

Added: branches/djamnedlies/people/models.py
==============================================================================
--- (empty file)
+++ branches/djamnedlies/people/models.py	Sun Nov  2 21:54:38 2008
@@ -0,0 +1,44 @@
+from django.db import models
+from django.contrib.auth.models import User
+
+def obfuscate_email(email):
+    if email:
+        return email.replace('@', ' at ').replace('.', ' dot ')
+    return ''
+
+class Person(User):
+    """ The User class of D-L. """
+
+    # Deprecated - This field will be removed after the first
+    # production deployment
+    _old_id = models.CharField(max_length=50)
+
+    svn_account = models.SlugField(max_length=20, null=True)
+    image = models.URLField(null=True)
+    webpage_url = models.URLField(null=True)
+    irc_nick = models.SlugField(max_length=20, null=True)
+    bugzilla_account = models.SlugField(null=True)
+
+    class Meta:
+        db_table = 'person'
+
+    def no_spam_email(self):
+        return obfuscate_email(self.email)
+
+    def no_spam_bugzilla_account(self):
+        return obfuscate_email(self.bugzilla_account)
+
+    @property
+    def name(self):
+        return self.first_name + " " + self.last_name
+
+    @models.permalink
+    def get_absolute_url(self):
+        return ('person', [str(self.id)])
+
+    def maintains(self):
+        return self.module_set.all()
+
+    def translates(self): 	 
+        # FIXME The term 'translates' is confusing (see TODO)
+        return self.coordinates.all()

Added: branches/djamnedlies/people/urls.py
==============================================================================
--- (empty file)
+++ branches/djamnedlies/people/urls.py	Sun Nov  2 21:54:38 2008
@@ -0,0 +1,15 @@
+from django.conf.urls.defaults import *
+from people.models import Person
+
+info_dict = {
+    'queryset': Person.objects.all(),
+    'template_object_name': 'person',
+    'extra_context': { 
+        'pageSection': "teams"
+    }
+}
+
+urlpatterns = patterns('django.views.generic.list_detail',
+    url(r'^$', 'object_list', dict(info_dict), 'persons'),                    
+    url(r'(?P<object_id>\d+)/$', 'object_detail', dict(info_dict), 'person')
+)

Modified: branches/djamnedlies/stats/admin.py
==============================================================================
--- branches/djamnedlies/stats/admin.py	(original)
+++ branches/djamnedlies/stats/admin.py	Sun Nov  2 21:54:38 2008
@@ -19,7 +19,7 @@
 # 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 from django.contrib import admin
-from stats.models import Statistics, Module, Branch, Category, Release, Language, Team, Person
+from stats.models import Statistics, Module, Branch, Category, Release, Language
 
 class ReleaseAdmin(admin.ModelAdmin):
     list_display = ('name', 'status', 'stringfrozen')
@@ -30,5 +30,3 @@
 admin.site.register(Category)
 admin.site.register(Release, ReleaseAdmin)
 admin.site.register(Language)
-admin.site.register(Team)
-admin.site.register(Person)

Modified: branches/djamnedlies/stats/management/commands/migrate.py
==============================================================================
--- branches/djamnedlies/stats/management/commands/migrate.py	(original)
+++ branches/djamnedlies/stats/management/commands/migrate.py	Sun Nov  2 21:54:38 2008
@@ -1,7 +1,9 @@
 import os
 import sys
 from django.core.management.base import BaseCommand
-from stats.models import Person, Team, Language, Module, Branch, Domain, Release, Category, Statistics
+from people.models import Person
+from teams.models import Team
+from stats.models import Language, Module, Branch, Domain, Release, Category, Statistics
 from stats.conf import settings
 
 class Command(BaseCommand):

Modified: branches/djamnedlies/stats/models.py
==============================================================================
--- branches/djamnedlies/stats/models.py	(original)
+++ branches/djamnedlies/stats/models.py	Sun Nov  2 21:54:38 2008
@@ -22,47 +22,14 @@
 from datetime import datetime
 from time import tzname
 from django.db import models, connection
-from django.contrib.auth.models import User
 from django.utils.translation import ungettext, ugettext as _, ugettext_noop
 from stats.conf import settings
 from stats import utils
 import potdiff
 
-class Person(User):
-    """ The User class of D-L. """
-
-    # Deprecated - This field will be removed after the first
-    # production deployment
-    _old_id = models.CharField(max_length=50)
-
-    svn_account = models.SlugField(max_length=20, null=True)
-    image = models.URLField(null=True)
-    webpage_url = models.URLField(null=True)
-    irc_nick = models.SlugField(max_length=20, null=True)
-    bugzilla_account = models.SlugField(null=True)
-
-    class Meta:
-        db_table = 'person'
-
-    def no_spam_email(self):
-        return utils.obfuscate_email(self.email)
-
-    def no_spam_bugzilla_account(self):
-        return utils.obfuscate_email(self.bugzilla_account)
-
-    @property
-    def name(self):
-        return self.first_name + " " + self.last_name
-
-    @models.permalink
-    def get_absolute_url(self):
-        return ('person_view', [str(self.id)])
-
-    def maintains(self):
-        return self.module_set.all()
-
+from people.models import Person
 from teams.models import Team
-    
+
 class Language(models.Model):
     name = models.CharField(max_length=50)
     locale = models.CharField(max_length=15)

Modified: branches/djamnedlies/stats/urls.py
==============================================================================
--- branches/djamnedlies/stats/urls.py	(original)
+++ branches/djamnedlies/stats/urls.py	Sun Nov  2 21:54:38 2008
@@ -1,5 +1,4 @@
 from django.conf.urls.defaults import *
-from stats.models import Person
 from stats.conf import settings
 
 # FIXME All these URL must be branched under '/' not '/stats' to
@@ -7,26 +6,9 @@
 urlpatterns = patterns('stats.views',
     url(r'^languages/$', 'languages', name='languages'),
     url(r'^languages/(?P<langcode>\w+)/(?P<release_id>\d+)/$', 'languagerelease', name='languagerelease'),
-    (r'^people/$', 'people'),
     url(r'^module/$', 'modules', name='modules'),
     (r'^module/(?P<module_name>[\w\-\+]+)$', 'module'),
     (r'^module/(?P<module_name>[\w\-\+]+)/(?P<potbase>\w+)/(?P<branch_name>[\w-]+)/(?P<langcode>\w+)/images/$', 'docimages'),
     url(r'^releases/$', 'releases', name='releases'),
     (r'^releases/(?P<release_id>\d+)$', 'release'),
 )
-
-people_dict = {
-    'queryset': Person.objects.all(),
-}
-
-urlpatterns += patterns('django.views.generic',
-    url(r'^people/(?P<object_id>\d+)/$', 'list_detail.object_detail',
-        dict(people_dict), 'person_view'),
-    
-)
-
-# Static files (should be replaced by web server redirection in production
-urlpatterns += patterns('',
-    (r'^POT/(?P<path>.*)$', 'django.views.static.serve',
-     {'document_root': settings.POTDIR}),
-)

Modified: branches/djamnedlies/stats/utils.py
==============================================================================
--- branches/djamnedlies/stats/utils.py	(original)
+++ branches/djamnedlies/stats/utils.py	Sun Nov  2 21:54:38 2008
@@ -23,11 +23,6 @@
 from stats.conf import settings
 import sys, os, re, time, commands
 
-def obfuscate_email(email):
-    if email:
-        return email.replace('@', ' at ').replace('.', ' dot ')
-    return ""
-
 def sortObjectList(lst, tr_field):
     """ Sort an object list with translated_name """
     for l in lst:

Modified: branches/djamnedlies/stats/views.py
==============================================================================
--- branches/djamnedlies/stats/views.py	(original)
+++ branches/djamnedlies/stats/views.py	Sun Nov  2 21:54:38 2008
@@ -19,22 +19,12 @@
 # 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 from django.shortcuts import render_to_response
-from stats.models import Statistics, Team, Language, Person, Module, Release
+from stats.models import Statistics, Language, Module, Release
 from stats.conf import settings
 from djamnedlies.stats import utils
 from django.http import HttpResponse
 from django.utils.translation import ugettext_lazy as _
 
-
-def team(request, name):
-    team = Team.objects.get(name=name)
-    languages = team.language_set.all()
-    context = {
-        'pageSection': "teams",
-        'team': team,
-        'languages': languages}
-    return render_to_response('team_detail.html', context)
-    
 def languages(request):
     all_languages = Language.objects.all()
     context = {
@@ -43,15 +33,6 @@
     }
     return render_to_response('language_list.html', context)
 
-def people(request):
-    """ Print a list of all people in database """
-    all_people = Person.objects.all()
-    context = {
-        'pageSection': "teams",
-        'people': all_people
-    }
-    return render_to_response('people.html', context)
-
 def modules(request):
     all_modules = Module.objects.all()
     context = {

Added: branches/djamnedlies/teams/admin.py
==============================================================================
--- (empty file)
+++ branches/djamnedlies/teams/admin.py	Sun Nov  2 21:54:38 2008
@@ -0,0 +1,4 @@
+from django.contrib import admin
+from teams.models import Team
+
+admin.site.register(Team)

Modified: branches/djamnedlies/teams/models.py
==============================================================================
--- branches/djamnedlies/teams/models.py	(original)
+++ branches/djamnedlies/teams/models.py	Sun Nov  2 21:54:38 2008
@@ -28,7 +28,7 @@
 
     description = models.TextField()
     # Don't confuse this relation with the 'groups' one
-    coordinator = models.ForeignKey(Person, related_name='managed_teams')
+    coordinator = models.ForeignKey(Person, related_name='coordinates')
     webpage_url = models.URLField(null=True)
     mailing_list = models.URLField(null=True)
     mailing_list_subscribe = models.URLField(null=True)

Modified: branches/djamnedlies/teams/urls.py
==============================================================================
--- branches/djamnedlies/teams/urls.py	(original)
+++ branches/djamnedlies/teams/urls.py	Sun Nov  2 21:54:38 2008
@@ -5,6 +5,9 @@
     'queryset': Team.objects.all(),
     'template_object_name': 'team',
     'slug_field': 'name',
+    'extra_context': { 
+        'pageSection': "teams"
+    }
 }
 
 urlpatterns = patterns('',

Copied: branches/djamnedlies/templates/people/person_detail.html (from r1122, /branches/djamnedlies/templates/stats/person_detail.html)
==============================================================================
--- /branches/djamnedlies/templates/stats/person_detail.html	(original)
+++ branches/djamnedlies/templates/people/person_detail.html	Sun Nov  2 21:54:38 2008
@@ -1,18 +1,13 @@
 {% extends "base.html" %}
 {% load i18n %}
 
-{% block title %} {% trans "GNOME Contributor" %} {% endblock %}
+{% block title %}{% trans "GNOME Contributor" %}{% endblock %}
 
 {% block content %}
 <div class="mainpage">
-
-  <h2>{{ object.name}}</h2>
+  <h2>{{ person.name }}</h2>
   {% with 1 as printroles %}
-  {% with object as person %}
   {% include "person_base.html" %}
   {% endwith %}
-  {% endwith %}
-
 </div>
-
 {% endblock %}

Copied: branches/djamnedlies/templates/people/person_list.html (from r1122, /branches/djamnedlies/templates/people.html)
==============================================================================
--- /branches/djamnedlies/templates/people.html	(original)
+++ branches/djamnedlies/templates/people/person_list.html	Sun Nov  2 21:54:38 2008
@@ -1,7 +1,7 @@
 {% extends "base.html" %}
 {% load i18n %}
 
-{% block title %} {% trans "GNOME Contributors" %} {% endblock %}
+{% block title %}{% trans "GNOME Contributors" %}{% endblock %}
 
 {% block content %}
 <div class="mainpage">
@@ -11,7 +11,7 @@
 <p>{% trans "GNOME is being developed by following people:" %}</p>
 
 <div style="column-count:3;-moz-column-count:3;-webkit-column-count:3">
-{% for person in people %}
+{% for person in person_list %}
   <div class="maintainer">
   {% ifnotequal person.image '/media/img/nobody.png' %}
     <img class="people" src="{{ person.image }}" alt="{{ person.name }}" />
@@ -23,8 +23,8 @@
   <a href="{{ person.webpage_url }}">{{ person.webpage_url }}</a><br />
   {% endif %}
   </div>
-
 {% endfor %}
 </div>
+
 </div>
 {% endblock %}

Modified: branches/djamnedlies/templates/person_base.html
==============================================================================
--- branches/djamnedlies/templates/person_base.html	(original)
+++ branches/djamnedlies/templates/person_base.html	Sun Nov  2 21:54:38 2008
@@ -40,7 +40,7 @@
       <h2>{% trans "Maintains:" %}</h2>
       <ul>
         {% for module in person.maintains %}
-        <li><a href="{% url stats.views.module module.name%} ">{{ module.description }}</a></li>
+        <li><a href="{{ module.get_absolute_url }} ">{{ module.description }}</a></li>
         {% endfor %}
       </ul>
       {% endif %}

Modified: branches/djamnedlies/urls.py
==============================================================================
--- branches/djamnedlies/urls.py	(original)
+++ branches/djamnedlies/urls.py	Sun Nov  2 21:54:38 2008
@@ -22,6 +22,7 @@
 urlpatterns = patterns('',
     url(r'^$', 'common.views.index', name='home'),
     (r'^teams/', include('teams.urls')),
+    (r'^people/', include('people.urls')),
     (r'^stats/', include('stats.urls')),
     (r'^admin/(.*)', admin.site.root),
 )



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