damned-lies r1069 - in branches/djamnedlies: . vertimus vertimus/templates



Author: stephaner
Date: Tue Oct 21 22:45:22 2008
New Revision: 1069
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1069&view=rev

Log:
2008-10-22  StÃphane Raimbault  <stephane raimbault gmail com>

	Initial and rough commit of Vertimus features.


Added:
   branches/djamnedlies/ChangeLog
   branches/djamnedlies/vertimus/
   branches/djamnedlies/vertimus/__init__.py
   branches/djamnedlies/vertimus/models.py
   branches/djamnedlies/vertimus/templates/
   branches/djamnedlies/vertimus/views.py
   branches/djamnedlies/vertimus/workflow_state.py
Modified:
   branches/djamnedlies/settings.py

Modified: branches/djamnedlies/settings.py
==============================================================================
--- branches/djamnedlies/settings.py	(original)
+++ branches/djamnedlies/settings.py	Tue Oct 21 22:45:22 2008
@@ -71,6 +71,7 @@
 
 TEMPLATE_DIRS = (
     os.path.join(PROJECT_PATH, 'stats', 'templates'),
+    os.path.join(PROJECT_PATH, 'vertimus', 'templates'),
 )
 
 INSTALLED_APPS = (
@@ -80,4 +81,5 @@
     'django.contrib.sites',
     'django.contrib.admin',
     'stats',
+    'vertimus'
 )

Added: branches/djamnedlies/vertimus/__init__.py
==============================================================================

Added: branches/djamnedlies/vertimus/models.py
==============================================================================
--- (empty file)
+++ branches/djamnedlies/vertimus/models.py	Tue Oct 21 22:45:22 2008
@@ -0,0 +1,140 @@
+# -*- coding: utf-8 -*-
+#
+# 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.db import models
+from django.utils.translation import ugettext_lazy as _
+from django.contrib.auth.models import User
+from stats.models import Person, Branch, Domain, Language
+from workflow_state import *
+
+ACTION_CODES = (
+    'WC', 
+    'RT', 'UT',
+    'RP', 'UP', 
+    'TC', 'RC', 
+    'IC', 'TR',
+    'BA', 'UNDO')
+
+class WorkflowAction(models.Model):
+    """Abstract class"""
+    person = models.ForeignKey(Person)
+    branch = models.ForeignKey(Branch)
+    domain = models.ForeignKey(Domain)
+    language = models.ForeignKey(Language)
+    code = models.CharField(max_length=8)
+    created = models.DateField(auto_now_add=True, editable=False)
+    comment = models.TextField(null=True)
+    # FIXME filename in child or here
+
+    class Meta:
+        abstract = True
+        get_latest_by = 'created'
+
+    def get_all(self):
+        actions = []
+        for code in ACTION_CODES:
+            actions.append(eval('WorkflowAction' + code + '()'))
+
+    # FIXME Apply parent/child call
+    def apply(self, person, branch, domain, language, comment=None):
+        self.person = person
+        self.branch = branch
+        self.domain = domain
+        self.language = language
+        self.comment = comment
+        self.save()
+
+        return self._apply_child()
+
+    def __unicode__(self):
+        return self.name
+
+
+class WorkflowActionWC(WorkflowAction):
+    class Meta:
+        db_table = 'workflow_action_wc'
+
+    def __init__(self):
+        models.Model.__init__(self, *args, **kwargs)
+        self.code = 'RT'
+        self.name = 'Write a comment'
+        
+    def _new_state(self):
+        return None
+
+    def _apply_child(self):
+        return self._new_state()
+
+
+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')
+    >>> p.save()
+    >>> r = Release(name='gnome-2-24', stringfrozen=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.save()
+    >>> d = Domain(module=m, name='ihm', dtype='ui', directory='dir')
+    >>> d.save()
+    >>> t = Team(lang_code='fr', description='GNOME French Team', coordinator=p)
+    >>> t.save()
+    >>> l = Language(name='french', locale='fr', team=t)
+    >>> l.save()
+    >>> ma = WorkflowActionRT()
+    >>> ma.name
+    'Reserve for translation'
+    >>> ms_next = ma.apply(p, b, d, l, 'Hi')
+    >>> ms_next.get_code()
+    'Translating'
+    """
+    class Meta:
+        db_table = 'workflow_action_rc'
+
+    def __init__(self, *args, **kwargs):
+        models.Model.__init__(self, *args, **kwargs)
+        self.code = 'RT'
+        self.name = 'Reserve for translation'
+        
+    def _new_state(self):
+        return WorkflowStateTranslating()
+
+    def _apply_child(self):
+        return self._new_state()
+
+
+class WorkflowActionUT(WorkflowAction):
+    class Meta:
+        db_table = 'workflow_action_ut'
+
+    def __init__(self):
+        models.Model.__init__(self, *args, **kwargs)
+        self.code = 'UT'
+        self.name = 'Upload the new translation'
+        
+    def _new_state(self):
+        return WorkflowStateTranslated()
+
+    def _apply_child(self):
+        return self._new_state()

Added: branches/djamnedlies/vertimus/views.py
==============================================================================
--- (empty file)
+++ branches/djamnedlies/vertimus/views.py	Tue Oct 21 22:45:22 2008
@@ -0,0 +1 @@
+# Create your views here.

Added: branches/djamnedlies/vertimus/workflow_state.py
==============================================================================
--- (empty file)
+++ branches/djamnedlies/vertimus/workflow_state.py	Tue Oct 21 22:45:22 2008
@@ -0,0 +1,148 @@
+# -*- coding: utf-8 -*-
+#
+# 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
+
+class WorkflowState(object):
+    """Abstract class"""
+    def __init__(self, code, name):
+        self.code = code
+        self.name = name
+        self.color = ''
+
+    def common_get_actions(self, action_codes=[]):
+        action_codes.append('WC')
+        return [ eval('WorkflowAction' + action_code)() for action_code in action_codes]
+
+    def __unicode__(self):
+        return self.name
+
+    def get_code(self):
+        return self.code
+
+class WorkflowStateNone(WorkflowState):
+    def __init__(self):
+        super(WorkflowStateNone, self).__init__('None', 'Inactive')
+
+    def get_actions(self, module, user):
+        return self.common_get_actions(['RT'])
+
+
+class WorkflowStateCommitted(WorkflowState):
+    def __init__(self):
+        super(WorkflowStateCommitted, self).__init__('Committed', 'Committed')
+
+    def get_actions(self, module, user):
+        return self.common_get_actions()
+
+
+class WorkflowStateCommitting(WorkflowState):
+    def __init__(self):
+        super(WorkflowStateCommitting, self).__init__('Committing', 'Committing')
+        
+    def get_actions(self, module, user):
+        action_codes = []
+
+        if user.is_commiter:
+            # FIXME Not imple
+            last_user = module.get_last_user()
+            # if (type(last_user) is User):
+            if (True):
+                if (user.id == last_user.id):
+                    action_codes = ['IC', 'TR', 'TC', 'UNDO']
+            
+        return self.common_get_actions(action_codes)
+
+
+class WorkflowStateProofread(WorkflowState):
+    def __init__(self):
+        super(WorkflowStateProofread, self).__init__('Proofread', 'Proofread')
+
+    def get_actions(self, module, user):
+        if user.is_reviewer:
+            action_codes = ['TC', 'TR']
+        else:
+            action_codes = []
+
+
+class WorkflowStateProofreading(WorkflowState):
+    def __init__(self):
+        super(WorkflowStateProofreading, self).__init__('Proofreading', 'Proofreading')
+
+    def get_actions(self, module, user):
+        action_codes = []
+        
+        if user.is_commiter:
+            # FIXME Not implemented
+            last_user = module.get_last_user()
+            if type(last_user) is User:
+                if user.id == last_user.id:
+                    action_codes = ['UP', 'TR', 'TC', 'UNDO']
+                    
+        return self.common_get_actions(action_codes)
+
+
+class WorkflowStateToCommit(WorkflowState):
+    def __init__(self):
+        super(WorkflowStateToCommit, self).__init__('ToCommit', 'To Commit')
+
+    def get_actions(self, module, user):
+        if user.is_commiter:
+            action_codes = ['RC', 'TR']
+        else:
+            action_codes = []
+            
+        return self.common_get_actions(action_codes)
+
+
+class WorkflowStateToReview(WorkflowState):
+    def __init__(self):
+        super(WorkflowStateToReview, self).__init__('ToReview', 'To Review')
+        self.color = 'needswork';
+
+    def get_actions(self, module, user):
+        return self.common_get_actions(['RT'])
+
+
+class WorkflowStateTranslated(WorkflowState):
+    def __init__(self):
+        super(WorkflowStateTranslated, self).__init__('Translated', 'Translated')
+
+    def get_actions(self, module, user):
+        if user.is_reviewer:
+            action_codes = ['RP']
+        else:
+            action_codes = []
+
+        action_codes.append('RT')
+        return self.common_get_actions(action_codes)
+
+
+class WorkflowStateTranslating(WorkflowState):
+    def __init__(self):
+        super(WorkflowStateTranslating, self).__init__('Translating', 'Translating')
+
+    def get_actions(self, module, user):
+        action_codes = []
+        last_user = module.get_last_user()
+        if type(last_user) is User:
+            if user.id == last_user.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]