damned-lies r1172 - in trunk: . stats stats/management/commands templates vertimus vertimus/templates



Author: stephaner
Date: Sat Nov 15 23:38:39 2008
New Revision: 1172
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1172&view=rev

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

	* README: Added note about django-evolution.
	* settings_sample.py: Added django-evolution settings and move
	  MANAGERS nearer to ADMINS.
	* stats/admin.py:
	* stats/management/commands/copy-release.py:
	* stats/management/commands/copy-release:
	* stats/models.py: Fixed freezed -> frozen.
	* templates/module.html: Renamed category.category into
	  category.name and stringfrozen into string_frozen	
	* vertimus/models.py: Adjustments.
	* vertimus/workflow_state.py: Fix tests.
	* vertimus/templates: Deleted.


Removed:
   trunk/vertimus/templates/
Modified:
   trunk/ChangeLog
   trunk/README
   trunk/settings_sample.py
   trunk/stats/admin.py
   trunk/stats/management/commands/copy-release.py
   trunk/stats/management/commands/migrate.py
   trunk/stats/models.py
   trunk/templates/module.html
   trunk/vertimus/models.py
   trunk/vertimus/workflow_state.py

Modified: trunk/README
==============================================================================
--- trunk/README	(original)
+++ trunk/README	Sat Nov 15 23:38:39 2008
@@ -11,6 +11,22 @@
 The middle-term objective is to merge this code with the Transifex 
 application (http://transifex.org).
 
+Requirements
+============
+
+1 - Django 1.0.X
+
+2 - [Optional] Django Evolution is an extension to Django that allows
+    you to track changes in your models over time, and to update the
+    database to reflect those changes.
+
+    svn checkout http://django-evolution.googlecode.com/svn/trunk/
+    
+    Define USE_DJANGO_EVOLUTION to True in settings.py to use it.
+
+    Run './manage.py syncdb' before any model changes and './manage.py
+    evolve --hint --execute' after.
+
 Installation
 ============
 
@@ -25,7 +41,6 @@
 4 - Configure Sites in admin interface to define the 'View on site'
     link.
 
-
 Databases
 =========
 

Modified: trunk/settings_sample.py
==============================================================================
--- trunk/settings_sample.py	(original)
+++ trunk/settings_sample.py	Sat Nov 15 23:38:39 2008
@@ -5,6 +5,7 @@
 DEBUG = True
 TEMPLATE_DEBUG = DEBUG
 STATIC_SERVE = True
+USE_DJANGO_EVOLUTION = False
 
 PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
 
@@ -13,11 +14,11 @@
     ('Stephane Raimbault', 'stephane raimbault gmail com'),
 )
 
+MANAGERS = ADMINS
+
 SERVER_EMAIL = 'gnomeweb gnome org'
 EMAIL_SUBJECT_PREFIX = '[Damned Lies] '
 
-MANAGERS = ADMINS
-
 DATABASE_ENGINE = 'sqlite3'           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
 DATABASE_NAME = os.path.join(PROJECT_PATH,'database.db')            # Or path to database file if using sqlite3.
 DATABASE_USER = ''             # Not used with sqlite3.
@@ -102,3 +103,7 @@
     'teams',
     'vertimus'
 )
+
+if USE_DJANGO_EVOLUTION:
+    INSTALLED_APPS = list(INSTALLED_APPS)
+    INSTALLED_APPS += ['django_evolution']

Modified: trunk/stats/admin.py
==============================================================================
--- trunk/stats/admin.py	(original)
+++ trunk/stats/admin.py	Sat Nov 15 23:38:39 2008
@@ -66,10 +66,10 @@
     extra = 1
 
 class CategoryAdmin(admin.ModelAdmin):
-    search_fields = ('category', 'branch__module__name')
+    search_fields = ('name', 'branch__module__name')
 
 class ReleaseAdmin(admin.ModelAdmin):
-    list_display = ('name', 'status', 'stringfrozen')
+    list_display = ('name', 'status', 'string_frozen')
     inlines = [ CategoryInline ]
 
 class InformationInline(admin.TabularInline):

Modified: trunk/stats/management/commands/copy-release.py
==============================================================================
--- trunk/stats/management/commands/copy-release.py	(original)
+++ trunk/stats/management/commands/copy-release.py	Sat Nov 15 23:38:39 2008
@@ -36,7 +36,7 @@
         except:
             raise CommandError("No release named '%s'" % args[0])
         
-        new_rel = Release(name=args[1], description=args[1], stringfrozen=False, status=rel_to_copy.status)
+        new_rel = Release(name=args[1], description=args[1], string_frozen=False, status=rel_to_copy.status)
         new_rel.save()
         
         for cat in rel_to_copy.category_set.all():
@@ -45,7 +45,7 @@
                 branch = mod.get_head_branch()
             else:
                 branch = cat.branch
-            new_rel.category_set.add(Category(release=new_rel, branch=branch, category=cat.category))
+            new_rel.category_set.add(Category(release=new_rel, branch=branch, name=cat.name))
         
         print "New release '%s' created" % args[1]
 

Modified: trunk/stats/management/commands/migrate.py
==============================================================================
--- trunk/stats/management/commands/migrate.py	(original)
+++ trunk/stats/management/commands/migrate.py	Sat Nov 15 23:38:39 2008
@@ -151,7 +151,7 @@
             try:
                 new_r = Release.objects.get(name=release['_description'])
             except:
-                new_r = Release(name=release['_description'], stringfrozen=False, status=release['status'])
+                new_r = Release(name=release['_description'], string_frozen=False, status=release['status'])
                 new_r.save()
             if release.has_key('category'):
                 for catname, catcontent in release['category'].items():
@@ -167,7 +167,7 @@
                                 branch_name = u'HEAD'
                         try:
                             branch = Branch.objects.get(module__name=mod, name=branch_name)
-                            cat = Category(release=new_r, branch=branch, category=catcontent['_description'])
+                            cat = Category(release=new_r, branch=branch, name=catcontent['_description'])
                             cat.save()
                         except:
                             print "Unable to find branch '%s' of module '%s' for release '%s'" % (branch_name, mod, release['_description'])
@@ -183,7 +183,7 @@
                             branch_name = u'HEAD'
                     try:
                         branch = Branch.objects.get(module__name=mod, name=branch_name)
-                        cat = Category(release=new_r, branch=branch, category='default')
+                        cat = Category(release=new_r, branch=branch, name='default')
                         cat.save()
                     except:
                         print "Unable to find branch '%s' of module '%s' for release '%s'" % (branch_name, mod, release['_description'])

Modified: trunk/stats/models.py
==============================================================================
--- trunk/stats/models.py	(original)
+++ trunk/stats/models.py	Sat Nov 15 23:38:39 2008
@@ -132,10 +132,10 @@
             return True
         return False
 
-    def has_string_freezed(self):
-        """ Returns true if the branch is contained in at least one stringfreezed release """
+    def has_string_frozen(self):
+        """ Returns true if the branch is contained in at least one string frozen release """
         for rel in self.releases.all():
-            if rel.stringfrozen:
+            if rel.string_frozen:
                 return True
         return False
            
@@ -206,7 +206,7 @@
         """ Update statistics for all po files from the branch """
         self.checkout()
         domains = Domain.objects.filter(module=self.module)
-        string_freezed = self.has_string_freezed()
+        string_frozen = self.has_string_frozen()
         for dom in domains.all():
             # 1. Initial settings
             # *******************
@@ -248,7 +248,7 @@
 
             # If old pot already exists and we are in string freeze
             if os.access(previous_pot, os.R_OK):
-                if string_freezed and dom.dtype == 'ui':
+                if string_frozen and dom.dtype == 'ui':
                     diff = potdiff.diff(previous_pot, potfile, 1)
                     if len(diff):
                         utils.notify_list("%s.%s" % (self.module.name, self.name), diff)
@@ -517,7 +517,7 @@
 class Release(models.Model):
     name = models.SlugField(max_length=20)
     description = models.CharField(max_length=50)
-    stringfrozen = models.BooleanField(default=False)
+    string_frozen = models.BooleanField(default=False)
     status = models.CharField(max_length=12, choices=RELEASE_STATUS_CHOICES)
     branches = models.ManyToManyField(Branch, through='Category', related_name='releases')
 
@@ -680,7 +680,7 @@
                 }
         for stat in pot_stats:
             dtype = stat.domain.dtype
-            categdescr = stat.branch.category_set.get(release=self).category
+            categdescr = stat.branch.category_set.get(release=self).name
             domname = _(stat.domain.description)
             modname = stat.domain.module.name
             if not stats[dtype]['categs'].has_key(categdescr):
@@ -705,7 +705,7 @@
         tr_stats = Statistics.objects.filter(language=lang, branch__releases=self).order_by('domain__module__id')
         for stat in tr_stats:
             dtype = stat.domain.dtype
-            categdescr = stat.branch.category_set.get(release=self).category
+            categdescr = stat.branch.category_set.get(release=self).name
             domname = _(stat.domain.description)
             modname = stat.domain.module.name
             stats[dtype]['totaltrans'] += stat.translated
@@ -780,14 +780,14 @@
 class Category(models.Model):
     release = models.ForeignKey(Release)
     branch = models.ForeignKey(Branch)
-    category = models.CharField(max_length=30, choices=CATEGORY_CHOICES, default='default')
+    name = models.CharField(max_length=30, choices=CATEGORY_CHOICES, default='default')
 
     class Meta:
         db_table = 'category'
         verbose_name_plural = 'categories'
 
     def __unicode__(self):
-        return "%s (%s, %s)" % (self.get_category_display(), self.release, self.branch)
+        return "%s (%s, %s)" % (self.get_name_display(), self.release, self.branch)
     
     @classmethod
     def get_cat_name(cls, key):

Modified: trunk/templates/module.html
==============================================================================
--- trunk/templates/module.html	(original)
+++ trunk/templates/module.html	Sat Nov 15 23:38:39 2008
@@ -66,7 +66,7 @@
       (<a href="{{ branch.get_vcs_web_url }}">{% trans "Browse SVN" %}</a>)
     {% endifequal %}
     </h2>
-    {% if branch.release_cat.release.stringfrozen %}
+    {% if branch.release_cat.release.string_frozen %}
       <p>{% trans "This branch is currently string-frozen." %}</p>
     {% endif %}
 

Modified: trunk/vertimus/models.py
==============================================================================
--- trunk/vertimus/models.py	(original)
+++ trunk/vertimus/models.py	Sat Nov 15 23:38:39 2008
@@ -28,8 +28,8 @@
 ACTION_CODES = (
     'WC', 
     'RT', 'UT',
-    'RP', 'UP', 
-    'TC', 'RC', 
+    'RP', 'UP',
+    'TC', 'RC',
     'IC', 'TR',
     'BA', 'UNDO')
 
@@ -46,6 +46,7 @@
 
     class Meta:
         abstract = True
+        ordering = ('created',)
         get_latest_by = 'created'
 
     def get_all(self):
@@ -86,17 +87,20 @@
 
 class WorkflowActionRT(WorkflowAction):
     """
-    >>> from stats.models import Person, Release, Category, Module, Branch, Domain, Team, Language
-    >>> p = Person(_old_id=1, name=u'GÃrard Martin', email='gm mail com')
+    >>> from people.models import Person
+    >>> from teams.models import Team
+    >>> from languages.models import Language
+    >>> from stats.models import Release, Category, Module, Branch, Domain
+    >>> p = Person(name=u'GÃrard Martin', email='gm mail com')
     >>> p.save()
-    >>> r = Release(name='gnome-2-24', stringfrozen=True, status='official')
+    >>> r = Release(name='gnome-2-24', string_frozen=True, status='official')
     >>> r.save()
-    >>> c = Category(release=r, description='desktop')
-    >>> c.save()
     >>> m = Module(name='gedit', bugs_base='nd', bugs_product='d', bugs_component='d', vcs_type='svn', vcs_root='d', vcs_web='d')
     >>> m.save()
-    >>> b = Branch(name='trunk', module=m, category=c)
+    >>> b = Branch(name='trunk', module=m)
     >>> b.save()
+    >>> c = Category(release=r, branch=b, name='desktop')
+    >>> c.save()
     >>> d = Domain(module=m, name='ihm', dtype='ui', directory='dir')
     >>> d.save()
     >>> t = Team(name='fr', description='GNOME French Team', coordinator=p)

Modified: trunk/vertimus/workflow_state.py
==============================================================================
--- trunk/vertimus/workflow_state.py	(original)
+++ trunk/vertimus/workflow_state.py	Sat Nov 15 23:38:39 2008
@@ -35,6 +35,7 @@
     def get_code(self):
         return self.code
 
+
 class WorkflowStateNone(WorkflowState):
     def __init__(self):
         super(WorkflowStateNone, self).__init__('None', 'Inactive')
@@ -55,15 +56,15 @@
     def __init__(self):
         super(WorkflowStateCommitting, self).__init__('Committing', 'Committing')
         
-    def get_actions(self, module, user):
+    def get_actions(self, module, person):
         action_codes = []
 
-        if user.is_commiter:
+        if person.is_commiter:
             # FIXME Not imple
-            last_user = module.get_last_user()
-            # if (type(last_user) is User):
+            last_person = module.get_last_person()
+            # if (type(last_person) is Person):
             if (True):
-                if (user.id == last_user.id):
+                if (person.id == last_person.id):
                     action_codes = ['IC', 'TR', 'TC', 'UNDO']
             
         return self.common_get_actions(action_codes)
@@ -73,8 +74,8 @@
     def __init__(self):
         super(WorkflowStateProofread, self).__init__('Proofread', 'Proofread')
 
-    def get_actions(self, module, user):
-        if user.is_reviewer:
+    def get_actions(self, module, person):
+        if person.is_reviewer:
             action_codes = ['TC', 'TR']
         else:
             action_codes = []
@@ -84,14 +85,14 @@
     def __init__(self):
         super(WorkflowStateProofreading, self).__init__('Proofreading', 'Proofreading')
 
-    def get_actions(self, module, user):
+    def get_actions(self, module, person):
         action_codes = []
         
-        if user.is_commiter:
+        if person.is_commiter:
             # FIXME Not implemented
-            last_user = module.get_last_user()
-            if type(last_user) is User:
-                if user.id == last_user.id:
+            last_person = module.get_last_person()
+            if type(last_person) is Person:
+                if person.id == last_person.id:
                     action_codes = ['UP', 'TR', 'TC', 'UNDO']
                     
         return self.common_get_actions(action_codes)
@@ -101,8 +102,8 @@
     def __init__(self):
         super(WorkflowStateToCommit, self).__init__('ToCommit', 'To Commit')
 
-    def get_actions(self, module, user):
-        if user.is_commiter:
+    def get_actions(self, module, person):
+        if person.is_commiter:
             action_codes = ['RC', 'TR']
         else:
             action_codes = []
@@ -115,7 +116,7 @@
         super(WorkflowStateToReview, self).__init__('ToReview', 'To Review')
         self.color = 'needswork';
 
-    def get_actions(self, module, user):
+    def get_actions(self, module, person):
         return self.common_get_actions(['RT'])
 
 
@@ -123,8 +124,8 @@
     def __init__(self):
         super(WorkflowStateTranslated, self).__init__('Translated', 'Translated')
 
-    def get_actions(self, module, user):
-        if user.is_reviewer:
+    def get_actions(self, module, person):
+        if person.is_reviewer:
             action_codes = ['RP']
         else:
             action_codes = []
@@ -137,11 +138,11 @@
     def __init__(self):
         super(WorkflowStateTranslating, self).__init__('Translating', 'Translating')
 
-    def get_actions(self, module, user):
+    def get_actions(self, module, person):
         action_codes = []
-        last_user = module.get_last_user()
-        if type(last_user) is User:
-            if user.id == last_user.id:
+        last_person = module.get_last_person()
+        if type(last_person) is Person:
+            if person.id == last_person.id:
                 action_codes = ['UT', 'UNDO']
                     
         return self.common_get_actions(action_codes)



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