damned-lies r1526 - in trunk: . stats/management/commands vertimus vertimus/tests



Author: claudep
Date: Sat Apr  4 19:37:08 2009
New Revision: 1526
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1526&view=rev

Log:
2009-04-04  Claude Paroz  <claude 2xlibre net>

	* stats/management/commands/update-stats.py: Fix variable name.
	* vertimus/forms.py: Add custom widget to enable the separator in
	dropdowns.
	* vertimus/models.py: Add backup action to most states. Add a new
	fake separator action to add separators in dropdown action list.
	* vertimus/tests/__init__.py: Adapted to new action list.
	Fixes bugs #568773, #571826, #569864.

Modified:
   trunk/ChangeLog
   trunk/stats/management/commands/update-stats.py
   trunk/vertimus/forms.py
   trunk/vertimus/models.py
   trunk/vertimus/tests/__init__.py

Modified: trunk/stats/management/commands/update-stats.py
==============================================================================
--- trunk/stats/management/commands/update-stats.py	(original)
+++ trunk/stats/management/commands/update-stats.py	Sat Apr  4 19:37:08 2009
@@ -69,7 +69,7 @@
                             self.get_lock_for_module(mod.name, branch.name)
                             branch.update_stats(options['force'])
                         except:
-                            print "Error while updating stats for %s (branch '%s')" % (module_arg, branch.name)
+                            print "Error while updating stats for %s (branch '%s')" % (mod.name, branch.name)
                         finally:
                             self.release_lock_for_module(mod.name, branch.name)
         else:

Modified: trunk/vertimus/forms.py
==============================================================================
--- trunk/vertimus/forms.py	(original)
+++ trunk/vertimus/forms.py	Sat Apr  4 19:37:08 2009
@@ -26,10 +26,19 @@
 from vertimus.models import ActionAbstract
 from stats.utils import po_file_stats
 
+class ActionWidget(forms.Select):
+    """ Custom widget to disable the separator option (containing "--------") """ 
+    def render_options(self, choices, selected_choices):
+        options = super(ActionWidget, self).render_options(choices, selected_choices)
+        options = options.replace("<option value=\"None\">--------</option>",
+                                  "<option disabled='disabled'>--------</option>")
+        return options
+
 class ActionForm(forms.Form):
     action = forms.ChoiceField(label=_("Action"),
 #        help_text="Choose an action you want to apply",
-        choices=())
+        choices=(),
+        widget=ActionWidget)
     comment = forms.CharField(label=_("Comment"),
 #        help_text="Leave a comment to explain your action",
         max_length=1000,

Modified: trunk/vertimus/models.py
==============================================================================
--- trunk/vertimus/models.py	(original)
+++ trunk/vertimus/models.py	Sat Apr  4 19:37:08 2009
@@ -102,7 +102,9 @@
     def _get_available_actions(self, person, action_names):
         action_names.append('WC')
         if person.is_committer(self.language.team) and 'IC' not in action_names:
-            action_names.append('IC')
+            action_names.extend(('Separator', 'IC'))
+            if self.name not in ('None', 'Committed'):
+                action_names.append('BA')
         return [eval('Action' + action_name)() for action_name in action_names]
 
     def apply_action(self, action, person, comment=None, file=None):
@@ -747,6 +749,11 @@
                 return action._new_state()
         return StateNone()
 
+class ActionSeparator(object):
+    """ Fake action to add a separator in action menu """
+    name = None
+    description = "--------"
+    
 def update_uploaded_files(sender, **kwargs):
     """Callback to handle pot_file_changed signal"""
     actions = ActionDb.objects.filter(state_db__branch=kwargs['branch'],

Modified: trunk/vertimus/tests/__init__.py
==============================================================================
--- trunk/vertimus/tests/__init__.py	(original)
+++ trunk/vertimus/tests/__init__.py	Sat Apr  4 19:37:08 2009
@@ -131,7 +131,7 @@
 
         for p in (self.pc, self.pcoo):
             action_names = [a.name for a in state.get_available_actions(p)]
-            self.assertEqual(action_names, ['RT', 'WC', 'IC'])
+            self.assertEqual(action_names, ['RT', 'WC', None, 'IC'])
         
     def test_state_translating(self):
         sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pt)
@@ -145,7 +145,7 @@
         
         for p in (self.pc, self.pcoo):
             action_names = [a.name for a in state.get_available_actions(p)]
-            self.assertEqual(action_names, ['WC', 'IC'])
+            self.assertEqual(action_names, ['WC', None, 'IC', 'BA'])
 
         # Same person
         action_names = [a.name for a in state.get_available_actions(self.pt)]
@@ -168,7 +168,7 @@
 
         for p in (self.pc, self.pcoo):
             action_names = [a.name for a in state.get_available_actions(p)]
-            self.assertEqual(action_names, ['RP', 'RT', 'TR', 'WC', 'IC'])
+            self.assertEqual(action_names, ['RP', 'RT', 'TR', 'WC', None, 'IC', 'BA'])
 
     def test_state_proofreading(self):
         sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pr)
@@ -182,7 +182,7 @@
 
         for p in (self.pc, self.pcoo):
             action_names = [a.name for a in state.get_available_actions(p)]
-            self.assertEqual(action_names, ['WC', 'IC'])
+            self.assertEqual(action_names, ['WC', None, 'IC', 'BA'])
 
         # Same person and reviewer
         action_names = [a.name for a in state.get_available_actions(self.pr)]
@@ -203,7 +203,7 @@
 
         for p in (self.pc, self.pcoo):
             action_names = [a.name for a in state.get_available_actions(p)]
-            self.assertEqual(action_names, ['TC', 'RP', 'TR', 'WC', 'IC'])
+            self.assertEqual(action_names, ['TC', 'RP', 'TR', 'WC', None, 'IC', 'BA'])
 
     def test_state_to_review(self):
         sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pt)
@@ -220,7 +220,7 @@
 
         for p in (self.pc, self.pcoo):
             action_names = [a.name for a in state.get_available_actions(p)]
-            self.assertEqual(action_names, ['RT', 'WC', 'IC'])
+            self.assertEqual(action_names, ['RT', 'WC', None, 'IC', 'BA'])
 
     def test_state_to_commit(self):
         sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pr)
@@ -234,7 +234,7 @@
 
         for p in (self.pc, self.pcoo):
             action_names = [a.name for a in state.get_available_actions(p)]
-            self.assertEqual(action_names, ['RC', 'TR', 'WC', 'IC'])
+            self.assertEqual(action_names, ['RC', 'TR', 'WC', None, 'IC', 'BA'])
 
     def test_state_committing(self):
         sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pc)
@@ -247,7 +247,7 @@
             self.assertEqual(action_names, ['WC'])
 
         action_names = [a.name for a in state.get_available_actions(self.pcoo)]
-        self.assertEqual(action_names, ['WC', 'IC'])
+        self.assertEqual(action_names, ['WC', None, 'IC', 'BA'])
 
         action_names = [a.name for a in state.get_available_actions(self.pc)]
         self.assertEqual(action_names, ['IC', 'TR', 'UNDO', 'WC'])
@@ -264,7 +264,7 @@
 
         for p in (self.pc, self.pcoo):
             action_names = [a.name for a in state.get_available_actions(p)]
-            self.assertEqual(action_names, ['BA', 'WC', 'IC'])
+            self.assertEqual(action_names, ['BA', 'WC', None, 'IC'])
 
     def test_action_wc(self):
         state = StateDb(branch=self.b, domain=self.d, language=self.l, name='None').get_state()



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