コード例 #1
0
    def add_journal_entry(self, journal_context, fixed_context,
                          old_period, new_period):
        """Add a journal entry to `journal_context` indicating that
        `fixed_context` has been fixed.

        The journal entry is not translated, we don't want to add translations
        for this fix to opengever.core.

        We use message objects to make it possible to add translations should
        it be required, also this helps to avoid an UnicodeDecodeError.

        """
        title = _(u'label_retention_period_fixed',
                  default=u'Aufbewahrungsdauer korrigiert "${name}"',
                  mapping={'name':
                           fixed_context.Title().decode('utf-8')})
        # the comment is handled different from the title, it does not get
        # translated when displaying :-o.
        comment = 'Alter Wert: "{} Jahre", neuer Wert: "{} Jahre"'\
                  .format(old_period, new_period)

        journal_entry_factory(journal_context,
                              ACTION_RETENTION_PERIOD_FIXED,
                              title=title,
                              comment=comment)
コード例 #2
0
ファイル: export.py プロジェクト: lambertkansy/opengever.core
    def handleExport(self, action):
        data, errors = self.extractData()

        if errors:
            self.status = self.formErrorsMessage
            return

        if data['paths']:
            objs = data['paths']
        else:
            objs = [self.context]

        message = model.MessageT1()
        message.action = data['action']
        message.recipient_id = data['recipients']
        if data['subject'] is not None:
            message.subjects = [data['subject']]
        if data['comment'] is not None:
            message.comments = [data['comment']]

        if data['directive']:
            directive = model.Directive(data['directive'])
            directive.priority = data['priority']
            directive.deadline = data['deadline']
            message.directive = directive

        journal_entry = _(u'label_exported_as_ech0147',
                          default=u'Exported as eCH-0147 message')
        for obj in objs:
            message.add_object(obj)
            journal_entry_factory(obj, 'eCH-0147 Export', journal_entry)

        header_dom = message.header().toDOM(element_name='eCH-0147T0:header')
        message_dom = message.binding().toDOM()

        tmpfile = TemporaryFile()
        with ZipFile(tmpfile, 'w', ZIP_DEFLATED, True) as zipfile:
            zipfile.writestr(
                'header.xml', header_dom.toprettyxml(encoding='UTF-8'))
            zipfile.writestr(
                'message.xml', message_dom.toprettyxml(encoding='UTF-8'))
            message.add_to_zip(zipfile)

        size = tmpfile.tell()

        response = self.request.response
        response.setHeader(
            "Content-Disposition",
            'inline; filename="message.zip"')
        response.setHeader("Content-type", "application/zip")
        response.setHeader("Content-Length", size)

        self.response_body = TempfileStreamIterator(tmpfile, size)
コード例 #3
0
ファイル: export.py プロジェクト: 4teamwork/opengever.core
    def handleExport(self, action):
        data, errors = self.extractData()

        if errors:
            self.status = self.formErrorsMessage
            return

        if data['paths']:
            objs = data['paths']
        else:
            objs = [self.context]

        message = model.MessageT1()
        message.action = data['action']
        message.recipient_id = data['recipients']
        if data['subject'] is not None:
            message.subjects = [data['subject']]
        if data['comment'] is not None:
            message.comments = [data['comment']]

        if data['directive']:
            directive = model.Directive(data['directive'])
            directive.priority = data['priority']
            directive.deadline = data['deadline']
            message.directive = directive

        journal_entry = _(u'label_exported_as_ech0147',
                          default=u'Exported as eCH-0147 message')
        for obj in objs:
            message.add_object(obj)
            journal_entry_factory(obj, 'eCH-0147 Export', journal_entry)

        header_dom = message.header().toDOM(element_name='eCH-0147T0:header')
        message_dom = message.binding().toDOM()

        tmpfile = TemporaryFile()
        with ZipFile(tmpfile, 'w', ZIP_DEFLATED, True) as zipfile:
            zipfile.writestr(
                'header.xml', header_dom.toprettyxml(encoding='UTF-8'))
            zipfile.writestr(
                'message.xml', message_dom.toprettyxml(encoding='UTF-8'))
            message.add_to_zip(zipfile)

        size = tmpfile.tell()

        response = self.request.response
        response.setHeader(
            "Content-Disposition",
            'inline; filename="message.zip"')
        response.setHeader("Content-type", "application/zip")
        response.setHeader("Content-Length", size)

        self.response_body = TempfileStreamIterator(tmpfile, size)
コード例 #4
0
def create_cropped_title_journal_entry(obj, type_, in_desc=False):
    # German translations as a default. Hack, because we don't want to
    # maintain translations in opengever.maintenance
    if in_desc:
        title = _(u'label_title_cropped_saved_in_desc',
                  default=u'Titel gek\xfcrzt: ${obj_id}; Urspr\xfcnglicher '
                          u'Titel wurde in Feld "Beschreibung" gespeichert.',
                  mapping={'obj_id': obj.id})
    else:
        title = _(u'label_title_cropped',
                  default=u'Titel gek\xfcrzt: ${obj_id}',
                  mapping={'obj_id': obj.id})

    if type_ == 'Task':
        journal_target = obj.get_containing_dossier()
    elif type_ == 'Dossier':
        journal_target = obj
    else:
        raise NotImplementedError

    journal_entry_factory(
        journal_target, 'Title cropped', title, actor='SYSTEM')
コード例 #5
0
def create_initial_journal_entry(mail):
    title = _(
        u'label_journal_initialized',
        default=u'Journal initialized')
    journal_entry_factory(mail, 'Journal initialized', title)