Ejemplo n.º 1
0
    def get_min_date_active(self):
        """Determine the min_date_active to validate against.
        """
        min_date_active = None
        if IAuditable.providedBy(self.context):
            instance = removeSecurityProxy(self.context)
            changes = [ change for change in instance.changes 
                        if change.action == "workflow" ]
            if changes:
 	            # then use the "date_active" of the most recent entry
                min_date_active = changes[-1].date_active
        if not min_date_active: 
            # then fallback to the current parliament's atart_date
            min_date_active = globalsettings.get_current_parliament().start_date
        # As the precision of the UI-submitted datetime is only to the minute, 
        # we adjust min_date_time by a margin of 59 secs earlier to avoid 
        # issues of doing 2 transitions in quick succession (within same minute) 
        # the 2nd of which could be taken to be too old...
        return min_date_active - timedelta(seconds=59)
Ejemplo n.º 2
0
    def get_min_date_active(self):
        """Determine the min_date_active to validate against.
        """
        def is_workflowed_and_draft(instance):
            """is item workflowed, and is so is it in a logical draft state?
            """
            if IWorkflowed.providedBy(instance):
                tagged_key = instance.__class__.__name__.lower()
                draft_states = get_states(tagged_key, tagged=["draft"])
                return instance.status in draft_states
            return False

        min_date_active = None
        if IAuditable.providedBy(self.context):
            instance = removeSecurityProxy(self.context)
            # !+PASTDATAENTRY(mr, jun-2011) offers a way to enter past data
            # for workflowed items via the UI -- note, ideally we should be
            # able to also control the item's creation active_date.
            #
            # If a workflowed item is in draft state, we do NOT take the
            # date_active of its last change as the min_date_active, but
            # let that min fallback to parliament's creation date...
            if not is_workflowed_and_draft(instance):
                changes = [
                    change for change in instance.changes
                    if change.action == "workflow"
                ]
                if changes:
                    # then use the "date_active" of the most recent entry
                    min_date_active = changes[-1].date_active
        if not min_date_active:
            # fallback to current parliament's start_date (cast to a datetime)
            min_date_active = datetime.datetime.combine(
                globalsettings.get_current_parliament().start_date,
                datetime.time())
        # As the precision of the UI-submitted datetime is only to the minute,
        # we adjust min_date_active by a margin of 59 secs earlier to avoid
        # issues of doing 2 transitions in quick succession (within same minute)
        # the 2nd of which could be taken to be too old...
        return min_date_active - datetime.timedelta(seconds=59)
Ejemplo n.º 3
0
 def get_min_date_active(self):
     """Determine the min_date_active to validate against.
     """
     min_date_active = None
     if IAuditable.providedBy(self.context):
         instance = removeSecurityProxy(self.context)
         changes = [
             change for change in instance.changes
             if change.action == "workflow"
         ]
         if changes:
             # then use the "date_active" of the most recent entry
             min_date_active = changes[-1].date_active
     if not min_date_active:
         # then fallback to the current parliament's atart_date
         min_date_active = globalsettings.get_current_parliament(
         ).start_date
     # As the precision of the UI-submitted datetime is only to the minute,
     # we adjust min_date_time by a margin of 59 secs earlier to avoid
     # issues of doing 2 transitions in quick succession (within same minute)
     # the 2nd of which could be taken to be too old...
     return min_date_active - timedelta(seconds=59)
Ejemplo n.º 4
0
 def get_min_date_active(self):
     """Determine the min_date_active to validate against.
     """
     
     def is_workflowed_and_draft(instance):
         """is item workflowed, and if so is it in a logical draft state?
         """
         if interfaces.IWorkflowed.providedBy(instance):
             wf = interfaces.IWorkflow(instance)
             return instance.status in wf.get_state_ids(tagged=["draft"],
                 restrict=False)
         return False
     
     min_date_active = None
     if IFeatureAudit.providedBy(self.context):
         instance = removeSecurityProxy(self.context)
         # !+PASTDATAENTRY(mr, jun-2011) offers a way to enter past data 
         # for workflowed items via the UI -- note, ideally we should be 
         # able to also control the item's creation active_date.
         #
         # If a workflowed item is in draft state, we do NOT take the 
         # date_active of its last change as the min_date_active, but
         # let that min fallback to parliament's creation date...
         if not is_workflowed_and_draft(instance):
             changes = get_changes(instance, "workflow")
             if changes:
  	            # then use the "date_active" of the most recent entry
                 min_date_active = changes[-1].date_active
     if not min_date_active:
         # fallback to current parliament's start_date (cast to a datetime)
         min_date_active = datetime.datetime.combine(
             globalsettings.get_current_parliament().start_date,
             datetime.time())
     # As the precision of the UI-submitted datetime is only to the minute, 
     # we adjust min_date_active by a margin of 59 secs earlier to avoid 
     # issues of doing 2 transitions in quick succession (within same minute) 
     # the 2nd of which could be taken to be too old...
     return min_date_active - datetime.timedelta(seconds=59)
Ejemplo n.º 5
0
 def update(self):
     has_wfstate = False
     try:
         wf_state = interfaces.IWorkflowState(
                             removeSecurityProxy(self.context)).getState()
         has_wfstate = True
     except:
         wf_state = u"undefined"
     if wf_state is None:
         wf_state = u"undefined"
         has_wfstate = False
     self.wf_status = wf_state
     self.has_status = has_wfstate
     self.entries = self.getFeedEntries()
     # min_date_active
     if len(self.entries):
         # then use the "date_active" of the most recent entry
         min_date_active = self.entries[0].date_active
     else:
         # then use the current parliament's atart_date
         min_date_active = globalsettings.get_current_parliament().start_date
     # remember "min_date_active" on the request
     IAnnotations(self.request)["min_date_active"] = min_date_active
Ejemplo n.º 6
0
 def update(self):
     has_wfstate = False
     try:
         wf_state = interfaces.IWorkflowState(
             removeSecurityProxy(self.context)).getState()
         has_wfstate = True
     except:
         wf_state = u"undefined"
     if wf_state is None:
         wf_state = u"undefined"
         has_wfstate = False
     self.wf_status = wf_state
     self.has_status = has_wfstate
     self.entries = self.getFeedEntries()
     # min_date_active
     if len(self.entries):
         # then use the "date_active" of the most recent entry
         min_date_active = self.entries[0]["date_active"]
     else:
         # then use the current parliament's atart_date
         min_date_active = globalsettings.get_current_parliament(
         ).start_date
     # remember "min_date_active" on the request
     IAnnotations(self.request)["min_date_active"] = min_date_active
Ejemplo n.º 7
0
 def get_group(self, name=None):
     assert name is None
     return get_current_parliament()
Ejemplo n.º 8
0
def get_current_parliament(context=None):
    from bungeni.core import globalsettings
    return globalsettings.get_current_parliament()
Ejemplo n.º 9
0
 def get_group(self, name=None):
     assert name is None
     return get_current_parliament()
Ejemplo n.º 10
0
def get_current_parliament(context=None):
    from bungeni.core import globalsettings

    return globalsettings.get_current_parliament()