[damned-lies] Refs #268 - Allow direct submission of translation or review



commit 91d3f84fd11084632e2db4ab677428b442c4307e
Author: Claude Paroz <claude 2xlibre net>
Date:   Tue Nov 9 16:41:00 2021 +0100

    Refs #268 - Allow direct submission of translation or review

 vertimus/models.py      |  3 ++-
 vertimus/tests/tests.py | 27 +++++++++++++++++++++++----
 2 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/vertimus/models.py b/vertimus/models.py
index a6b0ea3f..1681aa5a 100644
--- a/vertimus/models.py
+++ b/vertimus/models.py
@@ -147,7 +147,7 @@ class StateNone(State):
             (self.language.team and person.is_translator(self.language.team))
             or person.is_maintainer_of(self.branch.module)
         ):
-            action_names = ['RT']
+            action_names = ['RT', 'UT']
 
         return self._get_available_actions(person, action_names)
 
@@ -180,6 +180,7 @@ class StateTranslated(State):
 
         if person.is_reviewer(self.language.team):
             action_names.append('RP')
+            action_names.append('UP')
             action_names.append('TR')
 
         if person.is_translator(self.language.team):
diff --git a/vertimus/tests/tests.py b/vertimus/tests/tests.py
index 455ee58b..bb250791 100644
--- a/vertimus/tests/tests.py
+++ b/vertimus/tests/tests.py
@@ -91,11 +91,11 @@ class VertimusTest(TeamsAndRolesMixin, TestCase):
 
         for p in (self.pt, self.pr):
             action_names = [a.name for a in state.get_available_actions(p)]
-            self.assertEqual(action_names, ['RT', 'WC'])
+            self.assertEqual(action_names, ['RT', 'UT', 'WC'])
 
         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', None, 'IC', 'AA'])
+            self.assertEqual(action_names, ['RT', 'UT', 'WC', None, 'IC', 'AA'])
 
     def test_state_translating(self):
         state = StateTranslating(branch=self.b, domain=self.d, language=self.language, person=self.pt)
@@ -124,11 +124,11 @@ class VertimusTest(TeamsAndRolesMixin, TestCase):
         self.assertEqual(action_names, ['RT', 'WC'])
 
         action_names = [a.name for a in state.get_available_actions(self.pr)]
-        self.assertEqual(action_names, ['RP', 'TR', 'RT', 'WC'])
+        self.assertEqual(action_names, ['RP', 'UP', 'TR', 'RT', 'WC'])
 
         for p in (self.pc, self.pcoo):
             action_names = [a.name for a in state.get_available_actions(p)]
-            self.assertEqual(action_names, ['RP', 'TR', 'RT', 'TC', 'WC', None, 'IC', 'AA'])
+            self.assertEqual(action_names, ['RP', 'UP', 'TR', 'RT', 'TC', 'WC', None, 'IC', 'AA'])
 
     def test_state_proofreading(self):
         state = StateProofreading(branch=self.b, domain=self.d, language=self.language, person=self.pr)
@@ -231,6 +231,7 @@ class VertimusTest(TeamsAndRolesMixin, TestCase):
             str(form['action']),
             '<select id="id_action" name="action">'
             '<option value="RT">Reserve for translation</option>'
+            '<option value="UT">Upload the new translation</option>'
             '<option value="WC">Write a comment</option>'
             '</select>'
         )
@@ -239,6 +240,7 @@ class VertimusTest(TeamsAndRolesMixin, TestCase):
             str(form['action']),
             '<select id="id_action" name="action">'
             '<option value="RT">Reserve for translation</option>'
+            '<option value="UT">Upload the new translation</option>'
             '<option value="WC">Write a comment</option>'
             '<option value="" disabled>--------</option>'
             '<option value="IC">Inform of submission</option>'
@@ -325,6 +327,23 @@ class VertimusTest(TeamsAndRolesMixin, TestCase):
         role = Role.objects.get(person=self.pt, team=self.language.team)
         self.assertTrue(role.is_active)
 
+    @test_scratchdir
+    def test_action_ut_already_reserved(self):
+        """
+        If someone reserved the module for translation, upload a translation from another person is not 
possible.
+        """
+        state = StateTranslating(branch=self.b, domain=self.d, language=self.language, person=self.pt)
+        state.save()
+
+        file_path = Path(__file__).parent / "valid_po.po"
+        with file_path.open() as test_file:
+            action = Action.new_by_name('UT', person=self.pr, file=File(test_file))
+            with self.assertRaisesRegex(Exception, "Action not allowed"):
+                action.apply_on(
+                    state,
+                    {'send_to_ml': False, 'comment': "Done by reviewer."}
+                )
+
     def test_action_rp(self):
         state = StateTranslated(branch=self.b, domain=self.d, language=self.language)
         state.save()


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