damned-lies r1352 - in trunk: . vertimus vertimus/tests



Author: stephaner
Date: Thu Jan 15 23:01:45 2009
New Revision: 1352
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1352&view=rev

Log:
2009-01-15  StÃphane Raimbault  <stephane raimbault gmail com>

	* vertimus/models.py: A backup is done after each commit, fixes
	#567251. Fixes the sequence number in the action_backup table.
	* vertimus/tests/__init__.py: Test adjustments to reflect the
	change.	


Modified:
   trunk/ChangeLog
   trunk/vertimus/models.py
   trunk/vertimus/tests/__init__.py

Modified: trunk/vertimus/models.py
==============================================================================
--- trunk/vertimus/models.py	(original)
+++ trunk/vertimus/models.py	Thu Jan 15 23:01:45 2009
@@ -110,6 +110,14 @@
                 # Only the name and the person change
                 new_state._state_db.name = new_state.name
                 new_state._state_db.person = person
+
+                if isinstance(new_state, StateCommitted):
+                    # Committed is the last state of the workflow 
+                    new_state.save()
+
+                    # Backup actions
+                    return new_state.apply_action(ActionBA(), person)
+
                 return new_state
             else:
                 return self
@@ -236,7 +244,8 @@
     def get_available_actions(self, person):
         if person.is_committer(self.language.team):
             action_names = ['BA']
-        else:            action_names = []
+        else:            
+            action_names = []
 
         return self._get_available_actions(action_names)
 
@@ -380,6 +389,7 @@
             mail.send_mail(subject, message, settings.SERVER_EMAIL, recipient_list)
             activate(current_lang)
 
+
 class ActionWC(ActionAbstract):
     name = 'WC'
     description = _('Write a comment')
@@ -581,12 +591,14 @@
                 file=file_to_backup)
             if file_to_backup:
                 action_db_backup.file.save(action_db.file.name, file_to_backup, save=False)
-            action_db_backup.save()
 
             if sequence == None:
-                sequence = action_db_backup.id
-                action_db_backup.sequence = sequence
+                # The ID is available after the save()
                 action_db_backup.save()
+                sequence = action_db_backup.id
+
+            action_db_backup.sequence = sequence
+            action_db_backup.save()
 
             action_db.delete() # The file is also automatically deleted, if it is not referenced elsewhere           
 

Modified: trunk/vertimus/tests/__init__.py
==============================================================================
--- trunk/vertimus/tests/__init__.py	(original)
+++ trunk/vertimus/tests/__init__.py	Thu Jan 15 23:01:45 2009
@@ -304,22 +304,6 @@
         new_state.save()
 
     def test_action_ic(self):
-        state = StateDb(branch=self.b, domain=self.d, language=self.l, name='Committing', person=self.pc).get_state()
-        state.save()
-
-        action = ActionAbstract.new_by_name('IC')
-        new_state = state.apply_action(action, self.pc, "Committed.")
-        new_state.save()
-
-    def test_action_tr(self):
-        state = StateDb(branch=self.b, domain=self.d, language=self.l, name='Translated').get_state()
-        state.save()
-
-        action = ActionAbstract.new_by_name('TR')
-        new_state = state.apply_action(action, self.pc, "Bad work :-/")
-        new_state.save()
-
-    def test_action_ba(self):
         state = StateDb(branch=self.b, domain=self.d, language=self.l, name='Proofreading', person=self.pr).get_state()
         state.save()
 
@@ -346,10 +330,6 @@
         state = state.apply_action(action, self.pc, "Committed.")
         state.save()
 
-        action = ActionAbstract.new_by_name('BA')
-        state = state.apply_action(action, self.pc, comment="I don't want to disappear")
-        state.save()
-
         self.assert_(not os.access(file_path, os.F_OK))
         
         # Remove test file
@@ -358,6 +338,22 @@
         backup_action.delete()
         self.assert_(not os.access(backup_file_path, os.F_OK))
 
+    def test_action_tr(self):
+        state = StateDb(branch=self.b, domain=self.d, language=self.l, name='Translated').get_state()
+        state.save()
+
+        action = ActionAbstract.new_by_name('TR')
+        new_state = state.apply_action(action, self.pc, "Bad work :-/")
+        new_state.save()
+
+    def test_action_ba(self):
+        state = StateDb(branch=self.b, domain=self.d, language=self.l, name='Committed', person=self.pr).get_state()
+        state.save()
+
+        action = ActionAbstract.new_by_name('BA')
+        state = state.apply_action(action, self.pc, comment="I don't want to disappear")
+        state.save()
+
     def test_action_undo(self):
         state = StateDb(branch=self.b, domain=self.d, language=self.l, name='None').get_state()
         state.save()



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