mail.py: fonction pour enregistrer une validation
This commit is contained in:
parent
47811e378a
commit
45eb0bbd02
1 changed files with 27 additions and 3 deletions
|
@ -4,17 +4,20 @@
|
|||
import os
|
||||
import jinja2
|
||||
import sys
|
||||
import json
|
||||
import inspect
|
||||
|
||||
from email.header import Header
|
||||
from email.message import Message
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.Utils import formatdate
|
||||
from markdown import markdown
|
||||
import inspect
|
||||
|
||||
sys.path.append('/usr/scripts/')
|
||||
if '/usr/scripts' not in sys.path:
|
||||
sys.path.append('/usr/scripts')
|
||||
from gestion.email_tools import format_sender
|
||||
sys.path.pop()
|
||||
from gestion import secrets_new as secrets
|
||||
|
||||
default_language = 'fr'
|
||||
template_path = '/usr/scripts/gestion/mail/template/'
|
||||
|
@ -108,3 +111,24 @@ def generate(mail, params, lang=default_language, lang_fallback=default_language
|
|||
msg['Date']=formatdate(localtime=True)
|
||||
|
||||
return msg
|
||||
|
||||
|
||||
def validation_url(view_name, data='', debug=False):
|
||||
"""Enregistre une nouvelle url pour le module "validation" de l'intranet."""
|
||||
import requests
|
||||
if debug:
|
||||
CA = False
|
||||
ROOT = 'https://intranet-dev.crans.org'
|
||||
else:
|
||||
CA = '/etc/ssl/certs/cacert.org.pem'
|
||||
ROOT = 'https://intranet2.crans.org'
|
||||
url = ROOT + '/validation/register/%s/' % view_name
|
||||
payload = {
|
||||
'data': json.dumps(data),
|
||||
'shared_secret': secrets.get('validation'),
|
||||
}
|
||||
req = requests.post(url, payload, verify=CA)
|
||||
if req.status_code != 200:
|
||||
raise Exception('Bad code status %d' % req.status_code)
|
||||
|
||||
return ROOT + req.text.encode('utf-8')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue