Beispiel #1
0
 def get_dossier_lists(self):
     return [
         [_(u'label_resolved_dossiers', default=u'Resolved Dossiers'),
          self.active_dossiers],
         [_(u'label_inactive_dossiers', default=u'Inactive Dossiers'),
          self.inactive_dossiers]
     ]
 def get_dossier_lists(self):
     return [
         [_(u'label_resolved_dossiers', default=u'Resolved Dossiers'),
          self.active_dossiers],
         [_(u'label_inactive_dossiers', default=u'Inactive Dossiers'),
          self.inactive_dossiers]
     ]
 def get_columns(self):
     return [
         Column('date', _('label_time', default=u'Time'), '20%'),
         Column('actor_label', _('label_actor', default=u'Actor'), '40%'),
         Column('transition_label', _('label_action', default=u'Action'),
                '40%')
     ]
    def get_render_arguments(self):
        self.layout.show_contact = False

        dossier_listener = getMultiAdapter((self.context, self.request, self),
                                           ILaTexListing,
                                           name='destroyed_dossiers')

        history_listener = getMultiAdapter((self.context, self.request, self),
                                           ILaTexListing,
                                           name='disposition_history')

        return {
            'label_protocol':
            self.translate(
                _('label_removal_protocol', default="Removal protocol")),
            'title':
            self.context.title,
            'disposition_metadata':
            self.get_disposition_metadata(),
            'label_dossiers':
            translate(_('label_dossiers', default="Dossiers"),
                      context=self.request),
            'dossier_listing':
            dossier_listener.get_listing(
                self.context.get_dossier_representations()),
            'label_history':
            translate(_('label_history', default="History"),
                      context=self.request),
            'history':
            history_listener.get_listing(self.context.get_history())
        }
 def get_columns(self):
     return [
         Column('reference_number',
                _('label_reference_number', default='Reference number'),
                '20%'),
         Column('title', _('label_title', default='Title'), '70%'),
         Column('appraisal', _('label_archived', default='Archived'), '10%',
                self.get_archived_label)
     ]
Beispiel #6
0
    def get_columns(self):
        return [
            Column('date',
                   _('label_time', default=u'Time'),
                   '20%'),

            Column('actor_label',
                   _('label_actor', default=u'Actor'),
                   '40%'),

            Column('transition_label',
                   _('label_action', default=u'Action'),
                   '40%')
        ]
Beispiel #7
0
    def get_columns(self):
        return [
            Column('reference_number',
                   _('label_reference_number', default='Reference number'),
                   '20%'),

            Column('title',
                   _('label_title', default='Title'),
                   '70%'),

            Column('appraisal',
                   _('label_archived', default='Archived'),
                   '10%',
                   self.get_archived_label)
        ]
 def get_attributes(self):
     return [
         {'id': 'reference_number',
          'title': dossier_mf(u'label_reference_number',
                              default=u'Reference Number')},
         {'id': 'title',
          'title': dossier_mf('label_title', default=u'title')},
         {'id': 'start',
          'title': dossier_mf(u'label_start', default=u'Opening Date'),
          'number_format': DATE_NUMBER_FORMAT},
         {'id': 'end',
          'title': dossier_mf(u'label_end', default=u'Closing Date'),
          'number_format': DATE_NUMBER_FORMAT},
         {'id': 'public_trial',
          'title': base_mf(u'label_public_trial', default=u'Public Trial'),
          'transform': StringTranslater(
              self.request, 'opengever.base').translate},
         {'id': 'archival_value',
          'title': base_mf(u'label_archival_value',
                           default=u'Archival value'),
          'transform': StringTranslater(
              self.request, 'opengever.base').translate},
         {'id': 'archival_value_annotation',
          'title': base_mf(u'label_archival_value_annotation',
                           default=u'archivalValueAnnotation'),
          'transform': StringTranslater(
              self.request, 'opengever.base').translate},
         {'id': 'appraisal',
          'title': _(u'label_appraisal', default=u'Appraisal'),
          'transform': readable_appraisal},
     ]
Beispiel #9
0
 def summary(self):
     actor = Actor.lookup(self.context.Creator())
     msg = _('summary_disposition_added',
             u'New disposition added by ${user} on admin unit ${admin_unit}',
             mapping={'user': actor.get_label(with_principal=False),
                      'admin_unit': get_current_admin_unit().label()})
     return self.translate_to_all_languages(msg)
Beispiel #10
0
    def get_disposition_metadata(self):
        rows = []
        config = [
            {'label': _('label_title', default=u'Title'),
             'value': self.context.title},
            {'label': _('label_transfer_number',
                        default=u'Transfer number'),
             'value': self.context.transfer_number if
                 self.context.transfer_number else u''}
        ]

        for row in config:
            label = translate(row.get('label'), context=self.request)
            rows.append(u'\\bf {} & {} \\\\%%'.format(
                self.convert_plain(label), row.get('value')))

        return '\n'.join(rows)
Beispiel #11
0
    def get_disposition_metadata(self):
        rows = []
        config = [
            {'label': _('label_title', default=u'Title'),
             'value': self.context.title},
            {'label': _('label_transfer_number',
                        default=u'Transfer number'),
             'value': self.context.transfer_number if
                 self.context.transfer_number else u''}
        ]

        for row in config:
            label = translate(row.get('label'), context=self.request)
            rows.append(u'\\bf {} & {} \\\\%%'.format(
                self.convert_plain(label), row.get('value')))

        return '\n'.join(rows)
 def get_file_name(self):
     """Returns the filename for the excel spreadsheet.
     """
     normalizer = getUtility(IIDNormalizer)
     name_basis = _(u'appraisal_list', default=u'appraisal_list')
     file_name = "{0}_{1}.xlsx".format(
         translate(name_basis, context=self.request),
         normalizer.normalize(self.context.title_or_id()))
     return file_name
 def get_file_name(self):
     """Returns the filename for the excel spreadsheet.
     """
     normalizer = getUtility(IIDNormalizer)
     name_basis = _(u'appraisal_list', default=u'appraisal_list')
     file_name = "{0}_{1}.xlsx".format(
         translate(name_basis, context=self.request),
         normalizer.normalize(self.context.title_or_id()))
     return file_name
Beispiel #14
0
class IDispositionSchema(form.Schema):

    form.fieldset(
        u'common',
        label=_(u'fieldset_common', default=u'Common'),
        fields=[u'title', u'dossiers', u'transfer_number'],
    )

    dexteritytextindexer.searchable('title')
    title = schema.TextLine(
        title=_(u"label_title", default=u"Title"),
        required=True,
        max_length=256,
        defaultFactory=title_default,
    )

    dossiers = RelationList(
        title=_(u'label_dossiers', default=u'Dossiers'),
        default=[],
        missing_value=[],
        value_type=RelationChoice(
            title=u"Dossier",
            source=ObjPathSourceBinder(
                object_provides=(
                    'opengever.dossier.behaviors.dossier.IDossierMarker'),
                review_state=DOSSIER_STATES_OFFERABLE,
                navigation_tree_query={
                    'object_provides': [
                        'opengever.repository.repositoryroot.IRepositoryRoot',
                        'opengever.repository.interfaces.IRepositoryFolder',
                        'opengever.dossier.behaviors.dossier.IDossierMarker'
                    ],
                }),
        ),
        required=True,
    )

    write_permission(
        transfer_number='opengever.disposition.EditTransferNumber')
    dexteritytextindexer.searchable('transfer_number')
    transfer_number = schema.TextLine(
        title=_(u"label_transfer_number", default=u"Transfer number"),
        required=False,
    )
Beispiel #15
0
class Dispositions(BaseCatalogListingTab):
    grok.name('tabbedview_view-dispositions')

    types = ['opengever.disposition.disposition']
    enabled_actions = []
    major_actions = []

    filterlist_name = 'disposition_state_filter'
    filterlist_available = True
    filterlist = FilterList(
        Filter('filter_all', _('all')),
        CatalogQueryFilter('filter_active',
                           _('active'),
                           default=True,
                           query_extension={'review_state': ACTIVE_STATES}))

    columns = (
        {
            'column': '',
            'column_title': '',
            'transform': path_checkbox,
            'sortable': False,
            'width': 30
        },
        {
            'column':
            'sequence_number',
            'column_title':
            _(u'document_sequence_number', default=u'Sequence Number'),
            'sort_index':
            'sequence_number'
        },
        {
            'column': 'Title',
            'column_title': _(u'label_title', default=u'Title'),
            'sort_index': 'sortable_title',
            'transform': linked
        },
        {
            'column': 'review_state',
            'column_title': _(u'label_review_state', default=u'Review state'),
            'transform': workflow_state
        },
    )
Beispiel #16
0
    def validate(self, value):
        """Validate if the retention period of all selected dossiers is
        expired and the dossiers are not part of another disposition.
        """
        super(OfferedDossiersValidator, self).validate(value)

        for dossier in value:
            if not dossier.is_retention_period_expired():
                raise Invalid(
                    _(u'error_retention_period_not_expired',
                      default=u'The retention period of the selected dossiers'
                      ' is not expired.'))

            if self.is_offered_in_a_different_disposition(dossier):
                raise Invalid(
                    _(u'error_offered_in_a_different_disposition',
                      default=u'The dossier ${title} is already offered in a '
                      'different disposition.',
                      mapping={'title': dossier.title}))
Beispiel #17
0
def title_default():
    """Returns title suggestion in the following format:

    `Disposition {admin unit abbreviation} {localized today's date}`
    """
    return u'{} {} {}'.format(
        translate(_('label_disposition', default=u'Disposition'),
                  context=getRequest()),
        get_current_admin_unit().abbreviation,
        api.portal.get_localized_time(date.today(), long_format=False))
Beispiel #18
0
def title_default():
    """Returns title suggestion in the following format:

    `Disposition {admin unit abbreviation} {localized today's date}`
    """
    return u'{} {} {}'.format(
        translate(_('label_disposition', default=u'Disposition'),
                  context=getRequest()),
        get_current_admin_unit().abbreviation,
        api.portal.get_localized_time(date.today(), long_format=False))
Beispiel #19
0
 def summary(self):
     actor = Actor.lookup(self.context.Creator())
     msg = _(
         'summary_disposition_added',
         u'New disposition added by ${user} on admin unit ${admin_unit}',
         mapping={
             'user': actor.get_label(with_principal=False),
             'admin_unit': get_current_admin_unit().label()
         })
     return self.translate_to_all_languages(msg)
Beispiel #20
0
    def validate(self, value):
        """Validate if the retention period of all selected dossiers is
        expired and the dossiers are not part of another disposition.
        """
        super(OfferedDossiersValidator, self).validate(value)

        for dossier in value:
            if not dossier.is_retention_period_expired():
                raise Invalid(
                    _(u'error_retention_period_not_expired',
                      default=u'The retention period of the selected dossiers'
                      ' is not expired.'))

            if self.is_offered_in_a_different_disposition(dossier):
                raise Invalid(
                    _(u'error_offered_in_a_different_disposition',
                      default=u'The dossier ${title} is already offered in a '
                      'different disposition.',
                      mapping={'title': dossier.title}))
 def get_attributes(self):
     return [
         {
             'id':
             'reference_number',
             'title':
             dossier_mf(u'label_reference_number',
                        default=u'Reference Number')
         },
         {
             'id': 'title',
             'title': dossier_mf('label_title', default=u'title')
         },
         {
             'id': 'start',
             'title': dossier_mf(u'label_start', default=u'Opening Date'),
             'number_format': DATE_NUMBER_FORMAT
         },
         {
             'id': 'end',
             'title': dossier_mf(u'label_end', default=u'Closing Date'),
             'number_format': DATE_NUMBER_FORMAT
         },
         {
             'id':
             'public_trial',
             'title':
             base_mf(u'label_public_trial', default=u'Public Trial'),
             'transform':
             StringTranslater(self.request, 'opengever.base').translate
         },
         {
             'id':
             'archival_value',
             'title':
             base_mf(u'label_archival_value', default=u'Archival value'),
             'transform':
             StringTranslater(self.request, 'opengever.base').translate
         },
         {
             'id':
             'archival_value_annotation',
             'title':
             base_mf(u'label_archival_value_annotation',
                     default=u'archivalValueAnnotation'),
             'transform':
             StringTranslater(self.request, 'opengever.base').translate
         },
         {
             'id': 'appraisal',
             'title': _(u'label_appraisal', default=u'Appraisal'),
             'transform': readable_appraisal
         },
     ]
Beispiel #22
0
    def __call__(self):
        if not self.context.has_sip_package():
            msg = _('msg_no_sip_package_generated',
                    default=u'No SIP Package generated for this disposition.')
            api.portal.show_message(msg, request=self.request, type='error')
            return self.request.RESPONSE.redirect(self.context.absolute_url())

        sip_package = self.context.get_sip_package()
        filename = self.context.get_sip_filename()
        set_headers(sip_package, self.request.response, filename)
        return stream_data(sip_package)
Beispiel #23
0
 def get_actions(self):
     return [
         {'id': 'export_appraisal_list',
          'label': _('label_export_appraisal_list_as_excel',
                     default=u'Export appraisal list as excel'),
          'url': '{}/download_excel'.format(self.context.absolute_url()),
          'visible': True,
          'class': 'appraisal_list'},
         {'id': 'sip_download',
          'label': _('label_dispositon_package_download',
                     default=u'Download disposition package'),
          'url': '{}/ech0160_export'.format(self.context.absolute_url()),
          'visible': self.sip_download_available(),
          'class': 'sip_download'},
         {'id': 'removal_protocol',
          'label': _('label_download_removal_protocol',
                     default=u'Download removal protocol'),
          'url': '{}/removal_protocol'.format(self.context.absolute_url()),
          'visible': self.removal_protocol_available(),
          'class': 'removal_protocol'}
     ]
Beispiel #24
0
 def get_actions(self):
     return [
         {'id': 'export_appraisal_list',
          'label': _('label_export_appraisal_list_as_excel',
                     default=u'Export appraisal list as excel'),
          'url': '{}/download_excel'.format(self.context.absolute_url()),
          'visible': True,
          'class': 'appraisal_list'},
         {'id': 'sip_download',
          'label': _('label_dispositon_package_download',
                     default=u'Download disposition package'),
          'url': '{}/ech0160_export'.format(self.context.absolute_url()),
          'visible': self.sip_download_available(),
          'class': 'sip_download'},
         {'id': 'removal_protocol',
          'label': _('label_download_removal_protocol',
                     default=u'Download removal protocol'),
          'url': '{}/removal_protocol'.format(self.context.absolute_url()),
          'visible': self.removal_protocol_available(),
          'class': 'removal_protocol'}
     ]
Beispiel #25
0
    def __call__(self):
        if not IAppraisal(self.context).is_complete():
            msg = _(u'msg_appraisal_incomplete',
                    default=u'The appraisal is incomplete, appraisal could '
                    'not be finalized.')
            api.portal.show_message(
                message=msg, request=self.request, type='error')

            return self.request.RESPONSE.redirect(self.context.absolute_url())

        return self.request.RESPONSE.redirect(
            '{}/content_status_modify?workflow_action={}'.format(
                self.context.absolute_url(), self.transition))
Beispiel #26
0
    def __call__(self):
        if not IAppraisal(self.context).is_complete():
            msg = _(u'msg_appraisal_incomplete',
                    default=u'The appraisal is incomplete, appraisal could '
                    'not be finalized.')
            api.portal.show_message(
                message=msg, request=self.request, type='error')

            return self.request.RESPONSE.redirect(self.context.absolute_url())

        return self.request.RESPONSE.redirect(
            '{}/content_status_modify?workflow_action={}'.format(
                self.context.absolute_url(), self.transition))
Beispiel #27
0
    def get_render_arguments(self):
        self.layout.show_contact = False

        dossier_listener = getMultiAdapter(
            (self.context, self.request, self),
            ILaTexListing, name='destroyed_dossiers')

        history_listener = getMultiAdapter(
            (self.context, self.request, self),
            ILaTexListing, name='disposition_history')

        return {
            'label_protocol': self.translate(
                _('label_removal_protocol', default="Removal protocol")),
            'title': self.context.title,
            'disposition_metadata': self.get_disposition_metadata(),
            'label_dossiers': translate(
                _('label_dossiers', default="Dossiers"), context=self.request),
            'dossier_listing': dossier_listener.get_listing(
                self.context.get_dossier_representations()),
            'label_history': translate(
                _('label_history', default="History"), context=self.request),
            'history': history_listener.get_listing(self.context.get_history())
        }
Beispiel #28
0
    def __call__(self):
        reporter = XLSReporter(
            self.request, self.get_attributes(),
            self.context.get_dossier_representations(),
            sheet_title=self.get_sheet_title())

        response = self.request.RESPONSE
        data = reporter()
        if not data:
            msg = _(u'The report could not been generated.')
            api.portal.show_message(
                message=msg, request=self.request, type='error')
            return response.redirect(self.context.absolute_url())

        response.setHeader(
            'Content-Type',
            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
        set_attachment_content_disposition(
            self.request, "disposition_report.xlsx")

        return data
    def __call__(self):
        reporter = XLSReporter(self.request,
                               self.get_attributes(),
                               self.context.get_dossier_representations(),
                               sheet_title=self.get_sheet_title())

        response = self.request.RESPONSE
        data = reporter()
        if not data:
            msg = _(u'The report could not been generated.')
            api.portal.show_message(message=msg,
                                    request=self.request,
                                    type='error')
            return response.redirect(self.context.absolute_url())

        response.setHeader(
            'Content-Type',
            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
        )
        set_attachment_content_disposition(self.request, self.get_file_name())

        return data
Beispiel #30
0
 def label(self):
     return self.translate_to_all_languages(
         _('label_disposition_added', u'Disposition added'))
from zope.annotation import IAnnotations
from zope.component import getAdapters
from zope.globalrequest import getRequest
import logging
import sys
import traceback


TRANSPORT_STATUSES_KEY = 'opengever.disposition.delivery.transport_statuses'

STATUS_SCHEDULED = 'status_scheduled'
STATUS_SUCCESS = 'status_success'
STATUS_FAILED = 'status_failed'

DELIVERY_STATUS_LABELS = {
    STATUS_SCHEDULED: _(u'label_delivery_status_scheduled', default=u'Scheduled for delivery'),
    STATUS_SUCCESS: _(u'label_delivery_status_success', default=u'Delivered successfully'),
    STATUS_FAILED: _(u'label_delivery_status_failed', default=u'Delivery failed'),
}


class DeliveryScheduler(object):
    """The DeliveryScheduler takes care of scheduling SIP packages for delivery,
    performing scheduled deliveries by delegating to the respective transports,
    and tracking delivery statuses (per transport).
    """

    def __init__(self, disposition, parent_logger=None):
        self.disposition = disposition

        # When run via nightly job, the NightlyJobRunner's logger will be
Beispiel #32
0
 def get_pdf_title(self):
     title = _(u'title_removal_protocol',
               default=u'Removal protocol for ${disposition}',
               mapping={'disposition': self.context.title})
     return translate(title, context=self.request)
Beispiel #33
0
 def transition_label(self):
     return translate(
         _('label_disposition_added', default=u'Disposition added'),
         context=getRequest())
Beispiel #34
0
 def msg(self):
     return _(
         'msg_disposition_refuse',
         default=u'Disposition refused by ${user}',
         mapping=self._msg_mapping)
Beispiel #35
0
 def msg(self):
     return _('msg_disposition_archived',
              default=u'The archiving confirmed by ${user}',
              mapping=self._msg_mapping)
Beispiel #36
0
 def msg(self):
     return _('msg_disposition_appraised',
              default=u'Appraisal finalized by ${user}',
              mapping=self._msg_mapping)
Beispiel #37
0
 def msg(self):
     return _(
         'msg_disposition_close',
         default=u'Disposition closed and all dossiers destroyed by ${user}',
         mapping=self._msg_mapping)
Beispiel #38
0
 def msg(self):
     _('msg_disposition_updated', default=u'Updated by ${user}')
     return self.msg_mapping.get(self.transition)
Beispiel #39
0
 def msg(self):
     return _('msg_disposition_refuse',
              default=u'Disposition refused by ${user}',
              mapping=self._msg_mapping)
Beispiel #40
0
 def msg(self):
     return _('msg_disposition_edited',
              default=u'Edited by ${user}',
              mapping=self._msg_mapping)
Beispiel #41
0
 def label(self):
     return self.translate_to_all_languages(
         _('label_disposition_added', u'Disposition added'))
Beispiel #42
0
 def msg(self):
     return _('msg_disposition_appraised',
              default=u'Appraisal finalized by ${user}',
              mapping=self._msg_mapping)
Beispiel #43
0
    def get_archived_label(self, item):
        if item.appraisal:
            return _(u'label_yes', default=u'Yes')

        return _(u'label_no', default=u'No')
Beispiel #44
0
 def __call__(self):
     self.context.store_sip_package()
     msg = _('msg_sip_package_sucessfully_generated',
             default=u'SIP Package generated successfully.')
     api.portal.show_message(msg, request=self.request, type='info')
     return self.request.RESPONSE.redirect(self.context.absolute_url())
Beispiel #45
0
 def msg(self):
     return _('msg_disposition_disposed',
              default=u'Disposition disposed for the archive by ${user}',
              mapping=self._msg_mapping)
Beispiel #46
0
 def msg(self):
     return _('msg_disposition_archived',
              default=u'The archiving confirmed by ${user}',
              mapping=self._msg_mapping)
Beispiel #47
0
 def msg(self):
     return _(
         'msg_disposition_close',
         default=u'Disposition closed and all dossiers destroyed by ${user}',
         mapping=self._msg_mapping)
Beispiel #48
0
 def msg(self):
     return _('msg_disposition_disposed',
              default=u'Disposition disposed for the archive by ${user}',
              mapping=self._msg_mapping)
Beispiel #49
0
 def msg(self):
     _('msg_disposition_updated', default=u'Updated by ${user}')
     return self.msg_mapping.get(self.transition)
Beispiel #50
0
    def get_archived_label(self, item):
        if item.appraisal:
            return _(u'label_yes', default=u'Yes')

        return _(u'label_no', default=u'No')
Beispiel #51
0
 def msg(self):
     return _('msg_disposition_edited',
              default=u'Edited by ${user}',
              mapping=self._msg_mapping)
Beispiel #52
0
 def transition_label(self):
     return translate(_('label_disposition_added',
                        default=u'Disposition added'),
                      context=getRequest())