[damned-lies] Display hide/show modules in translator profile (refs #674607)



commit 555072fb5a6964ca79a1238a34bb538636597009
Author: Claude Paroz <claude 2xlibre net>
Date:   Tue Oct 9 16:54:03 2012 +0200

    Display hide/show modules in translator profile (refs #674607)

 common/static/css/template.css                  |    2 +-
 common/static/js/main.js                        |    4 ++--
 people/views.py                                 |    2 +-
 templates/languages/language_all_modules.html   |   16 +++++++++-------
 templates/languages/language_release.html       |   16 +++++++++-------
 templates/languages/language_release_stats.html |    6 +-----
 templates/people/person_detail.html             |   18 ++++++++++++++----
 vertimus/models.py                              |    5 ++++-
 8 files changed, 41 insertions(+), 28 deletions(-)
---
diff --git a/common/static/css/template.css b/common/static/css/template.css
index 3729486..0383896 100644
--- a/common/static/css/template.css
+++ b/common/static/css/template.css
@@ -827,7 +827,7 @@ img.screenshot {
 	border: 0;
 }
 
-p#show, p#hide {
+div#hide-show {
 	text-align: right;
 	float:right;
 }
diff --git a/common/static/js/main.js b/common/static/js/main.js
index d44e1ad..5902b9e 100644
--- a/common/static/js/main.js
+++ b/common/static/js/main.js
@@ -2,10 +2,10 @@
 // This function shows or hides all modules in a release that are
 // 100% translated
 // ***
-function showHideCompleted() {
+function showHideCompleted(target) {
     var regex = /complete$/i;
 
-    var tbls = document.getElementsByName("stats-table");
+    var tbls = document.getElementsByName(target);
     for (var tb=0; tb < tbls.length; tb++) {
         var translations = tbls[tb].getElementsByTagName("tr");
 
diff --git a/people/views.py b/people/views.py
index e3fce1d..d53f4e7 100644
--- a/people/views.py
+++ b/people/views.py
@@ -61,7 +61,7 @@ class PersonDetailView(DetailView):
             'pageSection': "teams",
             'all_languages': all_languages,
             'on_own_page': self.request.user.is_authenticated() and self.object.username == self.request.user.username,
-            'states': states,
+            'states': [(s, s.stats) for s in states],
         })
         return context
 
diff --git a/templates/languages/language_all_modules.html b/templates/languages/language_all_modules.html
index 136de6a..dcbd5ef 100644
--- a/templates/languages/language_all_modules.html
+++ b/templates/languages/language_all_modules.html
@@ -22,13 +22,15 @@ $(document).ready(function()
 
 <h2>{% trans "All modules" %} - <a href="{{ language.get_team_url }}">{{ language.get_name }}</a></h2>
 
-<p id="hide">
-   <a href="#" onclick="return showHideCompleted();">{% trans "Hide completed modules" %}</a>
-</p>
-
-<p id="show" style="display:none">
-   <a href="#" onclick="return showHideCompleted();">{% trans "Show completed modules" %}</a>
-</p>
+<div id="hide-show">
+  <p id="hide">
+   <a href="#" onclick="return showHideCompleted('stats-table');">{% trans "Hide completed modules" %}</a>
+  </p>
+
+  <p id="show" style="display:none">
+   <a href="#" onclick="return showHideCompleted('stats-table');">{% trans "Show completed modules" %}</a>
+  </p>
+</div>
 
 <h3>{{ stats_title }}</h3>
 {% with stats as modstats %}
diff --git a/templates/languages/language_release.html b/templates/languages/language_release.html
index 2691ba9..f2ddf9a 100644
--- a/templates/languages/language_release.html
+++ b/templates/languages/language_release.html
@@ -26,13 +26,15 @@ $(document).ready(function()
 <p><i>{% trans "The modules of this release are not part of the GNOME Git repository. Please check each module's web page to see where to send translations." %}</i></p>
 {% endif %}
 
-<p id="hide">
-   <a href="#" onclick="return showHideCompleted();">{% trans "Hide completed modules" %}</a>
-</p>
-
-<p id="show" style="display:none">
-   <a href="#" onclick="return showHideCompleted();">{% trans "Show completed modules" %}</a>
-</p>
+<div id="hide-show">
+  <p id="hide">
+   <a href="#" onclick="return showHideCompleted('stats-table');">{% trans "Hide completed modules" %}</a>
+  </p>
+
+  <p id="show" style="display:none">
+   <a href="#" onclick="return showHideCompleted('stats-table');">{% trans "Show completed modules" %}</a>
+  </p>
+</div>
 
 <h3>{{ stats_title }}</h3>
 {% with stats as modstats %}
diff --git a/templates/languages/language_release_stats.html b/templates/languages/language_release_stats.html
index e03e0d2..bc210e3 100644
--- a/templates/languages/language_release_stats.html
+++ b/templates/languages/language_release_stats.html
@@ -43,11 +43,7 @@
      {% for dom in doms %}
       {% with dom.0 as domname and dom.1 as stat %}
       {% if stat and not stat.is_fake %}
-        {% if stat.tr_percentage == 100 %}
-          <tr id="{{ modname }}-{{ stat.domain.id }}-complete">
-        {% else %}
-          <tr>
-        {% endif %}
+        <tr id="{{ modname }}-{{ stat.domain.id }}{% if stat.tr_percentage == 100 %}-complete{% endif %}">
         <td class="leftcell">
           {% if language %}
           <a href="{% url 'vertimus_by_names' modname branch stat.domain.name language.locale %}">{{ stat.module_description }}
diff --git a/templates/people/person_detail.html b/templates/people/person_detail.html
index c90f5af..1d7a56f 100644
--- a/templates/people/person_detail.html
+++ b/templates/people/person_detail.html
@@ -48,18 +48,28 @@ $(document).ready(function()
 {% include "people/person_team_membership.html" %}
 
 {% if states %}
+<div id="hide-show">
+  <p id="hide">
+   <a href="#" onclick="return showHideCompleted('working_on');">{% trans "Hide completed modules" %}</a>
+  </p>
+
+  <p id="show" style="display:none">
+   <a href="#" onclick="return showHideCompleted('working_on');">{% trans "Show completed modules" %}</a>
+ </p>
+</div>
+
 <h2>{% trans "Current activity" %}</h2>
 
-<table class="stats" id="working_on">
+<table class="stats" id="working_on" name="working_on">
 <thead><tr>
   <th>{% trans "Date" %}</th><th>{% trans "Module" %}</th><th></th><th>{% trans "State" %}</th>
 </tr></thead>
 <tbody>
-{% for state in states %}
-<tr>
+{% for state, stats in states %}
+<tr id="{{ state.id }}{% if stats.tr_percentage == 100 %}-complete{% endif %}">
   <td><span style="display: none;">{{ state.updated|date:"c" }}</span>{{ state.updated|naturalday:"DATE_FORMAT" }}</td>
   <td><a href="{{ state.get_absolute_url }}">{{ state.branch.module.get_description }} - {{ state.branch.name }} - {{ state.domain.get_description }} - {{ state.language.get_name }}</a></td>
-  <td><div class="graph">{{ state.stats|vis_stats }}</div></td>
+  <td><div class="graph">{{ stats|vis_stats }}</div></td>
   <td>{{ state.description }}</td>
 </tr>
 {% endfor %}
diff --git a/vertimus/models.py b/vertimus/models.py
index 57e1d5a..f293692 100644
--- a/vertimus/models.py
+++ b/vertimus/models.py
@@ -85,7 +85,10 @@ class State(models.Model):
 
     @property
     def stats(self):
-        return Statistics.objects.get(branch=self.branch, domain=self.domain, language=self.language)
+        try:
+            return Statistics.objects.get(branch=self.branch, domain=self.domain, language=self.language)
+        except Statistics.DoesNotExist:
+            return None
 
     def change_state(self, state_class, person=None):
         self.name = state_class.name



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