[damned-lies] Put old releases in hidden Archive section on the Team page (Fixes #573756)
- From: Claude Paroz <claudep src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [damned-lies] Put old releases in hidden Archive section on the Team page (Fixes #573756)
- Date: Sat, 14 Nov 2009 15:35:45 +0000 (UTC)
commit 2ee552b5b40ea9002a80c80056899ca1c9ed1f70
Author: Claude Paroz <claude 2xlibre net>
Date: Sat Nov 14 16:35:28 2009 +0100
Put old releases in hidden Archive section on the Team page (Fixes #573756)
languages/models.py | 7 ++-
languages/urls.py | 4 +
languages/views.py | 13 ++++
stats/templatetags/stats_extras.py | 5 ++
templates/languages/language_release_summary.html | 50 ++++++++++++++
templates/teams/team_detail.html | 74 +++++++++-----------
6 files changed, 110 insertions(+), 43 deletions(-)
---
diff --git a/languages/models.py b/languages/models.py
index 3af9092..ecf60ed 100644
--- a/languages/models.py
+++ b/languages/models.py
@@ -31,12 +31,15 @@ class Language(models.Model):
def bugs_url_show(self):
return "http://bugzilla.gnome.org/buglist.cgi?product=l10n&component=%s%%20[%s]&bug_status=NEW&bug_status=REOPENED&bug_status=ASSIGNED&bug_status=UNCONFIRMED" % (self.name, self.locale)
- def get_release_stats(self):
+ def get_release_stats(self, archives=False):
# FIXME Here be dragons
""" Get summary stats for all releases """
from stats.models import Release
- releases = Release.objects.all().order_by('status', '-name')
+ if archives:
+ releases = Release.objects.all().filter(weight__lt=0).order_by('status', '-weight', '-name')
+ else:
+ releases = Release.objects.all().filter(weight__gte=0).order_by('status', '-weight', '-name')
stats = []
for rel in releases:
stats.append(rel.total_for_lang(self))
diff --git a/languages/urls.py b/languages/urls.py
index 39b836a..ea5f971 100644
--- a/languages/urls.py
+++ b/languages/urls.py
@@ -10,6 +10,10 @@ urlpatterns = patterns('',
view = 'languages.views.language_all',
name = 'language_all'),
url(
+ regex = r'^(?P<locale>[\w\- ]+)/rel-archives/$',
+ view = 'languages.views.release_archives',
+ name = 'language_release_archives'),
+ url(
regex = r'^(?P<locale>[\w\- ]+)/(?P<release_name>[\w-]+)/(?P<dtype>(ui|doc)+)/$',
view = 'languages.views.language_release',
name = 'language_release'),
diff --git a/languages/views.py b/languages/views.py
index 5fd0bc0..dd84db7 100644
--- a/languages/views.py
+++ b/languages/views.py
@@ -54,6 +54,19 @@ def language_all(request, locale, dtype):
return render_to_response('languages/language_all_modules.html', context,
context_instance=RequestContext(request))
+def release_archives(request, locale):
+ """ This view is used to display archive release stats through Ajax call
+ Only the HTML table is produced
+ """
+ language = get_object_or_404(Language, locale=locale)
+ context = {
+ 'lang': language,
+ 'stats': language.get_release_stats(archives=True),
+ 'show_all_modules_line': False,
+ }
+ return render_to_response('languages/language_release_summary.html', context,
+ context_instance=RequestContext(request))
+
def language_release(request, locale, release_name, dtype):
if locale == 'C':
language = None
diff --git a/stats/templatetags/stats_extras.py b/stats/templatetags/stats_extras.py
index 7a9907f..26ab927 100644
--- a/stats/templatetags/stats_extras.py
+++ b/stats/templatetags/stats_extras.py
@@ -18,6 +18,11 @@ def support_class(value):
return "partially"
return "not_supported"
+ register filter
+def escapeat(value):
+ """Replace '@' with '__', accepted sequence in JS ids."""
+ return value.replace('@', '__')
+
class IfLessNode(template.Node):
def __init__(self, val1, val2, nodelist_true, nodelist_false):
self.val1 = val1
diff --git a/templates/languages/language_release_summary.html b/templates/languages/language_release_summary.html
new file mode 100644
index 0000000..014a16e
--- /dev/null
+++ b/templates/languages/language_release_summary.html
@@ -0,0 +1,50 @@
+{% load i18n %}
+{% comment %}
+Following variables should be set:
+ lang : current language
+ stats : release stat list, obtained with get_release_stats
+ show_all_modules_line : boolean
+{% endcomment %}
+<table class="stats">
+ <thead><tr><th>{% trans "Release" %}</th><th>{% trans "User Interface" %}</th><th>{% trans "Graph" %}</th>
+ <th>{% trans "Documentation" %}</th><th>{% trans "Graph" %}</th></tr></thead>
+ {% for stat in stats %}
+ <tr>
+ <td class="leftcell">
+ {{ stat.description }}</a>
+ </td>
+
+ <td><a href="{% url language_release lang.locale,stat.name,"ui" %}">
+ {{ stat.uitransperc }}% ({{ stat.uitrans }}/{{ stat.uifuzzy }}/{{ stat.uiuntrans }})</a>
+ </td>
+ <td style="width: 108px; text-align: center;"><div class="graph">
+ <div class="translated" style="width:{{ stat.uitransperc }}px;"></div>
+ <div class="fuzzy" style="{{ LANGUAGE_BIDI|yesno:"right,left" }}:{{ stat.uitransperc }}px; width:{{ stat.uifuzzyperc }}px;"></div>
+ {% with stat.uitransperc|add:stat.uifuzzyperc as upos %}
+ <div class="untranslated" style="{{ LANGUAGE_BIDI|yesno:"right,left" }}:{{ upos }}px; width:{{ stat.uiuntransperc }}px;"></div>
+ {% endwith %}
+ </div>
+ </td>
+
+ {% if stat.doctotal %}
+ <td><a href="{% url language_release lang.locale,stat.name,"doc" %}">
+ {{ stat.doctransperc }}% ({{ stat.doctrans }}/{{ stat.docfuzzy }}/{{ stat.docuntrans }})</a>
+ </td>
+ <td style="width: 108px; text-align: center;"><div class="graph">
+ <div class="translated" style="width:{{ stat.doctransperc }}px;"></div>
+ <div class="fuzzy" style="{{ LANGUAGE_BIDI|yesno:"right,left" }}:{{ stat.doctransperc }}px; width:{{ stat.docfuzzyperc }}px;"></div>
+ {% with stat.doctransperc|add:stat.docfuzzyperc as upos %}
+ <div class="untranslated" style="{{ LANGUAGE_BIDI|yesno:"right,left" }}:{{ upos }}px; width:{{ stat.docuntransperc }}px;"></div>
+ {% endwith %}
+ </div>
+ </td>
+ {% else %}
+ <td>-</td><td></td>
+ {% endif %}
+ </tr>
+ {% endfor %}
+ {% if show_all_modules_line %}
+ <tr><td></td><td><a href="{% url language_all lang.locale,"ui" %}">{% trans "All modules" %}</a></td>
+ <td></td><td><a href="{% url language_all lang.locale,"doc" %}">{% trans "All modules" %}</a></td><td></td></tr>
+ {% endif %}
+</table>
diff --git a/templates/teams/team_detail.html b/templates/teams/team_detail.html
index c34af40..370f3ba 100644
--- a/templates/teams/team_detail.html
+++ b/templates/teams/team_detail.html
@@ -1,10 +1,35 @@
{% extends "base.html" %}
{% load i18n %}
+{% load stats_extras %}
{% block extrahead %}
<link rel="alternate" type="application/rss+xml"
title="{% blocktrans with team.get_description as lang %}Last actions made by the {{ lang }} team of the GNOME Translation Project{% endblocktrans %}"
href="/rss/teams/{{ team.name }}" />
+
+<script type="text/javascript">
+$(document).ready(function() {
+ $(".archives").click(function(event) {
+ event.preventDefault();
+ arch_div = $("#div-rel-archives-"+this.id);
+ is_visible = arch_div.is(':visible');
+ if (is_visible) {
+ arch_div.hide();
+ $(this).children('img').attr("src", "{{ MEDIA_URL }}img/closed.png");
+ } else {
+ if (arch_div.attr("class") == "empty") {
+ // Load the archive stats dynamically
+ arch_div.load("/languages/"+this.id.replace('__','@')+"/rel-archives/");
+ arch_div.attr("class", "loaded");
+ }
+ arch_div.show();
+ $(this).children('img').attr("src", "{{ MEDIA_URL }}img/open.png");
+ }
+ });
+ }
+);
+</script>
{% endblock %}
+
{% block title %}{{ team.get_description }}{% endblock %}
{% block content %}
@@ -22,49 +47,16 @@
{% for lang in team.get_languages %}
<h2>{{ lang.get_name }} ({{ lang.locale }})</h2>
- <table class="stats">
- <thead><tr><th>{% trans "Release" %}</th><th>{% trans "User Interface" %}</th><th>{% trans "Graph" %}</th>
- <th>{% trans "Documentation" %}</th><th>{% trans "Graph" %}</th></tr></thead>
- {% for stat in lang.get_release_stats %}
- <tr>
- <td class="leftcell">
- {{ stat.description }}</a>
- </td>
-
- <td><a href="{% url language_release lang.locale,stat.name,"ui" %}">
- {{ stat.uitransperc }}% ({{ stat.uitrans }}/{{ stat.uifuzzy }}/{{ stat.uiuntrans }})</a>
- </td>
- <td style="width: 108px; text-align: center;"><div class="graph">
- <div class="translated" style="width:{{ stat.uitransperc }}px;"></div>
- <div class="fuzzy" style="{{ LANGUAGE_BIDI|yesno:"right,left" }}:{{ stat.uitransperc }}px; width:{{ stat.uifuzzyperc }}px;"></div>
- {% with stat.uitransperc|add:stat.uifuzzyperc as upos %}
- <div class="untranslated" style="{{ LANGUAGE_BIDI|yesno:"right,left" }}:{{ upos }}px; width:{{ stat.uiuntransperc }}px;"></div>
- {% endwith %}
- </div>
- </td>
-
- {% if stat.doctotal %}
- <td><a href="{% url language_release lang.locale,stat.name,"doc" %}">
- {{ stat.doctransperc }}% ({{ stat.doctrans }}/{{ stat.docfuzzy }}/{{ stat.docuntrans }})</a>
- </td>
- <td style="width: 108px; text-align: center;"><div class="graph">
- <div class="translated" style="width:{{ stat.doctransperc }}px;"></div>
- <div class="fuzzy" style="{{ LANGUAGE_BIDI|yesno:"right,left" }}:{{ stat.doctransperc }}px; width:{{ stat.docfuzzyperc }}px;"></div>
- {% with stat.doctransperc|add:stat.docfuzzyperc as upos %}
- <div class="untranslated" style="{{ LANGUAGE_BIDI|yesno:"right,left" }}:{{ upos }}px; width:{{ stat.docuntransperc }}px;"></div>
- {% endwith %}
- </div>
- </td>
- {% else %}
- <td>-</td><td></td>
- {% endif %}
- </tr>
- {% endfor %}
- <tr><td></td><td><a href="{% url language_all lang.locale,"ui" %}">{% trans "All modules" %}</a></td>
- <td></td><td><a href="{% url language_all lang.locale,"doc" %}">{% trans "All modules" %}</a></td><td></td></tr>
-</table>
+ {% with 1 as show_all_modules_line %}
+ {% with lang.get_release_stats as stats %}
+ {% include "languages/language_release_summary.html" %}
+ {% endwith %}
+ {% endwith %}
<p><strong>{% trans "Plural forms:" %}</strong> {{ lang.get_plurals }}</p>
+<h3><a href="." class="archives" id="{{ lang.locale|escapeat }}"><img src="{{ MEDIA_URL }}img/closed.png" /></a> Archives</h3>
+<div id="div-rel-archives-{{ lang.locale|escapeat }}" class="empty" style="display:none;"></div>
+
{% endfor %}
{% if not team.fake %}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]