Mercurial > libervia-website
annotate 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 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/env python2.7 |
2 # -*- coding: utf-8 -*- | |
3 | |
4 from collections import namedtuple | |
5 from twisted.internet import defer | |
28
e7c7327f9f25
refactoring: fix imports and names in doc following modules hierarchy refactoring
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
6 from libervia.web.server.constants import Const as C |
e7c7327f9f25
refactoring: fix imports and names in doc following modules hierarchy refactoring
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
7 from libervia.backend.core.i18n import D_ |
e7c7327f9f25
refactoring: fix imports and names in doc following modules hierarchy refactoring
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
8 from libervia.backend.tools import config |
e7c7327f9f25
refactoring: fix imports and names in doc following modules hierarchy refactoring
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
9 from libervia.backend.tools.common import email |
e7c7327f9f25
refactoring: fix imports and names in doc following modules hierarchy refactoring
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
10 from libervia.backend.core import exceptions |
e7c7327f9f25
refactoring: fix imports and names in doc following modules hierarchy refactoring
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
11 from libervia.backend.core.log import getLogger |
0 | 12 |
13 log = getLogger(__name__) | |
14 | |
6 | 15 name = "association_membership" |
16 template = "association/membership.html" | |
0 | 17 |
18 FIELDS = ( | |
19 'name', | |
20 'firstname', | |
21 'address', | |
22 'email', | |
23 'jid', | |
24 'subscription', | |
25 'reference', | |
26 'comment', | |
27 'mailing_list', | |
28 'documents_read', | |
29 ) | |
30 REQUIRED = ('name', 'firstname', 'address', 'email', 'subscription') | |
31 FormData = namedtuple("FormData", FIELDS) | |
32 | |
6 | 33 SUBJECT_ADMIN = D_("New subscription to the association") |
34 BODY_ADMIN = D_("""\ | |
0 | 35 New subscription received: |
36 | |
37 {fields_list}""").format( | |
6 | 38 fields_list="\n".join("- {0}: {{{0}}}".format(f) for f in FIELDS) |
0 | 39 ) |
40 | |
6 | 41 SUBJECT = D_("Your association membership request") |
42 BODY = D_("""\ | |
0 | 43 Hello {firstname}, |
44 | |
45 you request to join the "Salut à Toi" association has been well received. | |
46 Thank you and welcome to the SàT community. | |
47 | |
48 You can contact us at contact""" | |
49 # we split the address to avoid | |
50 # it being recognized too easily by spam bots | |
6 | 51 + '@' + 'salut-a-toi' + '.org' |
52 """ | |
0 | 53 or on the official XMPP chat room: |
23 | 54 xmpp: libervia@chat.jabberfr.org |
55 web: https://chat.jabberfr.org/converse.js/libervia@chat.jabberfr.org | |
0 | 56 |
57 The Salut à Toi team | |
58 """) | |
59 | |
60 WARNING_MSG_NOT_READ = D_( | |
6 | 61 "You must have read the documents to validate your membership request") |
0 | 62 WARNING_MSG_MISSING_FIELDS = D_( |
6 | 63 "The form you posted is not complete, we can't validate this membership request.\n" |
64 "Please fill all the required fields, thank you!") | |
0 | 65 |
21
67487063f421
fix membership following changes with new theme
Goffi <goffi@goffi.org>
parents:
6
diff
changeset
|
66 async def on_data_post(self, request): |
22
5fd933e238bb
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
21
diff
changeset
|
67 data = FormData(*self.get_posted_data(request, FIELDS, raise_on_missing=False)) |
0 | 68 if any(not getattr(data, f) for f in REQUIRED): |
6 | 69 log.warning("missing data fields:\n{data}".format(data=data)) |
0 | 70 raise exceptions.DataError(WARNING_MSG_MISSING_FIELDS) |
71 if not C.bool(data.documents_read or C.BOOL_FALSE): | |
6 | 72 log.warning("documents_read has not been checked:\n{data}".format(data=data)) |
0 | 73 raise exceptions.DataError(WARNING_MSG_NOT_READ) |
22
5fd933e238bb
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
21
diff
changeset
|
74 addresses = config.config_get( |
0 | 75 self.host.main_conf, |
76 None, | |
77 "email_admins_list", | |
78 default=Exception) | |
22
5fd933e238bb
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
21
diff
changeset
|
79 await email.send_email( |
0 | 80 self.host.main_conf, |
81 addresses, | |
82 SUBJECT_ADMIN, | |
83 BODY_ADMIN.format(**data._asdict()), | |
84 ) | |
22
5fd933e238bb
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
21
diff
changeset
|
85 await email.send_email( |
0 | 86 self.host.main_conf, |
87 data.email, | |
88 SUBJECT, | |
89 BODY.format(**data._asdict()), | |
90 ) | |
91 |