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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python2.7
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 from collections import namedtuple
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
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
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
12
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 log = getLogger(__name__)
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14
6
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
15 name = "association_membership"
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
16 template = "association/membership.html"
0
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 FIELDS = (
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 'name',
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
20 'firstname',
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 'address',
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 'email',
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 'jid',
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 'subscription',
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 'reference',
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 'comment',
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 'mailing_list',
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 'documents_read',
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 )
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 REQUIRED = ('name', 'firstname', 'address', 'email', 'subscription')
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 FormData = namedtuple("FormData", FIELDS)
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
32
6
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
33 SUBJECT_ADMIN = D_("New subscription to the association")
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
34 BODY_ADMIN = D_("""\
0
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 New subscription received:
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
36
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 {fields_list}""").format(
6
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
38 fields_list="\n".join("- {0}: {{{0}}}".format(f) for f in FIELDS)
0
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 )
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
40
6
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
41 SUBJECT = D_("Your association membership request")
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
42 BODY = D_("""\
0
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 Hello {firstname},
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
44
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 you request to join the "Salut à Toi" association has been well received.
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 Thank you and welcome to the SàT community.
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
47
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 You can contact us at contact"""
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 # we split the address to avoid
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 # it being recognized too easily by spam bots
6
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
51 + '@' + 'salut-a-toi' + '.org'
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
52 """
0
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 or on the official XMPP chat room:
23
395af2ad2bc9 update MUC links
Goffi <goffi@goffi.org>
parents: 22
diff changeset
54 xmpp: libervia@chat.jabberfr.org
395af2ad2bc9 update MUC links
Goffi <goffi@goffi.org>
parents: 22
diff changeset
55 web: https://chat.jabberfr.org/converse.js/libervia@chat.jabberfr.org
0
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
56
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 The Salut à Toi team
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 """)
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
59
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 WARNING_MSG_NOT_READ = D_(
6
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
61 "You must have read the documents to validate your membership request")
0
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 WARNING_MSG_MISSING_FIELDS = D_(
6
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
63 "The form you posted is not complete, we can't validate this membership request.\n"
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
64 "Please fill all the required fields, thank you!")
0
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
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
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 if any(not getattr(data, f) for f in REQUIRED):
6
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
69 log.warning("missing data fields:\n{data}".format(data=data))
0
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 raise exceptions.DataError(WARNING_MSG_MISSING_FIELDS)
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 if not C.bool(data.documents_read or C.BOOL_FALSE):
6
9ce41ef66dfa python 3 port
Goffi <goffi@goffi.org>
parents: 0
diff changeset
72 log.warning("documents_read has not been checked:\n{data}".format(data=data))
0
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
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
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
75 self.host.main_conf,
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 None,
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
77 "email_admins_list",
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
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
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 self.host.main_conf,
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 addresses,
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 SUBJECT_ADMIN,
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 BODY_ADMIN.format(**data._asdict()),
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
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
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 self.host.main_conf,
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 data.email,
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
88 SUBJECT,
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 BODY.format(**data._asdict()),
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 )
09d66acc7c73 initial commit, website first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
91