示例#1
0
 def renderCell(self, item):
     res = u'-'
     value = self.getValue(item)
     if not value or value == 'None' or value == self.ignored_value:
         item_obj = item.getObject()
         if item_obj.portal_type == 'operationalobjective':
             value = find_max_deadline_on_children(item_obj, {"pstaction": "planned_end_date",
                                                              "pstsubaction": "planned_end_date",
                                                              "subaction_link": "planned_end_date",
                                                              "task": "due_date"})
         elif item_obj.portal_type == 'pstaction':
             value = find_max_deadline_on_children(item_obj, {"pstsubaction": "planned_end_date",
                                                              "subaction_link": "planned_end_date",
                                                              "task": "due_date"})
         elif item_obj.portal_type == 'pstsubaction':
             value = find_max_deadline_on_children(item_obj, {"task": "due_date"})
     if value:
         if isinstance(value, DateTime):
             value = value.asdatetime().date()
         res = api.portal.get_localized_time(datetime=value, long_format=self.long_format, time_only=self.time_only)
         if self.use_caching:
             cached_result = self._get_cached_result(value)
             if cached_result:
                 res = cached_result
             else:
                 self._store_cached_result(value, res)
     return res
示例#2
0
 def test_find_max_deadline_on_operational_objective_children(self):
     """
     Test find_max_deadline_on_operational_objective_children method on operational objective.
     children deadlines :
     (a_16, 30/06/2024)
         (sa_17, 30/06/2020)
             (t1, 30/04/2020)
             (t2, 31/03/2020)
         (sa_18, 31/10/2020)
         (sa_19, 31/10/2020)
     (a_20, 30/06/2024)
         (sal_17, 30/06/2020)
             (t1, 30/04/2020)
             (t2, 31/03/2020)
         (sal_18, 31/10/2020)
         (sal_19, 31/10/2020)
     """
     self.assertEqual(
         find_max_deadline_on_children(
             self.oo_15, {
                 "pstaction": "planned_end_date",
                 "pstsubaction": "planned_end_date",
                 "subaction_link": "planned_end_date",
                 "task": "due_date"
             }), datetime.date(datetime(2024, 6, 30)))
示例#3
0
 def get(self):
     value = super(PSTSubActionDataManager, self).get()
     if self.field.__name__ == "planned_end_date":
         value = self.context.planned_end_date
         if not value:
             value = find_max_deadline_on_children(self.context, {"task": "due_date"})
     return value
示例#4
0
 def test_find_max_deadline_on_pst_sub_action_children(self):
     """
     Test find_max_deadline_on_pst_sub_action_children method on pst sub action.
     (t1, 30/04/2020)
     (t2, 31/03/2020)
     """
     self.assertEqual(
         find_max_deadline_on_children(self.sa_17, {"task": "due_date"}),
         datetime.date(datetime(2020, 4, 30)))
示例#5
0
 def get(self):
     value = super(OperationalObjectiveDataManager, self).get()
     if self.field.__name__ == "planned_end_date":
         value = self.context.planned_end_date
         if not value:
             value = find_max_deadline_on_children(
                 self.context, {
                     "pstaction": "planned_end_date",
                     "pstsubaction": "planned_end_date",
                     "subaction_link": "planned_end_date",
                     "task": "due_date"
                 })
     return value
示例#6
0
 def test_find_max_deadline_on_pst_action_children(self):
     """
     Test find_max_deadline_on_pst_action_children method on pst action.
     children deadlines :
     (sa_17, 30/06/2020)
         (t1, 30/04/2020)
         (t2, 31/03/2020)
     (sa_18, 31/10/2020)
     (sa_19, 31/10/2020)
     """
     self.assertEqual(
         find_max_deadline_on_children(
             self.a_16, {
                 "pstsubaction": "planned_end_date",
                 "subaction_link": "planned_end_date",
                 "task": "due_date"
             }), datetime.date(datetime(2020, 10, 31)))
示例#7
0
 def getAllMessages(self):
     ret = []
     if self.context.portal_type == "operationalobjective":
         if self.context.planned_end_date:
             max_children_deadline = find_max_deadline_on_children(
                 self.context, {
                     "pstaction": "planned_end_date",
                     "action_link": "planned_end_date",
                     "pstsubaction": "planned_end_date",
                     "subaction_link": "planned_end_date",
                     "task": "due_date"
                 })
             if max_children_deadline:
                 if max_children_deadline > self.context.planned_end_date:
                     msg = _(
                         u"The deadline of any one of children is greater than those of this element"
                     )
                     ret.append(
                         PseudoMessage(
                             msg_type="significant",
                             text=richtextval(msg),
                             hidden_uid=generate_uid(),
                             can_hide=False,
                         ))
         else:
             msg = _(
                 u"The deadline is not fill on this element, the system displays the largest of its "
                 u"possible children")
             ret.append(
                 PseudoMessage(
                     msg_type="significant",
                     text=richtextval(msg),
                     hidden_uid=generate_uid(),
                     can_hide=False,
                 ))
     if self.context.portal_type == "pstaction":
         if self.context.planned_end_date:
             max_children_deadline = find_max_deadline_on_children(
                 self.context, {
                     "pstsubaction": "planned_end_date",
                     "subaction_link": "planned_end_date",
                     "task": "due_date"
                 })
             if max_children_deadline:
                 if max_children_deadline > self.context.planned_end_date:
                     msg = _(
                         u"The deadline of any one of children is greater than those of this element"
                     )
                     ret.append(
                         PseudoMessage(
                             msg_type="significant",
                             text=richtextval(msg),
                             hidden_uid=generate_uid(),
                             can_hide=False,
                         ))
             if is_smaller_deadline_on_parents(
                     self.context, {
                         "pstaction": "planned_end_date",
                         "operationalobjective": "planned_end_date"
                     }):
                 msg = _(
                     u"The deadline of this element is greater than one of its parents"
                 )
                 ret.append(
                     PseudoMessage(
                         msg_type="significant",
                         text=richtextval(msg),
                         hidden_uid=generate_uid(),
                         can_hide=False,
                     ))
         else:
             msg = _(
                 u"The deadline is not fill on this element, the system displays the largest of its "
                 u"possible children")
             ret.append(
                 PseudoMessage(
                     msg_type="significant",
                     text=richtextval(msg),
                     hidden_uid=generate_uid(),
                     can_hide=False,
                 ))
     if self.context.portal_type == "pstsubaction":
         if self.context.planned_end_date:
             max_children_deadline = find_max_deadline_on_children(
                 self.context, {
                     "pstsubaction": "planned_end_date",
                     "subaction_link": "planned_end_date",
                     "task": "due_date"
                 })
             if max_children_deadline:
                 if max_children_deadline > self.context.planned_end_date:
                     msg = _(
                         u"The deadline of any one of children is greater than those of this element"
                     )
                     ret.append(
                         PseudoMessage(
                             msg_type="significant",
                             text=richtextval(msg),
                             hidden_uid=generate_uid(),
                             can_hide=False,
                         ))
             if is_smaller_deadline_on_parents(
                     self.context, {
                         "pstsubaction": "planned_end_date",
                         "pstaction": "planned_end_date",
                         "operationalobjective": "planned_end_date"
                     }):
                 msg = _(
                     u"The deadline of this element is greater than one of its parents"
                 )
                 ret.append(
                     PseudoMessage(
                         msg_type="significant",
                         text=richtextval(msg),
                         hidden_uid=generate_uid(),
                         can_hide=False,
                     ))
         else:
             msg = _(
                 u"The deadline is not fill on this element, the system displays the largest of its "
                 u"possible children")
             ret.append(
                 PseudoMessage(
                     msg_type="significant",
                     text=richtextval(msg),
                     hidden_uid=generate_uid(),
                     can_hide=False,
                 ))
     if self.context.portal_type == "task":
         if self.context.due_date:
             if is_smaller_deadline_on_parents(
                     self.context, {
                         "task": "due_date",
                         "pstsubaction": "planned_end_date",
                         "pstaction": "planned_end_date",
                         "operationalobjective": "planned_end_date"
                     }):
                 msg = _(
                     u"The deadline of this element is greater than one of its parents"
                 )
                 ret.append(
                     PseudoMessage(
                         msg_type="significant",
                         text=richtextval(msg),
                         hidden_uid=generate_uid(),
                         can_hide=False,
                     ))
         else:
             msg = _(u"The deadline is not fill on this element")
             ret.append(
                 PseudoMessage(
                     msg_type="significant",
                     text=richtextval(msg),
                     hidden_uid=generate_uid(),
                     can_hide=False,
                 ))
     return ret