[damned-lies] Fixes related to the new module.archived flag



commit de3a4c0194c1286eb6aff0a817aef75df737787a
Author: Claude Paroz <claude 2xlibre net>
Date:   Fri Jan 11 16:40:32 2013 +0100

    Fixes related to the new module.archived flag

 languages/views.py |   12 ++++++------
 stats/models.py    |    6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/languages/views.py b/languages/views.py
index 1ef8c4e..2cc0977 100644
--- a/languages/views.py
+++ b/languages/views.py
@@ -128,14 +128,14 @@ def language_release_xml(request, locale, release_name):
         content += "<fuzzy>%s</fuzzy>" % categ['catfuzzy']
         content += "<untranslated>%s</untranslated>" % categ['catuntrans']
         # Modules
-        for modname, mod in categ['modules']:
-            branch_name, domains = mod.items()[0]
-            content += "<module id=\"%s\" branch=\"%s\">" % (modname, branch_name)
+        for module, mod_stats in categ['modules'].items():
+            branch_name, domains = mod_stats.items()[0]
+            content += "<module id=\"%s\" branch=\"%s\">" % (module.name, branch_name)
             # DOC domains
             if catname in stats['doc']['categs'] and stats['doc']['categs'][catname]['modules']:
-                for docmod in stats['doc']['categs'][catname]['modules']:
-                    if docmod[0] == modname:
-                        content += get_domain_stats(docmod[1].values()[0], "document")
+                for docmod, data in stats['doc']['categs'][catname]['modules'].items():
+                    if docmod == module:
+                        content += get_domain_stats(data.values()[0], "document")
             # UI stats
             content += get_domain_stats(domains, "domain")
             content += "</module>"
diff --git a/stats/models.py b/stats/models.py
index 9569bcd..e0b51bc 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -196,7 +196,7 @@ class Branch(models.Model):
         unique_together = ('name', 'module')
 
     def __init__(self, *args, **kwargs):
-        models.Model.__init__(self, *args, **kwargs)
+        super(Branch, self).__init__(*args, **kwargs)
         self.checkout_lock = threading.Lock()
         self._ui_stats = None
         self._doc_stats = None
@@ -205,7 +205,7 @@ class Branch(models.Model):
         return "%s (%s)" % (self.name, self.module)
 
     def clean(self):
-        if self.checkout_on_creation:
+        if self.checkout_on_creation and not self.module.archived:
             try:
                 self.checkout()
             except:
@@ -213,7 +213,7 @@ class Branch(models.Model):
 
     def save(self, update_statistics=True, **kwargs):
         super(Branch, self).save(**kwargs)
-        if update_statistics:
+        if update_statistics and not self.module.archived:
             # The update command is launched asynchronously in a separate thread
             upd_thread = threading.Thread(target=self.update_stats, kwargs={'force':True})
             upd_thread.start()



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