def ulocalized_time(self, time, context, request): val = ut(time, long_format=self._properties['show_time'], time_only=False, context=context, request=request) return val
def ulocalized_time(self, time, context, request): """Returns the localized time in string format """ value = ut(time, long_format=self.show_time, time_only=False, context=context, request=request) return value or ""
def get(self, instance): """This getter contains a simple lookup table; The most recent review_history entry's 'time' value will be used, where state_title == workflow_state_id """ field_state_lookup = { 'DateApproved': 'approved', 'DateReceived': 'received', 'DateAccepted': 'accepted', 'DateReleased': 'released', 'DatePrepared': 'prepared', 'DateTested': 'tested', 'DatePassedQA': 'passed_qa', 'DatePublished': 'published', 'DateCancelled': 'cancelled', } workflow = getToolByName(instance, 'portal_workflow') try: review_history = list( workflow.getInfoFor(instance, 'review_history')) except WorkflowException: # Maybe there is no review_history at some states. If it doesn't # exist, we can't care about it. review_history = [] # invert the list, so we always see the most recent matching event review_history.reverse() try: state_id = field_state_lookup[self.getName()] except: raise RuntimeError( "field %s.%s not in field_state_lookup" % instance, self.getName()) for event in review_history: if event['review_state'] == state_id: value = ut(event['time'], long_format=True, time_only=False, context=instance) return value return None
def get(self, instance): """This getter contains a simple lookup table; The most recent review_history entry's 'time' value will be used, where state_title == workflow_state_id """ field_state_lookup = { 'DateApproved': 'approved', 'DateReceived': 'received', 'DateAccepted': 'accepted', 'DateReleased': 'released', 'DatePrepared': 'prepared', 'DateTested': 'tested', 'DatePassedQA': 'passed_qa', 'DatePublished': 'published', 'DateCancelled': 'cancelled', } workflow = getToolByName(instance, 'portal_workflow') try: review_history = list(workflow.getInfoFor(instance, 'review_history')) except WorkflowException: # Maybe there is no review_history at some states. If it doesn't # exist, we can't care about it. review_history = [] # invert the list, so we always see the most recent matching event review_history.reverse() try: state_id = field_state_lookup[self.getName()] except: raise RuntimeError("field %s.%s not in field_state_lookup" % instance, self.getName()) for event in review_history: if event['review_state'] == state_id: value = ut(event['time'], long_format=True, time_only=False, context=instance) return value return None
def get(self, instance): """This getter returns a multiline string, each line contains: <Analysis Request> <Analysis Service> <actor> <time> """ workflow = getToolByName(instance, 'portal_workflow') result = [] for ar in instance.getAnalysisRequests(): for analysis in ar.getAnalyses(full_objects=True): review_history = list( workflow.getInfoFor(analysis, 'review_history')) review_history.reverse() for event in review_history: if event['review_state'] == "retracted": result.append( "%-20s %-20s %-10s %s" % (ar.getId(), analysis.getId(), '' if event['actor'] is None else event['actor'], ut(event['time'], long_format=True, time_only=False, context=instance))) return result
def get(self, instance): """This getter returns a multiline string, each line contains: <Analysis Request> <Analysis Service> <actor> <time> """ workflow = getToolByName(instance, 'portal_workflow') result = [] for ar in instance.getAnalysisRequests(): for analysis in ar.getAnalyses(full_objects=True): review_history = list(workflow.getInfoFor(analysis, 'review_history')) review_history.reverse() for event in review_history: if event['review_state'] == "retracted": result.append("%-20s %-20s %-10s %s" % ( ar.getId(), analysis.getId(), '' if event['actor'] is None else event['actor'], ut(event['time'], long_format=True, time_only=False, context=instance) )) return result