# -*- coding: utf8 -*- from pyramid.response import Response from pyramid.renderers import render, get_renderer from pyramid.view import ( view_config, forbidden_view_config, ) from pyramid.security import ( authenticated_userid, remember, forget, ) from pyramid.httpexceptions import ( HTTPFound, HTTPNotFound, HTTPForbidden, ) from pyramid_mailer import get_mailer from pyramid_mailer.message import Message, Attachment from datetime import * import hashlib from sqlalchemy.exc import DBAPIError from ..security import groupfinder import json def to_decimal(x): import decimal return decimal.Decimal(str(x)) def to_euro(x): """Takes a float and returns a string""" #if x == 0: # return "" #else: return (u"%.2f €" % x).replace('.', ',') def to_int(x): try: number = int(x.replace(',', '.')) return number except ValueError: return 0 def to_percent(x): """Takes a float and returns a string""" return (u"%.2f " % x).replace('.', ',') + "%" @view_config(route_name='home', renderer='../templates/home.pt', permission='view') def home(request): return { 'page_title': 'Bienvenue', 'project': 'mondumas', } def envoyerMail(request, destinataire, objet, corps): body = u""" %s Cordialement, gestion.entreprise-dumas.com """ % (corps) message = Message(subject=u"[Ent. Dumas] %s" % objet, sender=request.registry.settings['mondumas.admin_email'], body=body) message.add_recipient(destinataire) mailer = get_mailer(request) mailer.send_immediately(message)