damned-lies r1125 - in branches/djamnedlies: . common stats teams templates templates/teams
- From: stephaner svn gnome org
- To: svn-commits-list gnome org
- Subject: damned-lies r1125 - in branches/djamnedlies: . common stats teams templates templates/teams
- Date: Sun, 2 Nov 2008 20:48:28 +0000 (UTC)
Author: stephaner
Date: Sun Nov 2 20:48:28 2008
New Revision: 1125
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1125&view=rev
Log:
2008-11-02 StÃphane Raimbault <stephane raimbault gmail com>
Moved teams components to their own 'teams' application.
* common/utils.py:
* common/views.py: Moved home.
* stats/models.py:
* stats/urls.py: Removed useless admin.autodiscover().
* stats/views.py: Removed hard URL for coordinator.
* teams/models.py: Add get_absolute_url.
* teams/urls.py: A team is accessible by its id or its name.
* teams/views.py: Use the generic view for detail.
* templates/base.html: Removed rtl not used and wrong on body tag.
* templates/team_detail.html:
* templates/team_list.html:
* templates/teams/team_detail.html: Use team.language_set.all.
* templates/teams/team_list.html: Use team and coordinator
get_absolute_url().
* urls.py: Updated for index and teams.
Added:
branches/djamnedlies/common/
branches/djamnedlies/common/__init__.py
branches/djamnedlies/common/utils.py
branches/djamnedlies/common/views.py
branches/djamnedlies/teams/
branches/djamnedlies/teams/__init__.py
branches/djamnedlies/teams/models.py
branches/djamnedlies/teams/urls.py
branches/djamnedlies/teams/views.py
branches/djamnedlies/templates/teams/
branches/djamnedlies/templates/teams/team_detail.html
- copied, changed from r1122, /branches/djamnedlies/templates/team_detail.html
branches/djamnedlies/templates/teams/team_list.html
- copied, changed from r1122, /branches/djamnedlies/templates/team_list.html
Removed:
branches/djamnedlies/templates/team_detail.html
branches/djamnedlies/templates/team_list.html
Modified:
branches/djamnedlies/ChangeLog
branches/djamnedlies/stats/models.py
branches/djamnedlies/stats/urls.py
branches/djamnedlies/stats/views.py
branches/djamnedlies/templates/base.html
branches/djamnedlies/urls.py
Added: branches/djamnedlies/common/__init__.py
==============================================================================
Added: branches/djamnedlies/common/utils.py
==============================================================================
--- (empty file)
+++ branches/djamnedlies/common/utils.py Sun Nov 2 20:48:28 2008
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2006-2007 Danilo Segan <danilo gnome org>.
+# Copyright (c) 2008 Claude Paroz <claude 2xlibre net>.
+#
+# 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
+
+from django.utils.translation import ugettext as _
+
+def trans_sort_object_list(lst, tr_field):
+ """ Sort an object list with translated_name """
+ for l in lst:
+ l.translated_name = _(getattr(l, tr_field))
+ templist = [(obj_.translated_name.lower(), obj_) for obj_ in lst]
+ templist.sort()
+ return [obj_ for (key1, obj_) in templist]
Added: branches/djamnedlies/common/views.py
==============================================================================
--- (empty file)
+++ branches/djamnedlies/common/views.py Sun Nov 2 20:48:28 2008
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2008 Claude Paroz <claude 2xlibre net>.
+#
+# 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
+
+from django.shortcuts import render_to_response
+from django.utils.translation import ugettext_lazy as _
+
+def index(request):
+ translator_credits = _("translator-credits")
+ # FIXME Not sure the LANGUAGE_CODE test is useful
+ if request.LANGUAGE_CODE == 'en' or translator_credits == "translator-credits":
+ translator_credits = ''
+ else:
+ translator_credits = translator_credits.split('\n')
+
+ context = {
+ 'pageSection': 'home',
+ 'translator_credits': translator_credits
+ }
+ return render_to_response('index.html', context)
Modified: branches/djamnedlies/stats/models.py
==============================================================================
--- branches/djamnedlies/stats/models.py (original)
+++ branches/djamnedlies/stats/models.py Sun Nov 2 20:48:28 2008
@@ -22,7 +22,7 @@
from datetime import datetime
from time import tzname
from django.db import models, connection
-from django.contrib.auth.models import User, Group
+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
@@ -60,33 +60,13 @@
def maintains(self):
return self.module_set.all()
-
- def translates(self):
- return Team.objects.filter(coordinator=self.id)
-
-class Team(Group):
- """ The name of the team is stored in Group.name.
- The lang_code is generally used. """
-
- description = models.TextField()
- # Don't confuse this relation with the 'groups' one
- coordinator = models.ForeignKey('Person', related_name='managed_teams')
- webpage_url = models.URLField(null=True)
- mailing_list = models.URLField(null=True)
- mailing_list_subscribe = models.URLField(null=True)
-
- class Meta:
- db_table = 'team'
- ordering = ('description',)
-
- def __unicode__(self):
- return self.description
-
+from teams.models import Team
+
class Language(models.Model):
name = models.CharField(max_length=50)
locale = models.CharField(max_length=15)
- team = models.ForeignKey('Team', null=True)
+ team = models.ForeignKey(Team, null=True)
class Meta:
db_table = 'language'
Modified: branches/djamnedlies/stats/urls.py
==============================================================================
--- branches/djamnedlies/stats/urls.py (original)
+++ branches/djamnedlies/stats/urls.py Sun Nov 2 20:48:28 2008
@@ -2,18 +2,10 @@
from stats.models import Person
from stats.conf import settings
-# Uncomment the next two lines to enable the admin:
-from django.contrib import admin
-admin.autodiscover()
-
# FIXME All these URL must be branched under '/' not '/stats' to
# maintain an URL compatibility with the old DL
urlpatterns = patterns('stats.views',
- (r'^$', 'index'),
- url(r'^teams/$', 'teams', name='teams'),
- (r'^teams/(?P<name>\w+)$', 'team'),
url(r'^languages/$', 'languages', name='languages'),
- url(r'^languages/(?P<name>\w+)/$', 'team', name='language'),
url(r'^languages/(?P<langcode>\w+)/(?P<release_id>\d+)/$', 'languagerelease', name='languagerelease'),
(r'^people/$', 'people'),
url(r'^module/$', 'modules', name='modules'),
Modified: branches/djamnedlies/stats/views.py
==============================================================================
--- branches/djamnedlies/stats/views.py (original)
+++ branches/djamnedlies/stats/views.py Sun Nov 2 20:48:28 2008
@@ -25,41 +25,10 @@
from django.http import HttpResponse
from django.utils.translation import ugettext_lazy as _
-def index(request):
- translator_credits = _("translator-credits")
- if request.LANGUAGE_CODE == 'en' or translator_credits == "translator-credits":
- translator_credits = ''
- else:
- translator_credits = translator_credits.split('\n')
-
- context = {
- 'pageSection': "home",
- 'rtl': False,
- 'translator_credits': translator_credits
- }
- return render_to_response('index.html', context)
-
-def teams(request):
- all_teams = Team.objects.all()
- for t in all_teams:
- t.coordinator_url = "<a href='%s/people/%s'>%s</a>" % (
- settings.WEBROOT, t.coordinator.id, t.coordinator.name)
-
- context = {
- 'pageSection': "teams",
- 'teams': utils.sortObjectList(all_teams, 'description')
- }
- return render_to_response('team_list.html', context)
def team(request, name):
- try:
- team = Team.objects.get(name=name)
- languages = team.language_set.all()
- except:
- # In the case there is no team for a language
- language = Language.objects.get(locale=name)
- team = {'description': name}
- languages = [language]
+ team = Team.objects.get(name=name)
+ languages = team.language_set.all()
context = {
'pageSection': "teams",
'team': team,
Added: branches/djamnedlies/teams/__init__.py
==============================================================================
Added: branches/djamnedlies/teams/models.py
==============================================================================
--- (empty file)
+++ branches/djamnedlies/teams/models.py Sun Nov 2 20:48:28 2008
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2008 StÃphane Railmbault <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
+
+from django.db import models
+from django.contrib.auth.models import Group
+from stats.models import Person
+
+class Team(Group):
+ """The name of the team is stored in Group.name.
+ The lang_code is generally used."""
+
+ description = models.TextField()
+ # Don't confuse this relation with the 'groups' one
+ coordinator = models.ForeignKey(Person, related_name='managed_teams')
+ webpage_url = models.URLField(null=True)
+ mailing_list = models.URLField(null=True)
+ mailing_list_subscribe = models.URLField(null=True)
+
+ class Meta:
+ db_table = 'team'
+ ordering = ('description',)
+
+ def __unicode__(self):
+ return self.description
+
+ @models.permalink
+ def get_absolute_url(self):
+ return ('team_slug', [self.name])
Added: branches/djamnedlies/teams/urls.py
==============================================================================
--- (empty file)
+++ branches/djamnedlies/teams/urls.py Sun Nov 2 20:48:28 2008
@@ -0,0 +1,14 @@
+from django.conf.urls.defaults import *
+from teams.models import Team
+
+info_dict = {
+ 'queryset': Team.objects.all(),
+ 'template_object_name': 'team',
+ 'slug_field': 'name',
+}
+
+urlpatterns = patterns('',
+ url(r'^$', 'teams.views.teams', name='teams'),
+ url(r'(?P<object_id>\d+)', 'django.views.generic.list_detail.object_detail', dict(info_dict), 'team'),
+ url(r'(?P<slug>\w+)', 'django.views.generic.list_detail.object_detail', dict(info_dict), 'team_slug'),
+)
Added: branches/djamnedlies/teams/views.py
==============================================================================
--- (empty file)
+++ branches/djamnedlies/teams/views.py Sun Nov 2 20:48:28 2008
@@ -0,0 +1,33 @@
+# -*- 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
+
+from django.shortcuts import render_to_response
+from common import utils
+from stats.models import Team
+
+def teams(request):
+ teams = Team.objects.all()
+
+ context = {
+ 'pageSection': 'teams',
+ 'teams': utils.trans_sort_object_list(teams, 'description')
+ }
+ return render_to_response('teams/team_list.html', context)
Modified: branches/djamnedlies/templates/base.html
==============================================================================
--- branches/djamnedlies/templates/base.html (original)
+++ branches/djamnedlies/templates/base.html Sun Nov 2 20:48:28 2008
@@ -17,12 +17,7 @@
<script src="/media/js/main.js" type="text/javascript"></script>
</head>
-{% if rtl %}
- <body dir="rtl">
-{% else %}
- <body>
-{% endif %}
-
+<body>
<div id="page">
<ul id="general">
<li id="siteaction-gnome_home" class="home">
Copied: branches/djamnedlies/templates/teams/team_detail.html (from r1122, /branches/djamnedlies/templates/team_detail.html)
==============================================================================
--- /branches/djamnedlies/templates/team_detail.html (original)
+++ branches/djamnedlies/templates/teams/team_detail.html Sun Nov 2 20:48:28 2008
@@ -44,7 +44,7 @@
{% endif %}
</td></tr></table>
-{% for lang in languages %}
+{% for lang in team.language_set.all %}
<h2>{% trans lang.name %}</h2>
<table class="stats">
<thead><tr><th>{% trans "Release" %}</th><th>{% trans "Documentation" %}</th><th>{% trans "Graph" %}</th>
Copied: branches/djamnedlies/templates/teams/team_list.html (from r1122, /branches/djamnedlies/templates/team_list.html)
==============================================================================
--- /branches/djamnedlies/templates/team_list.html (original)
+++ branches/djamnedlies/templates/teams/team_list.html Sun Nov 2 20:48:28 2008
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% load i18n %}
-{% block title %} {% trans "GNOME Translation Teams" %} {% endblock %}
+{% block title %}{% trans "GNOME Translation Teams" %}{% endblock %}
{% block content %}
<div class="mainpage">
@@ -14,12 +14,17 @@
<ul class="foot">
{% for team in teams %}
<li style="font-size: 120%;">
- <a href="{% url stats.views.team team.name %}">{{ team.translated_name }}</a>
+ <a href="{{ team.get_absolute_url }}">{{ team.translated_name }}</a>
{% if team.webpage_url %}
— <a href="{{ team.webpage_url }}">{{ team.webpage_url }}</a>
{% endif %}
- {% if team.coordinator_url %}
- <br /><span style="font-size: 80%;">{% blocktrans with team.coordinator_url|safe as url %}Coordinated by {{ url }}{% endblocktrans %}</span>
+ {% 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>
{% endif %}
</li>
{% endfor %}
Modified: branches/djamnedlies/urls.py
==============================================================================
--- branches/djamnedlies/urls.py (original)
+++ branches/djamnedlies/urls.py Sun Nov 2 20:48:28 2008
@@ -4,10 +4,26 @@
admin.autodiscover()
+# To try to respect http://www.w3.org/Provider/Style/URI
+# The following URL must be added:
+
+# - /people/ -> all
+# - /people/<id>
+
+# - /languages/ -> all
+# - /languages/<name> (not sure, redirects on team)
+# - /languages/<langcode>/<release_id>/
+
+# - /module/ -> all
+# - /module/<name>
+# - /releases/ -> all
+# - /releases/<id>
+
urlpatterns = patterns('',
- url(r'^$', 'stats.views.index', name='home'),
- (r'^admin/(.*)', admin.site.root),
+ url(r'^$', 'common.views.index', name='home'),
+ (r'^teams/', include('teams.urls')),
(r'^stats/', include('stats.urls')),
+ (r'^admin/(.*)', admin.site.root),
)
if settings.STATIC_SERVE:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]