Beispiel #1
0
    def get_columns(self):
        return [
            Column('sequence_number',
                   _('short_label_sequence_number', default='No.'),
                   '6%'),

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

            Column('document_date',
                   _('label_document_date', default='Document date'),
                   '13%',
                   lambda brain: helper.readable_date(brain, brain.document_date)),

            Column('receipt_date',
                   _('label_receipt_date', default='Receipt date'),
                   '13%',
                   lambda brain: helper.readable_date(brain, brain.receipt_date)),

            Column('delivery_date',
                   _('label_delivery_date', default='Delivery date'),
                   '13%',
                   lambda brain: helper.readable_date(brain, brain.delivery_date)),

            Column('document_author',
                   _('label_document_author', default='Document author'),
                   '20%')
        ]
Beispiel #2
0
 def get_folder_data(dossier):
     data = ['',
             dossier.get_reference_number(),
             dossier.title,
             api.content.get_state(dossier),
             dossier.responsible_label,
             readable_date(dossier, IDossier(dossier).start),
             readable_date(dossier, IDossier(dossier).end),
             ', '.join(IDossier(dossier).keywords),
             ]
     return data
Beispiel #3
0
 def get_items(self):
     """Returns all items to be displayed.
     """
     ftwfile = has_ftwfile(self.context)
     for brain in self._brains():
         yield {'title': self.convert(brain.Title),
                'effective': helper.readable_date(
                     brain, getattr(
                     brain, ftwfile and 'documentDate' or 'effective')),
                'modified': helper.readable_date(
                     brain, getattr(brain, 'modified')),
                'creator': self.get_creator(brain),
                }
Beispiel #4
0
    def get_config(self):
        """Returns a list with dict per row including this row informations:
        - label
        - value_getter
        - width
        """

        return [{
            'id': 'sequence_number',
            'label': _('short_label_sequence_number', default='No.'),
            'width': '6%',
            'getter': lambda brain: brain.sequence_number
        }, {
            'id': 'title',
            'label': _('label_title', default='Title'),
            'width': '35%',
            'getter': lambda brain: brain.Title
        }, {
            'id':
            'document_date',
            'label':
            _('label_document_date', default='Document date'),
            'width':
            '13%',
            'getter':
            lambda brain: helper.readable_date(brain, brain.document_date)
        }, {
            'id':
            'receipt_date',
            'label':
            _('label_receipt_date', default='Receipt date'),
            'width':
            '13%',
            'getter':
            lambda brain: helper.readable_date(brain, brain.receipt_date)
        }, {
            'id':
            'delivery_date',
            'label':
            _('label_delivery_date', default='Delivery date'),
            'width':
            '13%',
            'getter':
            lambda brain: helper.readable_date(brain, brain.delivery_date)
        }, {
            'id': 'document_author',
            'label': _('label_document_author', default='Document author'),
            'width': '20%',
            'getter': lambda brain: brain.document_author
        }]
Beispiel #5
0
    def get_config(self):
        """Returns a list with dict per row including this row informations:
        - label
        - value_getter
        - width
        """

        return [
            {'id': 'reference',
             'label': _('label_reference_number', default='Reference number'),
             'width': '10%',
             'getter': lambda brain: brain.reference},

            {'id': 'sequence_number',
             'label': _('short_label_sequence_number', default='No.'),
             'width': '5%',
             'getter': lambda brain: brain.sequence_number},

            {'id': 'repository_title',
             'label': _('label_repository_title', default='Repositoryfolder'),
             'width': '20%',
             'getter': self.get_repository_title},

            {'id': 'title',
             'label': _('label_title', default='Title'),
             'width': '25%',
             'getter': lambda brain: brain.Title},

            {'id': 'responsible',
             'label': _('label_responsible', default='Responsible'),
             'width': '20%',
             'getter': self.get_responsible},

            {'id': 'review_state',
             'label': _('label_review_state', default='State'),
             'width': '10%',
             'getter': lambda brain: workflow_state(
                 brain, brain.review_state)},

            {'id': 'start',
             'label': _('label_start', default='Start'),
             'width': '5%',
             'getter': lambda brain: helper.readable_date(
                 brain, brain.start)},

            {'id': 'end',
             'label': _('label_end', default='End'),
             'width': '5%',
             'getter': lambda brain: helper.readable_date(brain, brain.end)}]
Beispiel #6
0
def readable_date(item, date):
    if isinstance(date, str):
        try:
            date = datetime.strptime(date[:10], '%Y-%m-%d').date()
        except ValueError:
            return ''
    return helper.readable_date(item, date)
    def get_data_for_item(self, item):
        admin_unit = item.get_admin_unit().title
        task_type = task_type_helper(item, item.task_type)
        sequence_number = unicode(item.sequence_number).encode("utf-8")
        deadline = helper.readable_date(item, item.deadline)

        title = unicode(getattr(item, "Title", getattr(item, "title", ""))).encode("utf-8")

        issuer = get_issuer_of_task(item, with_client=True, with_principal=False)

        responsible_org_unit = item.get_assigned_org_unit()
        responsible = Actor.lookup(item.responsible)
        responsible_label = responsible_org_unit.prefix_label(responsible.get_label(with_principal=False))

        dossier_title = item.containing_dossier or ""

        reference = unicode(getattr(item, "reference", getattr(item, "reference_number", ""))).encode("utf-8")

        review_state = workflow_state(item, item.review_state)

        return [
            admin_unit,
            sequence_number,
            title,
            task_type,
            dossier_title,
            reference,
            issuer,
            responsible_label,
            deadline,
            review_state,
        ]
Beispiel #8
0
def readable_date(item, date):
    if isinstance(date, str):
        try:
            date = datetime.strptime(date[:10], '%Y-%m-%d').date()
        except ValueError:
            return ''
    return helper.readable_date(item, date)
Beispiel #9
0
    def get_config(self):
        """Returns a list with dict per row including this row informations:
        - label
        - value_getter
        - width
        """

        return [{
            'id': 'sequence_number',
            'label': _('short_label_sequence_number', default='No.'),
            'width': '3%',
            'getter': lambda brain: brain.sequence_number
        }, {
            'id':
            'task_type',
            'label':
            _('label_task_type', default='Task type'),
            'width':
            '20%',
            'getter':
            lambda brain: task_type_helper(brain, brain.task_type)
        }, {
            'id':
            'issuer',
            'label':
            _('label_issuer', default='Issuer'),
            'width':
            '15%',
            'getter':
            lambda brain: get_issuer_of_task(
                brain, with_client=True, with_principal=False)
        }, {
            'id': 'responsible',
            'label': _('label_task_responsible', default='Responsible'),
            'width': '15%',
            'getter': lambda brain: get_responsible_of_task(brain)
        }, {
            'id':
            'review_state',
            'label':
            _('label_review_state', default='State'),
            'width':
            '7%',
            'getter':
            lambda brain: workflow_state(brain, brain.review_state)
        }, {
            'id': 'title',
            'label': _('label_title', default='Title'),
            'width': '25%',
            'getter': lambda brain: brain.Title
        }, {
            'id':
            'deadline',
            'label':
            _('label_deadline', default='Deadline'),
            'width':
            '15%',
            'getter':
            lambda brain: helper.readable_date(brain, brain.deadline)
        }]
Beispiel #10
0
    def get_config(self):
        """Returns a list with dict per row including this row informations:
        - label
        - value_getter
        - width
        """

        return [
            {'id': 'sequence_number',
             'label': _('short_label_sequence_number', default='No.'),
             'width': '6%',
             'getter': lambda brain: brain.sequence_number},

            {'id': 'title',
             'label': _('label_title', default='Title'),
             'width': '35%',
             'getter': lambda brain: brain.Title},

            {'id': 'document_date',
             'label': _('label_document_date', default='Document date'),
             'width': '13%',
             'getter': lambda brain: helper.readable_date(
                 brain, brain.document_date)},

            {'id': 'receipt_date',
             'label': _('label_receipt_date', default='Receipt date'),
             'width': '13%',
             'getter': lambda brain: helper.readable_date(
                 brain, brain.receipt_date)},

            {'id': 'delivery_date',
             'label': _('label_delivery_date', default='Delivery date'),
             'width': '13%',
             'getter': lambda brain: helper.readable_date(
                 brain, brain.delivery_date)},

            {'id': 'document_author',
             'label': _('label_document_author', default='Document author'),
             'width': '20%',
             'getter': lambda brain: brain.document_author}]
Beispiel #11
0
    def get_columns(self):
        return [
            Column('reference',
                   _('label_reference_number', default='Reference number'),
                   '10%'),

            Column('sequence_number',
                   _('short_label_sequence_number', default='No.'),
                   '5%'),

            Column('repository_title',
                   _('label_repository_title', default='Repositoryfolder'),
                   '20%',
                   self.get_repository_title),

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

            Column('responsible',
                   _('label_responsible', default='Responsible'),
                   '20%',
                   self.get_responsible),

            Column('review_state',
                   _('label_review_state', default='State'),
                   '10%',
                   lambda brain: workflow_state(brain, brain.review_state)),

            Column('start',
                   _('label_start', default='Start'),
                   '5%',
                   lambda brain: helper.readable_date(brain, brain.start)),

            Column('end',
                   _('label_end', default='End'),
                   '5%',
                   lambda brain: helper.readable_date(brain, brain.end))
        ]
Beispiel #12
0
 def get_columns(self):
     return [
         Column('reference',
                _('label_reference_number', default='Reference number'),
                '10%'),
         Column('sequence_number',
                _('short_label_sequence_number', default='No.'), '5%'),
         Column('repository_title',
                _('label_repository_title', default='Repositoryfolder'),
                '20%', self.get_repository_title),
         Column('title', _('label_title', default='Title'), '25%', 'Title'),
         Column('responsible', _('label_responsible',
                                 default='Responsible'), '20%',
                self.get_responsible),
         Column('review_state', _('label_review_state',
                                  default='State'), '10%',
                lambda brain: workflow_state(brain, brain.review_state)),
         Column('start', _('label_start', default='Start'), '5%',
                lambda brain: helper.readable_date(brain, brain.start)),
         Column('end', _('label_end', default='End'), '5%',
                lambda brain: helper.readable_date(brain, brain.end))
     ]
Beispiel #13
0
 def get_columns(self):
     return [
         Column('sequence_number',
                _('short_label_sequence_number', default='No.'), '6%'),
         Column('title', _('label_title', default='Title'), '35%', 'Title'),
         Column(
             'document_date',
             _('label_document_date', default='Document date'),
             '13%', lambda brain: helper.readable_date(
                 brain, brain.document_date)),
         Column(
             'receipt_date', _('label_receipt_date',
                               default='Receipt date'), '13%',
             lambda brain: helper.readable_date(brain, brain.receipt_date)),
         Column(
             'delivery_date',
             _('label_delivery_date', default='Delivery date'),
             '13%', lambda brain: helper.readable_date(
                 brain, brain.delivery_date)),
         Column('document_author',
                _('label_document_author', default='Document author'),
                '20%')
     ]
Beispiel #14
0
    def get_items(self):
        acl_users = getToolByName(self.context, "acl_users")

        for brain in self._brains():
            obj = brain.getObject()

            attendees = []
            for userid in obj.getAttendeesOrUsers():
                user = acl_users.getUserById(userid)
                attendees.append(user and user.getProperty("fullname", userid) or userid)

            yield {
                "title": obj.Title(),
                "start": helper.readable_date(brain, obj.startDate),
                "attendees": ", ".join(attendees),
            }
Beispiel #15
0
    def get_config(self):
        """Returns a list with dict per row including this row informations:
        - label
        - value_getter
        - width
        """

        return [
            {'id': 'sequence_number',
             'label': _('short_label_sequence_number', default='No.'),
             'width': '3%',
             'getter': lambda brain: brain.sequence_number},

            {'id': 'task_type',
             'label': _('label_task_type', default='Task type'),
             'width': '20%',
             'getter': lambda brain: task_type_helper(brain, brain.task_type)},

            {'id': 'issuer',
             'label': _('label_issuer', default='Issuer'),
             'width': '15%',
             'getter': lambda brain: get_issuer_of_task(
                 brain, with_client=True, with_principal=False)},

            {'id': 'responsible',
             'label': _('label_task_responsible', default='Responsible'),
             'width': '15%',
             'getter': lambda brain: get_responsible_of_task(brain)},

            {'id': 'review_state',
             'label': _('label_review_state', default='State'),
             'width': '7%',
             'getter': lambda brain: workflow_state(
                 brain, brain.review_state)},

            {'id': 'title',
             'label': _('label_title', default='Title'),
             'width': '25%',
             'getter': lambda brain: brain.Title},

            {'id': 'deadline',
             'label': _('label_deadline', default='Deadline'),
             'width': '15%',
             'getter': lambda brain: helper.readable_date(
                 brain, brain.deadline)}]
    def get_row_for_item(self, item, display_issuer_client=False,
                         display_responsible_client=False):
        task_type = task_type_helper(item, item.task_type)
        sequence_number = unicode(item.sequence_number).encode('utf-8')
        deadline = helper.readable_date(item, item.deadline)

        title = unicode(getattr(item, 'Title',
                            getattr(item, 'title', ''))).encode('utf-8')

        issuer = get_issuer_of_task(item,
                                    with_client=display_issuer_client,
                                    with_principal=False)

        responsible = self.info.describe(item.responsible,
                                         with_principal=False)

        if display_responsible_client:
            responsible_client = self.info.get_client_by_id(
                item.assigned_client).title
            responsible = '%s / %s' % (
                responsible_client,
                responsible)

        dossier_title = item.containing_dossier or ''

        reference = unicode(getattr(
                item, 'reference',
                getattr(item, 'reference_number', ''))).encode('utf-8')

        review_state = workflow_state(item, item.review_state)

        data = [
            sequence_number,
            title,
            task_type,
            dossier_title,
            reference,
            issuer,
            responsible,
            deadline,
            review_state,
            ]

        return self.convert_list_to_row(data)
    def get_row_for_item(self,
                         item,
                         display_issuer_client=False,
                         display_responsible_client=False):
        task_type = task_type_helper(item, item.task_type)
        sequence_number = unicode(item.sequence_number).encode('utf-8')
        deadline = helper.readable_date(item, item.deadline)

        title = unicode(getattr(item, 'Title', getattr(item, 'title',
                                                       ''))).encode('utf-8')

        issuer = get_issuer_of_task(item,
                                    with_client=display_issuer_client,
                                    with_principal=False)

        responsible = self.info.describe(item.responsible,
                                         with_principal=False)

        if display_responsible_client:
            responsible_client = self.info.get_client_by_id(
                item.assigned_client).title
            responsible = '%s / %s' % (responsible_client, responsible)

        dossier_title = item.containing_dossier or ''

        reference = unicode(
            getattr(item, 'reference', getattr(item, 'reference_number',
                                               ''))).encode('utf-8')

        review_state = workflow_state(item, item.review_state)

        data = [
            sequence_number,
            title,
            task_type,
            dossier_title,
            reference,
            issuer,
            responsible,
            deadline,
            review_state,
        ]

        return self.convert_list_to_row(data)
Beispiel #18
0
 def get_columns(self):
     return [
         Column('sequence_number',
                _('short_label_sequence_number', default='No.'), '3%'),
         Column('task_type', _('label_task_type', default='Task type'),
                '20%', lambda item: task_type_helper(item, item.task_type)),
         Column(
             'issuer', _('label_issuer', default='Issuer'), '15%',
             lambda item: get_issuer_of_task(
                 item, with_client=True, with_principal=False)),
         Column('responsible',
                _('label_task_responsible', default='Responsible'), '15%',
                get_responsible_of_task),
         Column('review_state', _('label_review_state', default='State'),
                '7%', lambda item: workflow_state(item, item.review_state)),
         Column('title', _('label_title', default='Title'), '25%'),
         Column('deadline', _('label_deadline', default='Deadline'), '15%',
                lambda item: helper.readable_date(item, item.deadline))
     ]
Beispiel #19
0
    def get_data_for_item(self,
                          item,
                          display_issuing_org_unit=False,
                          display_assigned_org_unit=False):
        task_type = task_type_helper(item, item.task_type)
        sequence_number = unicode(item.sequence_number).encode('utf-8')
        deadline = helper.readable_date(item, item.deadline)

        title = unicode(getattr(item, 'Title', getattr(item, 'title',
                                                       ''))).encode('utf-8')

        issuer = get_issuer_of_task(item,
                                    with_client=display_issuing_org_unit,
                                    with_principal=False)

        actor = Actor.lookup(item.responsible)
        responsible = actor.get_label(with_principal=False)

        if display_assigned_org_unit:
            org_unit = item.get_assigned_org_unit()
            responsible = org_unit.prefix_label(responsible)

        dossier_title = item.containing_dossier or ''

        reference = unicode(
            getattr(item, 'reference', getattr(item, 'reference_number',
                                               ''))).encode('utf-8')

        review_state = workflow_state(item, item.review_state)

        return [
            sequence_number,
            title,
            task_type,
            dossier_title,
            reference,
            issuer,
            responsible,
            deadline,
            review_state,
        ]
    def get_data_for_item(self, item,
                          display_issuing_org_unit=False,
                          display_assigned_org_unit=False):
        task_type = task_type_helper(item, item.task_type)
        sequence_number = unicode(item.sequence_number).encode('utf-8')
        deadline = helper.readable_date(item, item.deadline)

        title = unicode(getattr(item, 'Title',
                        getattr(item, 'title', ''))).encode('utf-8')

        issuer = get_issuer_of_task(item,
                                    with_client=display_issuing_org_unit,
                                    with_principal=False)

        actor = Actor.lookup(item.responsible)
        responsible = actor.get_label(with_principal=False)

        if display_assigned_org_unit:
            org_unit = item.get_assigned_org_unit()
            responsible = org_unit.prefix_label(responsible)

        dossier_title = item.containing_dossier or ''

        reference = unicode(getattr(
            item, 'reference',
            getattr(item, 'reference_number', ''))).encode('utf-8')

        review_state = workflow_state(item, item.review_state)

        return [
            sequence_number,
            title,
            task_type,
            dossier_title,
            reference,
            issuer,
            responsible,
            deadline,
            review_state,
            ]
Beispiel #21
0
    def get_columns(self):
        return [
            Column('sequence_number',
                   _('short_label_sequence_number', default='No.'),
                   '3%'),

            Column('task_type',
                   _('label_task_type', default='Task type'),
                   '20%',
                   lambda item: task_type_helper(item, item.task_type)),

            Column('issuer',
                   _('label_issuer', default='Issuer'),
                   '15%',
                   lambda item: get_issuer_of_task(item, with_client=True,
                                                   with_principal=False)),

            Column('responsible',
                   _('label_task_responsible', default='Responsible'),
                   '15%',
                   get_responsible_of_task),

            Column('review_state',
                   _('label_review_state', default='State'),
                   '7%',
                   lambda item: workflow_state(item, item.review_state)),

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

            Column('deadline',
                   _('label_deadline', default='Deadline'),
                   '15%',
                   lambda item: helper.readable_date(item, item.deadline))
        ]
 def get_start_date(self):
     return helper.readable_date(
         self.context, IDossier(self.context).start)
 def get_start_date(self):
     return helper.readable_date(
         self.context, IDossier(self.context).start)
 def get_end_date(self):
     return helper.readable_date(
         self.context, IDossier(self.context).end)
Beispiel #25
0
    def get_config(self):
        """Returns a list with dict per row including this row informations:
        - label
        - value_getter
        - width
        """

        return [{
            'id':
            'reference',
            'label':
            _('label_reference_number', default='Reference number'),
            'width':
            '10%',
            'getter':
            lambda brain: brain.reference
        }, {
            'id': 'sequence_number',
            'label': _('short_label_sequence_number', default='No.'),
            'width': '5%',
            'getter': lambda brain: brain.sequence_number
        }, {
            'id':
            'repository_title',
            'label':
            _('label_repository_title', default='Repositoryfolder'),
            'width':
            '20%',
            'getter':
            self.get_repository_title
        }, {
            'id': 'title',
            'label': _('label_title', default='Title'),
            'width': '25%',
            'getter': lambda brain: brain.Title
        }, {
            'id': 'responsible',
            'label': _('label_responsible', default='Responsible'),
            'width': '20%',
            'getter': self.get_responsible
        }, {
            'id':
            'review_state',
            'label':
            _('label_review_state', default='State'),
            'width':
            '10%',
            'getter':
            lambda brain: workflow_state(brain, brain.review_state)
        }, {
            'id':
            'start',
            'label':
            _('label_start', default='Start'),
            'width':
            '5%',
            'getter':
            lambda brain: helper.readable_date(brain, brain.start)
        }, {
            'id': 'end',
            'label': _('label_end', default='End'),
            'width': '5%',
            'getter': lambda brain: helper.readable_date(brain, brain.end)
        }]
 def test_none_if_value_is_invalid(self):
     self.assertEqual(
         None,
         readable_date(object, 'invalid date'))
 def test_date_in_format_d_m_y(self):
     self.assertEqual(
         '17.10.2012',
         readable_date(object, datetime(2012, 10, 17, 20, 8)))
 def test_date_in_format_d_m_y(self):
     self.assertEqual(
         '17.10.2012',
         readable_date(object, datetime(2012, 10, 17, 20, 8)))
 def test_none_if_value_is_invalid(self):
     self.assertEqual(
         None,
         readable_date(object, 'invalid date'))
 def test_empty_string_if_no_value_is_given(self):
     self.assertEqual(
         u'',
         readable_date(object, None))
 def get_end_date(self):
     return helper.readable_date(
         self.context, IDossier(self.context).end)
 def test_empty_string_if_no_value_is_given(self):
     self.assertEqual(
         u'',
         readable_date(object, None))