Ejemplo n.º 1
0
    def get_rows(self):
        rows = []

        for row in get_selected_items(self.context, self.request):
            rows.append(self.get_row_for_item(row))

        return rows
Ejemplo n.º 2
0
    def __call__(self):
        tasks = get_selected_items(self.context, self.request)
        tasks = [tt for tt in tasks]

        if not tasks:
            msg = _(
                u'error_no_items', default=u'You have not selected any items.')
            IStatusMessage(self.request).addStatusMessage(msg, type='error')
            if self.request.get('orig_template'):
                return self.request.RESPONSE.redirect(
                    self.request.form['orig_template'])
            else:
                return self.request.RESPONSE.redirect(
                    self.context.absolute_url())

        reporter = XLSReporter(
            self.context.REQUEST,
            self.columns(),
            tasks,
            sheet_title=translate(
                _('label_tasks', default=u'Tasks'), context=self.request),
            footer='%s %s' % (
                datetime.now().strftime('%d.%m.%Y %H:%M'),
                get_current_admin_unit().id())
            )

        return self.return_excel(reporter)
Ejemplo n.º 3
0
    def render(self):

        tasks = get_selected_items(self.context, self.request)
        tasks = [tt for tt in tasks]

        if not tasks:
            msg = _(
                u'error_no_items', default=u'You have not selected any Items')
            IStatusMessage(self.request).addStatusMessage(msg, type='error')
            if self.request.get('orig_template'):
                return self.request.RESPONSE.redirect(
                    self.request.form['orig_template'])
            else:
                return self.request.RESPONSE.redirect(
                    self.context.absolute_url())

        task_attributes = [
            {'id':'title', 'title':_('label_task_title')},
            {'id':'review_state', 'title':_('review_state'),
             'transform':StringTranslater(
                self.context.REQUEST, 'plone').translate},
            {'id':'deadline', 'title':_('label_deadline'),
             'transform':format_datetime, 'style':get_date_style()},
            {'id':'completed', 'title':_('label_completed'),
             'transform':format_datetime, 'style':get_date_style()},
            {'id': 'containing_dossier', 'title':_('label_dossier_title')},
            {'id':'issuer', 'title':_('label_issuer'),
             'transform':readable_author},
            {'id':'responsible', 'title':_('label_responsible'),
             'transform':readable_author},
            {'id':'task_type', 'title':_('label_task_type'),
             'transform':task_type_helper},
            {'id':'client_id', 'title':_('label_client_id')},
            {'id':'sequence_number', 'title':_('label_sequence_number')},
        ]

        reporter = XLSReporter(
            self.context.REQUEST,
            task_attributes,
            tasks,
            sheet_title=translate(
                _('label_tasks', default=u'Tasks'), context=self.request),
            footer='%s %s' % (
                datetime.now().strftime('%d.%m.%Y %H:%M'), get_client_id())
            )

        data = reporter()
        if not data:
            msg = _(u'Could not generate the report')
            IStatusMessage(self.request).addStatusMessage(
                msg, type='error')
            return self.request.RESPONSE.redirect(self.context.absolute_url())

        response = self.request.RESPONSE

        response.setHeader('Content-Type', 'application/vnd.ms-excel')
        set_attachment_content_disposition(self.request, "task_report.xls")

        return data
Ejemplo n.º 4
0
    def render(self):

        tasks = get_selected_items(self.context, self.request)
        tasks = [tt for tt in tasks]

        if not tasks:
            msg = _(u'error_no_items',
                    default=u'You have not selected any items.')
            IStatusMessage(self.request).addStatusMessage(msg, type='error')
            if self.request.get('orig_template'):
                return self.request.RESPONSE.redirect(
                    self.request.form['orig_template'])
            else:
                return self.request.RESPONSE.redirect(
                    self.context.absolute_url())

        task_attributes = [
            {
                'id': 'title',
                'title': _('label_task_title')
            },
            {
                'id':
                'review_state',
                'title':
                _('review_state'),
                'transform':
                StringTranslater(self.context.REQUEST, 'plone').translate
            },
            {
                'id': 'deadline',
                'title': _('label_deadline'),
                'number_format': DATE_NUMBER_FORMAT
            },
            {
                'id': 'completed',
                'title': _('label_completed'),
                'number_format': DATE_NUMBER_FORMAT
            },
            {
                'id': 'containing_dossier',
                'title': _('label_dossier_title')
            },
            {
                'id': 'issuer',
                'title': _('label_issuer'),
                'transform': readable_author
            },
            {
                'id': 'issuing_org_unit_label',
                'title': _('label_issuing_org_unit')
            },
            {
                'id': 'responsible',
                'title': _('label_responsible'),
                'transform': readable_author
            },
            {
                'id': 'task_type',
                'title': _('label_task_type'),
                'transform': task_type_helper
            },
            {
                'id': 'admin_unit_id',
                'title': _('label_admin_unit_id')
            },
            {
                'id': 'sequence_number',
                'title': _('label_sequence_number')
            },
        ]

        reporter = XLSReporter(self.context.REQUEST,
                               task_attributes,
                               tasks,
                               sheet_title=translate(_('label_tasks',
                                                       default=u'Tasks'),
                                                     context=self.request),
                               footer='%s %s' %
                               (datetime.now().strftime('%d.%m.%Y %H:%M'),
                                get_current_admin_unit().id()))

        data = reporter()
        if not data:
            msg = _(u'Could not generate the report.')
            IStatusMessage(self.request).addStatusMessage(msg, type='error')
            return self.request.RESPONSE.redirect(self.context.absolute_url())

        response = self.request.RESPONSE

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

        return data