record emails sent in history (#4326)
This commit is contained in:
parent
99cd46f2d0
commit
1e0328bb78
|
@ -36,7 +36,17 @@ class ContentHistoryView(BaseHistoryView):
|
|||
history_line['action'] = 'pfwbged_field'
|
||||
history_line['type'] = 'pfwbged_field'
|
||||
history_line['comments'] = ', '.join(history_line['value'])
|
||||
history_line['transition_title'] = _('New value for %s') % history_line['attribute']
|
||||
history_line['transition_title'] = _('New value for ${attribute}',
|
||||
mapping={'attribute': history_line['attribute']})
|
||||
if history_line['action_id'] == 'pfwbged_mail':
|
||||
history_line['actor'] = None
|
||||
history_line['actor_home'] = None
|
||||
history_line['actorid'] = history_line['actor_name']
|
||||
history_line['action'] = 'pfwbged_mail'
|
||||
history_line['type'] = 'pfwbged_mail'
|
||||
history_line['comments'] = _('To: ${to}', mapping={'to': history_line.get('to', '')})
|
||||
history_line['transition_title'] = _('Sent version ${version} by email',
|
||||
mapping={'version': history_line.get('version', '?')})
|
||||
return history
|
||||
|
||||
def workflowHistory(self, complete=True):
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
|
||||
import random
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from DateTime import DateTime
|
||||
from email.mime.base import MIMEBase
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
|
@ -13,6 +15,7 @@ from zope.component import createObject, queryUtility
|
|||
from z3c.form import form, button
|
||||
from z3c.form.field import Fields
|
||||
from z3c.form.interfaces import HIDDEN_MODE
|
||||
from zope.annotation.interfaces import IAnnotations
|
||||
|
||||
from Acquisition import aq_inner, aq_parent
|
||||
|
||||
|
@ -86,6 +89,21 @@ class MailForm(form.AddForm):
|
|||
log = logging.getLogger('pfwbged.policy')
|
||||
log.exception(e)
|
||||
self.context.plone_utils.addPortalMessage(_('Error sending email'))
|
||||
else:
|
||||
document = aq_parent(self.context)
|
||||
annotations = IAnnotations(document)
|
||||
if not 'pfwbged_history' in annotations:
|
||||
annotations['pfwbged_history'] = []
|
||||
annotations['pfwbged_history'].append({'time': DateTime(),
|
||||
'action_id': 'pfwbged_mail',
|
||||
'action': 'Sent by email',
|
||||
'actor_name': api.user.get_current().getId(),
|
||||
'to': msg['To'],
|
||||
'version': self.context.Title(),
|
||||
})
|
||||
# assign it back as a change to the list won't trigger the
|
||||
# annotation to be saved on disk.
|
||||
annotations['pfwbged_history'] = annotations['pfwbged_history'][:]
|
||||
|
||||
self.next_url = aq_parent(self.context).absolute_url()
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: pfwbged.policy\n"
|
||||
"POT-Creation-Date: 2014-10-20 14:13+0000\n"
|
||||
"PO-Revision-Date: 2014-10-20 16:14+0200\n"
|
||||
"POT-Creation-Date: 2014-10-24 11:52+0000\n"
|
||||
"PO-Revision-Date: 2014-10-24 13:52+0200\n"
|
||||
"Last-Translator: Frederic Peters <fpeters@entrouvert.com>\n"
|
||||
"Language-Team: --\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
|
@ -72,13 +72,13 @@ msgid "Can view"
|
|||
msgstr "Visible par"
|
||||
|
||||
#: ../browser/refuse.py:109
|
||||
#: ../browser/send_by_email.py:92
|
||||
#: ../browser/send_by_email.py:111
|
||||
#: ../browser/to_process.py:63
|
||||
msgid "Cancel"
|
||||
msgstr "Annuler"
|
||||
|
||||
#: ../browser/refuse.py:33
|
||||
#: ../browser/send_by_email.py:32
|
||||
#: ../browser/send_by_email.py:35
|
||||
#: ../browser/to_process.py:25
|
||||
msgid "Comment"
|
||||
msgstr "Note"
|
||||
|
@ -107,11 +107,11 @@ msgstr "Adresse du document : %s"
|
|||
msgid "Document: %s"
|
||||
msgstr "Document : %s"
|
||||
|
||||
#: ../browser/send_by_email.py:29
|
||||
#: ../browser/send_by_email.py:32
|
||||
msgid "Email addresses of the recipients, one per line"
|
||||
msgstr "Adresses électroniques des destinataires, une par ligne"
|
||||
|
||||
#: ../browser/send_by_email.py:88
|
||||
#: ../browser/send_by_email.py:91
|
||||
msgid "Error sending email"
|
||||
msgstr "Erreur à l'envoi d'un courrier électronique"
|
||||
|
||||
|
@ -136,8 +136,8 @@ msgid "My Tasks"
|
|||
msgstr "Mes tâches"
|
||||
|
||||
#: ../browser/history.py:39
|
||||
msgid "New value for %s"
|
||||
msgstr "Nouvelle valeur pour %s"
|
||||
msgid "New value for ${attribute}"
|
||||
msgstr "Nouvelle valeur pour ${attribute}"
|
||||
|
||||
#: ../subscribers/document.py:441
|
||||
msgid "New value for %s: %s"
|
||||
|
@ -159,7 +159,7 @@ msgstr "Traiter le document"
|
|||
msgid "Process mail"
|
||||
msgstr "Traiter le document"
|
||||
|
||||
#: ../browser/send_by_email.py:28
|
||||
#: ../browser/send_by_email.py:31
|
||||
msgid "Recipients"
|
||||
msgstr "Destinataires"
|
||||
|
||||
|
@ -192,7 +192,7 @@ msgstr "Enregistrer"
|
|||
msgid "Save As..."
|
||||
msgstr "Enregistrer sous…"
|
||||
|
||||
#: ../browser/send_by_email.py:49
|
||||
#: ../browser/send_by_email.py:52
|
||||
msgid "Send"
|
||||
msgstr "Envoyer"
|
||||
|
||||
|
@ -208,7 +208,15 @@ msgstr "Envoyer la version ${version} par email"
|
|||
msgid "Send version ${version} with PES"
|
||||
msgstr "Envoyer la version ${version} avec la PES"
|
||||
|
||||
#: ../browser/send_by_email.py:30
|
||||
#: ../browser/send_by_email.py:99
|
||||
msgid "Sent by email to %s"
|
||||
msgstr "Envoyé par email à %s"
|
||||
|
||||
#: ../browser/history.py:48
|
||||
msgid "Sent version ${version} by email"
|
||||
msgstr "Version ${version} envoyée par email"
|
||||
|
||||
#: ../browser/send_by_email.py:33
|
||||
msgid "Subject"
|
||||
msgstr "Objet"
|
||||
|
||||
|
@ -224,6 +232,10 @@ msgstr "Titre : %s"
|
|||
msgid "To process (with comment)"
|
||||
msgstr "À traiter (avec commentaire)"
|
||||
|
||||
#: ../browser/history.py:47
|
||||
msgid "To: ${to}"
|
||||
msgstr "À : ${to}"
|
||||
|
||||
#: ../menu.py:52
|
||||
msgid "Validate and finish version ${version}"
|
||||
msgstr "Valider et finaliser la version ${version}"
|
||||
|
@ -242,7 +254,7 @@ msgid "Workflow action"
|
|||
msgstr "Transition du workflow"
|
||||
|
||||
#: ../browser/refuse.py:34
|
||||
#: ../browser/send_by_email.py:33
|
||||
#: ../browser/send_by_email.py:36
|
||||
#: ../browser/to_process.py:26
|
||||
msgid "You can enter a note."
|
||||
msgstr "Vous pouvez entrer une note."
|
||||
|
|
|
@ -443,6 +443,9 @@ def log_some_history(context, event):
|
|||
'attribute': field,
|
||||
'value': value,
|
||||
})
|
||||
# assign it back as a change to the list won't trigger the
|
||||
# annotation to be saved on disk.
|
||||
annotations['pfwbged_history'] = annotations['pfwbged_history'][:]
|
||||
|
||||
|
||||
@grok.subscribe(IFolder, IObjectAddedEvent)
|
||||
|
|
Reference in New Issue