← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~lgp171188/launchpad:bugtask-changes-model into launchpad:master

 

Guruprasad has proposed merging ~lgp171188/launchpad:bugtask-changes-model into launchpad:master.

Commit message:
Add status_explanation, importance_explanation to BugTask

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~lgp171188/launchpad/+git/launchpad/+merge/417846
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~lgp171188/launchpad:bugtask-changes-model into launchpad:master.
diff --git a/lib/lp/bugs/configure.zcml b/lib/lp/bugs/configure.zcml
index 3064699..f98a666 100644
--- a/lib/lp/bugs/configure.zcml
+++ b/lib/lp/bugs/configure.zcml
@@ -213,7 +213,9 @@
                     milestone
                     _status
                     status
+                    status_explanation
                     importance
+                    importance_explanation
                     assignee
                     bugwatch
                     age
@@ -261,6 +263,7 @@
                     bugwatch
                     datecreated
                     importance
+                    importance_explanation
                     milestone
                     owner
                     related_tasks
@@ -268,6 +271,7 @@
                     setStatusFromDebbugs
                     statusdisplayhtml
                     statuselsewhere
+                    status_explanation
                     targetname
                     title
                     "/>
diff --git a/lib/lp/bugs/interfaces/bugtask.py b/lib/lp/bugs/interfaces/bugtask.py
index 5d22a40..c09c13c 100644
--- a/lib/lp/bugs/interfaces/bugtask.py
+++ b/lib/lp/bugs/interfaces/bugtask.py
@@ -435,9 +435,33 @@ class IBugTask(IHasBug, IBugTaskDelete):
         Choice(title=_('Status'), vocabulary=BugTaskStatus,
                default=BugTaskStatus.NEW, readonly=True))
     _status = Attribute('The actual status DB column used in queries.')
+    status_explanation = exported(
+        Text(
+            title=_("Status Explanation"),
+            description=_(
+                "The explanation for the current status of this bugtask."
+            ),
+            readonly=True,
+            required=False,
+        ),
+        as_of="devel"
+    )
+
     importance = exported(
         Choice(title=_('Importance'), vocabulary=BugTaskImportance,
                default=BugTaskImportance.UNDECIDED, readonly=True))
+    importance_explanation = exported(
+        Text(
+            title=_("Importance explanation"),
+            description=_(
+                "The explanation for the current importance of this bugtask."
+            ),
+            readonly=True,
+            required=False,
+        ),
+        as_of="devel"
+    )
+
     assignee = exported(
         PersonChoice(
             title=_('Assigned to'), required=False,
diff --git a/lib/lp/bugs/model/bugtask.py b/lib/lp/bugs/model/bugtask.py
index 086299f..9aa974c 100644
--- a/lib/lp/bugs/model/bugtask.py
+++ b/lib/lp/bugs/model/bugtask.py
@@ -470,12 +470,17 @@ class BugTask(StormBase):
         enum=(BugTaskStatus, BugTaskStatusSearch),
         default=BugTaskStatus.NEW,
         validator=validate_status)
+
+    status_explanation = Unicode(allow_none=True, default=None)
+
     importance = DBEnum(
         name='importance', allow_none=False,
         enum=BugTaskImportance,
         default=BugTaskImportance.UNDECIDED,
         validator=validate_conjoined_attribute)
 
+    importance_explanation = Unicode(allow_none=True, default=None)
+
     assignee_id = Int(
         name="assignee", allow_none=True, validator=validate_assignee)
     assignee = Reference(assignee_id, "Person.id")
diff --git a/lib/lp/bugs/model/tests/test_bugtask.py b/lib/lp/bugs/model/tests/test_bugtask.py
index 4089d86..41320b9 100644
--- a/lib/lp/bugs/model/tests/test_bugtask.py
+++ b/lib/lp/bugs/model/tests/test_bugtask.py
@@ -428,7 +428,7 @@ class TestBugTaskTargetName(TestCase):
         self.assertEqual(bugtask.bugtargetname, 'firefox')
 
 
-class TestEditingBugTask(TestCase):
+class TestEditingBugTask(TestCaseWithFactory):
     """Verify out editing functionality of bugtasks."""
 
     layer = DatabaseFunctionalLayer
@@ -485,6 +485,55 @@ class TestEditingBugTask(TestCase):
         distro_task.transitionToAssignee(sample_person)
 
 
+    def test_bugtask_edit_status_explanation(self):
+        bugtaskset = getUtility(IBugTaskSet)
+        bug_one = getUtility(IBugSet).get(1)
+        mark = getUtility(IPersonSet).getByEmail("mark@xxxxxxxxxxx")
+        product = self.factory.makeProduct()
+
+        bugtask = bugtaskset.createTask(
+            bug_one, mark, product,
+            status=BugTaskStatus.NEW,
+            importance=BugTaskImportance.MEDIUM)
+
+        self.assertIsNone(bugtask.status_explanation)
+
+        login(ANONYMOUS)
+
+        # Anonymous cannot set the value for 'status_explanation'.
+        with ExpectedException(ZopeUnAuthorized, ''):
+            bugtask.status_explanation = "Foo bar"
+
+        login("mark@xxxxxxxxxxx")
+        bugtask.status_explanation = "Foo bar"
+
+        self.assertEqual("Foo bar", bugtask.status_explanation)
+
+    def test_bugtask_edit_importance_explanation(self):
+        bugtaskset = getUtility(IBugTaskSet)
+        bug_one = getUtility(IBugSet).get(1)
+        mark = getUtility(IPersonSet).getByEmail("mark@xxxxxxxxxxx")
+        product = self.factory.makeProduct()
+
+        bugtask = bugtaskset.createTask(
+            bug_one, mark, product,
+            status=BugTaskStatus.NEW,
+            importance=BugTaskImportance.MEDIUM)
+
+        self.assertIsNone(bugtask.importance_explanation)
+
+        login(ANONYMOUS)
+
+        # Anonymous cannot set the value for 'importance_explanation'.
+        with ExpectedException(ZopeUnAuthorized, ''):
+            bugtask.importance_explanation = "Foo bar"
+
+        login("mark@xxxxxxxxxxx")
+        bugtask.importance_explanation = "Foo bar baz"
+
+        self.assertEqual("Foo bar baz", bugtask.importance_explanation)
+
+
 class TestBugTaskTags(TestCase):
     """List of bugtasks often need to display related tasks."""
 

References