Пример #1
0
 def __init__(self, context):
     request = check_request()
     terms = []
     versions = IWorkflowVersions(context.__parent__, None)
     if versions is not None:
         # check for first version
         first_version_label = request.localizer.translate(
             VERSION_DISPLAY[DISPLAY_FIRST_VERSION])
         try:
             first_version = versions.get_version(1)  # pylint: disable=assignment-from-no-return
         except VersionError:
             pass
         else:
             info = IWorkflowPublicationInfo(first_version, None)
             if info is not None and info.publication_effective_date:
                 first_version_label = '{1} (= {0})'.format(
                     first_version_label.lower(),
                     format_date(info.publication_effective_date,
                                 format_string=SH_DATE_FORMAT))
         terms.append(
             SimpleTerm(DISPLAY_FIRST_VERSION, title=first_version_label))
     # check for current version
     current_version_label = request.localizer.translate(
         VERSION_DISPLAY[DISPLAY_CURRENT_VERSION])
     info = IWorkflowPublicationInfo(context, None)
     if info is not None and info.publication_effective_date:
         current_version_label = '{1} (= {0})'.format(
             current_version_label.lower(),
             format_date(info.publication_effective_date,
                         format_string=SH_DATE_FORMAT))
     terms.append(
         SimpleTerm(DISPLAY_CURRENT_VERSION, title=current_version_label))
     super().__init__(terms)
Пример #2
0
 def visible_publication_date(self):
     """Visible publication date getter"""
     displayed_date = self.displayed_publication_date
     if displayed_date == DISPLAY_FIRST_VERSION:
         state = IWorkflowState(self.__parent__, None)
         if (state is not None) and (state.version_id > 1):
             versions = IWorkflowVersions(self.__parent__, None)
             if versions is not None:
                 version = versions.get_version(1)  # pylint: disable=assignment-from-no-return
                 return IWorkflowPublicationInfo(
                     version).publication_effective_date
     return self.publication_effective_date