Mercurial > libervia-website
view pages/association/membership/page_meta.py @ 33:2f0a33b117d3
presentation: docker image are available again
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 11 Dec 2023 01:12:33 +0100 |
parents | e7c7327f9f25 |
children |
line wrap: on
line source
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- from collections import namedtuple from twisted.internet import defer from libervia.web.server.constants import Const as C from libervia.backend.core.i18n import D_ from libervia.backend.tools import config from libervia.backend.tools.common import email from libervia.backend.core import exceptions from libervia.backend.core.log import getLogger log = getLogger(__name__) name = "association_membership" template = "association/membership.html" FIELDS = ( 'name', 'firstname', 'address', 'email', 'jid', 'subscription', 'reference', 'comment', 'mailing_list', 'documents_read', ) REQUIRED = ('name', 'firstname', 'address', 'email', 'subscription') FormData = namedtuple("FormData", FIELDS) SUBJECT_ADMIN = D_("New subscription to the association") BODY_ADMIN = D_("""\ New subscription received: {fields_list}""").format( fields_list="\n".join("- {0}: {{{0}}}".format(f) for f in FIELDS) ) SUBJECT = D_("Your association membership request") BODY = D_("""\ Hello {firstname}, you request to join the "Salut à Toi" association has been well received. Thank you and welcome to the SàT community. You can contact us at contact""" # we split the address to avoid # it being recognized too easily by spam bots + '@' + 'salut-a-toi' + '.org' """ or on the official XMPP chat room: xmpp: libervia@chat.jabberfr.org web: https://chat.jabberfr.org/converse.js/libervia@chat.jabberfr.org The Salut à Toi team """) WARNING_MSG_NOT_READ = D_( "You must have read the documents to validate your membership request") WARNING_MSG_MISSING_FIELDS = D_( "The form you posted is not complete, we can't validate this membership request.\n" "Please fill all the required fields, thank you!") async def on_data_post(self, request): data = FormData(*self.get_posted_data(request, FIELDS, raise_on_missing=False)) if any(not getattr(data, f) for f in REQUIRED): log.warning("missing data fields:\n{data}".format(data=data)) raise exceptions.DataError(WARNING_MSG_MISSING_FIELDS) if not C.bool(data.documents_read or C.BOOL_FALSE): log.warning("documents_read has not been checked:\n{data}".format(data=data)) raise exceptions.DataError(WARNING_MSG_NOT_READ) addresses = config.config_get( self.host.main_conf, None, "email_admins_list", default=Exception) await email.send_email( self.host.main_conf, addresses, SUBJECT_ADMIN, BODY_ADMIN.format(**data._asdict()), ) await email.send_email( self.host.main_conf, data.email, SUBJECT, BODY.format(**data._asdict()), )