Browse Source

[IMP] Emails are now translated.

pull/2/head
Sylvain LE GAL 11 years ago
parent
commit
d437d3af72
  1. 5
      auth_admin_passkey/__openerp__.py
  2. 35
      auth_admin_passkey/i18n/auth_admin_passkey.pot
  3. 58
      auth_admin_passkey/i18n/fr.po
  4. 45
      auth_admin_passkey/model/res_users.py

5
auth_admin_passkey/__openerp__.py

@ -15,15 +15,12 @@ Functionnalities :
------------------ ------------------
* Administrator has now the possibility to login in with any login; * Administrator has now the possibility to login in with any login;
* By default, OpenERP will send a mail to user and admin to indicate them; * By default, OpenERP will send a mail to user and admin to indicate them;
* If a user has the same password as the admin, OpenERP will inform the admin;
Technical informations : Technical informations :
------------------------ ------------------------
* Create two ir_config_parameter to enable / disable mail sending; * Create two ir_config_parameter to enable / disable mail sending;
Limits :
--------
* For the moment, this module doesn't manage translations for the mails;
Copyright and Licence : Copyright and Licence :
----------------------- -----------------------
* 2014, Groupement Régional Alimentaire de Proximité * 2014, Groupement Régional Alimentaire de Proximité

35
auth_admin_passkey/i18n/auth_admin_passkey.pot

@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n" "Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-03-23 17:43+0000\n"
"PO-Revision-Date: 2014-03-23 17:43+0000\n"
"POT-Creation-Date: 2014-03-23 20:41+0000\n"
"PO-Revision-Date: 2014-03-23 20:41+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -15,11 +15,37 @@ msgstr ""
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Plural-Forms: \n" "Plural-Forms: \n"
#. module: auth_admin_passkey
#: code:addons/auth_admin_passkey/model/res_users.py:66
#, python-format
msgid "<pre>User with login '%s' has the same password as you.</pre>"
msgstr ""
#. module: auth_admin_passkey
#: code:addons/auth_admin_passkey/model/res_users.py:44
#, python-format
msgid "Admin user used his passkey to login with '%s'.\n"
"\n"
"\n"
"\n"
"Technicals informations belows : \n"
"\n"
"- Login date : %s\n"
"\n"
""
msgstr ""
#. module: auth_admin_passkey #. module: auth_admin_passkey
#: view:base.config.settings:0 #: view:base.config.settings:0
msgid "Passkey" msgid "Passkey"
msgstr "" msgstr ""
#. module: auth_admin_passkey
#: code:addons/auth_admin_passkey/model/res_users.py:42
#, python-format
msgid "Passkey used"
msgstr ""
#. module: auth_admin_passkey #. module: auth_admin_passkey
#: field:base.config.settings,auth_admin_passkey_send_to_admin:0 #: field:base.config.settings,auth_admin_passkey_send_to_admin:0
msgid "Send email to admin user." msgid "Send email to admin user."
@ -48,9 +74,8 @@ msgid "When the administrator use his password to login in with a different acco
msgstr "" msgstr ""
#. module: auth_admin_passkey #. module: auth_admin_passkey
#: code:_description:0
#: model:ir.model,name:auth_admin_passkey.model_base_config_settings
#: code:addons/auth_admin_passkey/model/res_users.py:64
#, python-format #, python-format
msgid "base.config.settings"
msgid "[WARNING] OpenERP Security Risk"
msgstr "" msgstr ""

58
auth_admin_passkey/i18n/fr.po

@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n" "Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-03-17 12:04+0000\n"
"PO-Revision-Date: 2014-03-17 12:04+0000\n"
"POT-Creation-Date: 2014-03-23 20:38+0000\n"
"PO-Revision-Date: 2014-03-23 20:38+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -15,16 +15,62 @@ msgstr ""
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Plural-Forms: \n" "Plural-Forms: \n"
#. module: auth_admin_passkey
#: code:addons/auth_admin_passkey/model/res_users.py:66
#, python-format
msgid "<pre>User with login '%s' has the same password as you.</pre>"
msgstr "<pre>L'utilisateur dont l'identifiant est '%s' a le même mot de passe que vous.</pre>"
#. module: auth_admin_passkey
#: code:addons/auth_admin_passkey/model/res_users.py:44
#, python-format
msgid "Admin user used his passkey to login with '%s'.\n"
"\n"
"\n"
"\n"
"Technicals informations belows : \n"
"\n"
"- Login date : %s\n"
"\n"
""
msgstr "L'administrateur a utilisé son mot de passe bris de glace pour s'identifier avec l'identifiant '%s'.\n"
"\n"
"\n"
"\n"
"Informations techniques ci-dessous : \n"
"\n"
"- Date d'authentification : %s\n"
"\n"
""
#. module: auth_admin_passkey #. module: auth_admin_passkey
#: view:base.config.settings:0 #: view:base.config.settings:0
msgid "Passkey" msgid "Passkey"
msgstr "Mot de passe bris de glace" msgstr "Mot de passe bris de glace"
#. module: auth_admin_passkey
#: code:addons/auth_admin_passkey/model/res_users.py:42
#, python-format
msgid "Passkey used"
msgstr "Mot de passe bris de glace utilisé"
#. module: auth_admin_passkey #. module: auth_admin_passkey
#: field:base.config.settings,auth_admin_passkey_send_to_admin:0 #: field:base.config.settings,auth_admin_passkey_send_to_admin:0
msgid "Send email to admin user." msgid "Send email to admin user."
msgstr "Envoyer un email à l'administrateur." msgstr "Envoyer un email à l'administrateur."
#. module: auth_admin_passkey
#: field:base.config.settings,auth_admin_passkey_send_to_user:0
msgid "Send email to user."
msgstr "Envoyer un email à l'utilisateur."
#. module: auth_admin_passkey
#: code:_description:0
#: model:ir.model,name:auth_admin_passkey.model_res_users
#, python-format
msgid "Users"
msgstr "Utilisateurs"
#. module: auth_admin_passkey #. module: auth_admin_passkey
#: help:base.config.settings,auth_admin_passkey_send_to_user:0 #: help:base.config.settings,auth_admin_passkey_send_to_user:0
msgid "When the administrator use his password to login in with a different account, OpenERP will send an email to the account user." msgid "When the administrator use his password to login in with a different account, OpenERP will send an email to the account user."
@ -36,7 +82,7 @@ msgid "When the administrator use his password to login in with a different acco
msgstr "Quand l'administrateur utilise son mot de passe pour s'authentifier avec un compte différent, OpenERP enverra un mail à l'utilisateur." msgstr "Quand l'administrateur utilise son mot de passe pour s'authentifier avec un compte différent, OpenERP enverra un mail à l'utilisateur."
#. module: auth_admin_passkey #. module: auth_admin_passkey
#: field:base.config.settings,auth_admin_passkey_send_to_user:0
msgid "Send email to user."
msgstr "Envoyer un email à l'utilisateur."
#: code:addons/auth_admin_passkey/model/res_users.py:64
#, python-format
msgid "[WARNING] OpenERP Security Risk"
msgstr "[WARNING] Faille de sécurité sur OpenERP"

45
auth_admin_passkey/model/res_users.py

@ -10,14 +10,20 @@ from openerp import SUPERUSER_ID
from openerp import pooler from openerp import pooler
from openerp import exceptions from openerp import exceptions
from openerp.osv.orm import Model from openerp.osv.orm import Model
from openerp.tools.translate import _
class res_users(Model): class res_users(Model):
_inherit = "res.users" _inherit = "res.users"
### Private Function section ### Private Function section
def _get_translation(self, cr, lang, text):
context = {'lang': lang}
return _(text)
def _send_email_passkey(self, cr, user_id, user_agent_env): def _send_email_passkey(self, cr, user_id, user_agent_env):
""" Send a email to the admin of the system and / or the user """ Send a email to the admin of the system and / or the user
to inform passkey use """ to inform passkey use """
mails = []
mail_obj = self.pool.get('mail.mail') mail_obj = self.pool.get('mail.mail')
icp_obj = self.pool.get('ir.config_parameter') icp_obj = self.pool.get('ir.config_parameter')
admin_user = self.browse(cr, SUPERUSER_ID, SUPERUSER_ID) admin_user = self.browse(cr, SUPERUSER_ID, SUPERUSER_ID)
@ -26,21 +32,24 @@ class res_users(Model):
'auth_admin_passkey.send_to_admin', 'True')) 'auth_admin_passkey.send_to_admin', 'True'))
send_to_user = literal_eval(icp_obj.get_param(cr, SUPERUSER_ID, send_to_user = literal_eval(icp_obj.get_param(cr, SUPERUSER_ID,
'auth_admin_passkey.send_to_user', 'True')) 'auth_admin_passkey.send_to_user', 'True'))
emails_to = []
if send_to_admin and admin_user.email:
emails_to.append(admin_user.email)
if send_to_admin and admin_user.email:
mails.append({'email': admin_user.email, 'lang': admin_user.lang,})
if send_to_user and login_user.email: if send_to_user and login_user.email:
emails_to.append(login_user.email)
if emails_to:
body = "Admin user used his passkey to login with '%s'.\n\n" %(login_user.login)
body += "\n\nTechnicals informations belows : \n\n"
body += "- Login date : %s\n\n" %(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
for key, value in user_agent_env.iteritems():
body +=("- %s : %s\n\n") % (key, value)
for email_to in emails_to:
mail_obj.create(cr, SUPERUSER_ID, {
'email_to': email_to,
'subject': "Passkey used",
mails.append({'email': login_user.email, 'lang': login_user.lang,})
for mail in mails:
subject = self._get_translation(cr, mail['lang'], _('Passkey used'))
body = self._get_translation(cr, mail['lang'],
_("""Admin user used his passkey to login with '%s'.\n\n"""\
"""\n\nTechnicals informations belows : \n\n"""\
"""- Login date : %s\n\n""")) %(login_user.login,
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
for k, v in user_agent_env.iteritems():
body +=("- %s : %s\n\n") % (k, v)
mail_obj.create(cr, SUPERUSER_ID, {
'email_to': mail['email'],
'subject': subject,
'body_html': '<pre>%s</pre>' % body}) 'body_html': '<pre>%s</pre>' % body})
def _send_email_same_password(self, cr, login_user): def _send_email_same_password(self, cr, login_user):
@ -51,9 +60,11 @@ class res_users(Model):
if admin_user.email: if admin_user.email:
mail_obj.create(cr, SUPERUSER_ID, { mail_obj.create(cr, SUPERUSER_ID, {
'email_to': admin_user.email, 'email_to': admin_user.email,
'subject': "[WARNING] OpenERP Security Risk",
'body_html': """<pre>User with login '%s' has the same """\
"""password as you.</pre>""" %(login_user)
'subject': self._get_translation(cr, admin_user.lang,
_('[WARNING] OpenERP Security Risk')),
'body_html': self._get_translation(cr, admin_user.lang,
_("""<pre>User with login '%s' has the same """\
"""password as you.</pre>""")) %(login_user),
}) })
### Overload Section ### Overload Section

Loading…
Cancel
Save