Browse Source

Add invitations for general assembly and bar camp 2018

Markus Lorenz 1 year ago
parent
commit
cd29c5e8bb

+ 2
- 0
CHANGES.rst View File

@@ -8,6 +8,8 @@ Next Release
8 8
 
9 9
 - Show error message if applicant is younger than 18 years old.
10 10
 
11
+- Invitations for general assembly and bar camp 2018.
12
+
11 13
 
12 14
 
13 15
 1.20.4

+ 27
- 0
alembic/versions/34c421bb0d0c_invitations_ga_bc_2018.py View File

@@ -0,0 +1,27 @@
1
+"""Invitations for general assembly and bar camp 2018
2
+
3
+Revision ID: 34c421bb0d0c
4
+Revises: 2fbe1bde5df8
5
+Create Date: 2018-04-23 20:03:17.014936
6
+
7
+"""
8
+
9
+# revision identifiers, used by Alembic.
10
+revision = '34c421bb0d0c'
11
+down_revision = '2fbe1bde5df8'
12
+
13
+from alembic import op
14
+import sqlalchemy as sa
15
+
16
+
17
+def upgrade():
18
+    op.add_column('members', sa.Column('email_invite_date_bcgv18', sa.DateTime(), nullable=True))
19
+    op.add_column('members', sa.Column('email_invite_flag_bcgv18', sa.Boolean(), nullable=True))
20
+    op.add_column('members', sa.Column('email_invite_token_bcgv18', sa.Unicode(length=255), nullable=True))
21
+
22
+
23
+def downgrade():
24
+    with op.batch_alter_table('members') as batch_op:
25
+        batch_op.drop_column('email_invite_token_bcgv18')
26
+        batch_op.drop_column('email_invite_flag_bcgv18')
27
+        batch_op.drop_column('email_invite_date_bcgv18')

+ 14
- 13
c3smembership/invite_members.py View File

@@ -16,6 +16,7 @@ It was then reused for:
16 16
 - BarCamp and General Assembly 2015
17 17
 - BarCamp and General Assembly 2016
18 18
 - BarCamp and General Assembly 2017
19
+- BarCamp and General Assembly 2018
19 20
 
20 21
 How it works
21 22
 ------------
@@ -43,7 +44,7 @@ from pyramid.httpexceptions import HTTPFound
43 44
 from pyramid.view import view_config
44 45
 from pyramid_mailer.message import Message
45 46
 
46
-from c3smembership.invite_members_texts import make_bcga17_invitation_email
47
+from c3smembership.invite_members_texts import make_bcga18_invitation_email
47 48
 from c3smembership.mail_utils import send_message
48 49
 from c3smembership.membership_certificate import make_random_token
49 50
 from c3smembership.models import C3sMember
@@ -82,16 +83,16 @@ def invite_member_bcgv(request):
82 83
         return get_memberhip_listing_redirect(request, member_id)
83 84
 
84 85
     # prepare a random token iff none is set
85
-    if member.email_invite_token_bcgv17 is None:
86
-        member.email_invite_token_bcgv17 = make_random_token()
86
+    if member.email_invite_token_bcgv18 is None:
87
+        member.email_invite_token_bcgv18 = make_random_token()
87 88
     url = URL_PATTERN.format(
88 89
         ticketing_url=request.registry.settings['ticketing.url'],
89
-        token=member.email_invite_token_bcgv17,
90
+        token=member.email_invite_token_bcgv18,
90 91
         email=member.email)
91 92
 
92 93
     LOG.info("mailing event invitation to to member id %s", member.id)
93 94
 
94
-    email_subject, email_body = make_bcga17_invitation_email(member, url)
95
+    email_subject, email_body = make_bcga18_invitation_email(member, url)
95 96
     message = Message(
96 97
         subject=email_subject,
97 98
         sender='yes@c3s.cc',
@@ -104,8 +105,8 @@ def invite_member_bcgv(request):
104 105
     send_message(request, message)
105 106
 
106 107
     # member._token = _looong_token
107
-    member.email_invite_flag_bcgv17 = True
108
-    member.email_invite_date_bcgv17 = datetime.now()
108
+    member.email_invite_flag_bcgv18 = True
109
+    member.email_invite_date_bcgv18 = datetime.now()
109 110
     return get_memberhip_listing_redirect(request, member.id)
110 111
 
111 112
 
@@ -146,16 +147,16 @@ def batch_invite(request):
146 147
 
147 148
     for member in invitees:
148 149
         # prepare a random token iff none is set
149
-        if member.email_invite_token_bcgv17 is None:
150
-            member.email_invite_token_bcgv17 = make_random_token()
150
+        if member.email_invite_token_bcgv18 is None:
151
+            member.email_invite_token_bcgv18 = make_random_token()
151 152
         url = URL_PATTERN.format(
152 153
             ticketing_url=request.registry.settings['ticketing.url'],
153
-            token=member.email_invite_token_bcgv17,
154
+            token=member.email_invite_token_bcgv18,
154 155
             email=member.email)
155 156
 
156 157
         LOG.info("mailing event invitation to to member id %s", member.id)
157 158
 
158
-        email_subject, email_body = make_bcga17_invitation_email(member, url)
159
+        email_subject, email_body = make_bcga18_invitation_email(member, url)
159 160
         message = Message(
160 161
             subject=email_subject,
161 162
             sender='yes@c3s.cc',
@@ -167,8 +168,8 @@ def batch_invite(request):
167 168
         )
168 169
         send_message(request, message)
169 170
 
170
-        member.email_invite_flag_bcgv17 = True
171
-        member.email_invite_date_bcgv17 = datetime.now()
171
+        member.email_invite_flag_bcgv18 = True
172
+        member.email_invite_date_bcgv18 = datetime.now()
172 173
         num_sent += 1
173 174
         ids_sent.append(member.id)
174 175
 

+ 5
- 5
c3smembership/invite_members_texts.py View File

@@ -11,7 +11,7 @@ from c3smembership.mail_utils import (
11 11
 DEBUG = False
12 12
 
13 13
 
14
-def make_bcga17_invitation_email(member, url):
14
+def make_bcga18_invitation_email(member, url):
15 15
     """
16 16
     Create email subject and body for an invitation email for members.
17 17
 
@@ -23,18 +23,18 @@ def make_bcga17_invitation_email(member, url):
23 23
         print(u"the member.locale: {}".format(member.locale))
24 24
         print(u"the url: {}".format(url))
25 25
         print(u"the subject: {}".format(
26
-            get_template_text('bcga2017_invite_subject', member.locale)))
26
+            get_template_text('bcga2018_invite_subject', member.locale)))
27 27
         print(u"the salutation: {}".format(get_salutation(member)))
28 28
         print(u"the footer: {}".format(get_email_footer(member.locale)))
29 29
         print(u"the body: {}".format(
30
-            get_template_text('bcga2017_invite_body', member.locale).format(
30
+            get_template_text('bcga2018_invite_body', member.locale).format(
31 31
                 salutation=get_salutation(member),
32 32
                 invitation_url=url,
33 33
                 footer=get_email_footer(member.locale))))
34 34
     return (
35
-        get_template_text('bcga2017_invite_subject', member.locale).rstrip(
35
+        get_template_text('bcga2018_invite_subject', member.locale).rstrip(
36 36
             '\n'),  # remove newline (\n) from mail subject
37
-        get_template_text('bcga2017_invite_body', member.locale).format(
37
+        get_template_text('bcga2018_invite_body', member.locale).format(
38 38
             salutation=get_salutation(member),
39 39
             invitation_url=url,
40 40
             footer=get_email_footer(member.locale)

+ 7
- 4
c3smembership/models.py View File

@@ -597,6 +597,9 @@ class C3sMember(Base):
597 597
     email_invite_flag_bcgv17 = Column(Boolean, default=False)
598 598
     email_invite_date_bcgv17 = Column(DateTime(), default=datetime(1970, 1, 1))
599 599
     email_invite_token_bcgv17 = Column(Unicode(255))
600
+    email_invite_flag_bcgv18 = Column(Boolean, default=False)
601
+    email_invite_date_bcgv18 = Column(DateTime(), default=datetime(1970, 1, 1))
602
+    email_invite_token_bcgv18 = Column(Unicode(255))
600 603
     # legal entities
601 604
     is_legalentity = Column(Boolean, default=False)
602 605
     court_of_law = Column(Unicode(255))
@@ -854,7 +857,7 @@ class C3sMember(Base):
854 857
             object: C3sMember object
855 858
         """
856 859
         return DBSession.query(cls).filter(
857
-            cls.email_invite_token_bcgv17 == token).first()
860
+            cls.email_invite_token_bcgv18 == token).first()
858 861
 
859 862
     @classmethod
860 863
     def check_for_existing_confirm_code(cls, email_confirm_code):
@@ -922,10 +925,10 @@ class C3sMember(Base):
922 925
             and_(
923 926
                 cls.is_member_filter(),
924 927
                 or_(
925
-                    (cls.email_invite_flag_bcgv17 == 0),
926
-                    (cls.email_invite_flag_bcgv17 == ''),
928
+                    (cls.email_invite_flag_bcgv18 == 0),
929
+                    (cls.email_invite_flag_bcgv18 == ''),
927 930
                     # pylint: disable=singleton-comparison
928
-                    (cls.email_invite_flag_bcgv17 == None),
931
+                    (cls.email_invite_flag_bcgv18 == None),
929 932
                 )
930 933
             )
931 934
         ).slice(0, num).all()

+ 3
- 7
c3smembership/presentation/templates/memberships_list_backend.pt View File

@@ -96,12 +96,10 @@
96 96
                  title="Sort by id: descending"
97 97
                  class="glyphicon glyphicon-chevron-down"></a>
98 98
             </th>
99
-            <!--!
100 99
             <th>
101 100
                 bc &amp; ga<br />
102 101
                 invitation
103 102
             </th>
104
-            -->
105 103
             <th>
106 104
                 dues17<br />
107 105
                 invoice
@@ -158,20 +156,18 @@
158 156
                     </a>
159 157
                 </div>
160 158
             </td>
161
-            <!--!
162 159
             <td>
163 160
                 <div tal:condition="member.is_member()" tal:omit-tag="">
164
-                  <a tal:condition="member.email_invite_flag_bcgv17 is not True"
161
+                  <a tal:condition="member.email_invite_flag_bcgv18 is not True"
165 162
                       href="${request.route_url('invite_member', m_id=member.id)}"
166 163
                       title="invitation not sent yet. Click to send!"
167 164
                       class="btn btn-danger"></a>
168
-                  <a tal:condition="member.email_invite_flag_bcgv17 is True"
165
+                  <a tal:condition="member.email_invite_flag_bcgv18 is True"
169 166
                       href="${request.route_url('invite_member', m_id=member.id)}"
170
-                      title="gesendet ${member.email_invite_date_bcgv17.strftime('am %d.%m.%Y um %H:%M')}"
167
+                      title="gesendet ${member.email_invite_date_bcgv18.strftime('am %d.%m.%Y um %H:%M')}"
171 168
                       class="btn btn-success"></a>
172 169
                 </div>
173 170
             </td>
174
-            -->
175 171
             <td>
176 172
                 <div tal:omit-tag="" tal:condition="not member.membership_date > date(2017,12,31) and (member.membership_loss_date is None or member.membership_loss_date >= date(2017,1,1))">
177 173
                     <a tal:condition="member.dues17_invoice is False"

+ 1
- 1
c3smembership/presentation/templates/toolbox.pt View File

@@ -149,7 +149,7 @@
149 149
       </div>
150 150
     </p>
151 151
 
152
-    <h4>Mail Invitations for GA &amp; BC 2017</h4>
152
+    <h4>Mail Invitations for GA &amp; BC 2018</h4>
153 153
     <p>
154 154
       <a href="${request.route_url('invite_batch', number=5)}"
155 155
          title="Note: change number in URL as appropriate! Default is 5."

+ 6
- 0
c3smembership/templates/mail/bcga2018_invite_body_de.txt View File

@@ -0,0 +1,6 @@
1
+
2
+Hallo {salutation},
3
+
4
+  {invitation_url}
5
+
6
+{footer}

+ 6
- 0
c3smembership/templates/mail/bcga2018_invite_body_en.txt View File

@@ -0,0 +1,6 @@
1
+
2
+Hello {salutation},
3
+
4
+  {invitation_url}
5
+
6
+{footer}

+ 1
- 0
c3smembership/templates/mail/bcga2018_invite_subject_de.txt View File

@@ -0,0 +1 @@
1
+[C3S] Einladung zu Barcamp und Generalversammlung

+ 1
- 0
c3smembership/templates/mail/bcga2018_invite_subject_en.txt View File

@@ -0,0 +1 @@
1
+[C3S] Invitation to Barcamp and General Assembly

+ 4
- 4
c3smembership/tests/test_api_views.py View File

@@ -61,7 +61,7 @@ class TestApiViews(unittest.TestCase):
61 61
             )
62 62
         # pylint: disable=no-member
63 63
         DBSession.add(member1)
64
-        member1.email_invite_token_bcgv17 = u'MEMBERS_TOKEN'
64
+        member1.email_invite_token_bcgv18 = u'MEMBERS_TOKEN'
65 65
         # pylint: disable=no-member
66 66
         DBSession.flush()
67 67
 
@@ -112,7 +112,7 @@ class TestApiViews(unittest.TestCase):
112 112
         # now use the correct auth token
113 113
         _auth_info = {'X-messaging-token': 'SECRETAUTHTOKEN'}
114 114
 
115
-        # ..but a non-existing refcode (email_invite_token_bcgv17)
115
+        # ..but a non-existing refcode (email_invite_token_bcgv18)
116 116
         # returns no user (None)
117 117
         res = self.testapp.put_json(
118 118
             '/lm', dict(token='foo'), headers=_auth_info, status=200)
@@ -124,9 +124,9 @@ class TestApiViews(unittest.TestCase):
124 124
 
125 125
         member1 = C3sMember.get_by_id(1)  # load member from DB for crosscheck
126 126
 
127
-        # now try a valid refcode (email_invite_token_bcgv17)
127
+        # now try a valid refcode (email_invite_token_bcgv18)
128 128
         res2 = self.testapp.put_json(
129
-            '/lm', dict(token=member1.email_invite_token_bcgv17),
129
+            '/lm', dict(token=member1.email_invite_token_bcgv18),
130 130
             headers=_auth_info, status=200)
131 131
         self.assertTrue(json.loads(res2.body)['firstname'], member1.firstname)
132 132
         self.assertTrue(json.loads(res2.body)['lastname'], member1.lastname)

+ 17
- 17
c3smembership/tests/test_invite_member.py View File

@@ -160,15 +160,15 @@ class TestInvitation(unittest.TestCase):
160 160
         Test the invitation procedure for one single member at a time.
161 161
 
162 162
         Load this member from the DB,
163
-        assure the email_invite_flag_bcgv17 and token are not set,
163
+        assure the email_invite_flag_bcgv18 and token are not set,
164 164
         prepare cookies, invite this member,
165
-        assure the email_invite_flag_bcgv17 and token are now set,
165
+        assure the email_invite_flag_bcgv18 and token are now set,
166 166
         """
167 167
         from c3smembership.invite_members import invite_member_bcgv
168 168
 
169 169
         member1 = C3sMember.get_by_id(1)
170
-        self.assertEqual(member1.email_invite_flag_bcgv17, False)
171
-        self.assertTrue(member1.email_invite_token_bcgv17 is None)
170
+        self.assertEqual(member1.email_invite_flag_bcgv18, False)
171
+        self.assertTrue(member1.email_invite_token_bcgv18 is None)
172 172
 
173 173
         req = testing.DummyRequest()
174 174
         # have some cookies
@@ -184,8 +184,8 @@ class TestInvitation(unittest.TestCase):
184 184
         req.matchdict = {'m_id': member1.id}
185 185
         res = invite_member_bcgv(req)
186 186
 
187
-        self.assertEqual(member1.email_invite_flag_bcgv17, True)
188
-        self.assertTrue(member1.email_invite_token_bcgv17 is not None)
187
+        self.assertEqual(member1.email_invite_flag_bcgv18, True)
188
+        self.assertTrue(member1.email_invite_token_bcgv18 is not None)
189 189
 
190 190
         # now really send email
191 191
         self.config.registry.settings['testing.mail_to_console'] = 'false'
@@ -199,23 +199,23 @@ class TestInvitation(unittest.TestCase):
199 199
                         in mailer.outbox[1].subject)
200 200
         self.assertTrue(member1.firstname
201 201
                         in mailer.outbox[1].body)
202
-        self.assertTrue(member1.email_invite_token_bcgv17
202
+        self.assertTrue(member1.email_invite_token_bcgv18
203 203
                         in mailer.outbox[1].body)
204 204
 
205 205
         # now send invitation to english member
206 206
         member2 = C3sMember.get_by_id(2)
207
-        self.assertEqual(member2.email_invite_flag_bcgv17, False)
208
-        self.assertTrue(member2.email_invite_token_bcgv17 is None)
207
+        self.assertEqual(member2.email_invite_flag_bcgv18, False)
208
+        self.assertTrue(member2.email_invite_token_bcgv18 is None)
209 209
         req.matchdict = {'m_id': member2.id}
210 210
         res = invite_member_bcgv(req)
211
-        self.assertEqual(member2.email_invite_flag_bcgv17, True)
212
-        self.assertTrue(member2.email_invite_token_bcgv17 is not None)
211
+        self.assertEqual(member2.email_invite_flag_bcgv18, True)
212
+        self.assertTrue(member2.email_invite_token_bcgv18 is not None)
213 213
         self.assertEqual(len(mailer.outbox), 3)
214 214
         self.assertTrue(u'[C3S] Invitation to Barcamp and General Assembly'
215 215
                         in mailer.outbox[2].subject)
216 216
         self.assertTrue(member2.firstname
217 217
                         in mailer.outbox[2].body)
218
-        self.assertTrue(member2.email_invite_token_bcgv17
218
+        self.assertTrue(member2.email_invite_token_bcgv18
219 219
                         in mailer.outbox[2].body)
220 220
 
221 221
     def test_invitation_batch(self):
@@ -226,8 +226,8 @@ class TestInvitation(unittest.TestCase):
226 226
 
227 227
         members = C3sMember.get_all()
228 228
         for member in members:
229
-            self.assertEqual(member.email_invite_flag_bcgv17, False)
230
-            self.assertTrue(member.email_invite_token_bcgv17 is None)
229
+            self.assertEqual(member.email_invite_flag_bcgv18, False)
230
+            self.assertTrue(member.email_invite_token_bcgv18 is None)
231 231
             self.assertTrue(member.membership_accepted is True)
232 232
 
233 233
         req = testing.DummyRequest()
@@ -284,12 +284,12 @@ class TestInvitation(unittest.TestCase):
284 284
 
285 285
         for member in members:
286 286
             # has been invited
287
-            self.assertEqual(member.email_invite_flag_bcgv17, True)
287
+            self.assertEqual(member.email_invite_flag_bcgv18, True)
288 288
             # has a token
289
-            self.assertTrue(member.email_invite_token_bcgv17 is not None)
289
+            self.assertTrue(member.email_invite_token_bcgv18 is not None)
290 290
             # firstname and token are in email body
291 291
             self.assertTrue(
292 292
                 members[member.id - 1].firstname in mailer.outbox[member.id - 1].body)
293 293
             self.assertTrue(
294
-                members[member.id - 1].email_invite_token_bcgv17 in mailer.outbox[
294
+                members[member.id - 1].email_invite_token_bcgv18 in mailer.outbox[
295 295
                     member.id - 1].body)

+ 3
- 3
c3smembership/tests/test_models.py View File

@@ -191,17 +191,17 @@ class C3sMembershipModelTests(C3sMembershipModelTestBase):
191 191
 
192 192
     def test_get_by_bcgvtoken(self):
193 193
         """
194
-        test: get one entry by bcgv17 token
194
+        test: get one entry by bcgv18 token
195 195
         """
196 196
         instance = self._make_one()
197 197
         self.session.add(instance)
198
-        instance.email_invite_token_bcgv17 = u'SHINY_TOKEN'
198
+        instance.email_invite_token_bcgv18 = u'SHINY_TOKEN'
199 199
         instance_from_db = self._get_target_class().get_by_bcgvtoken(
200 200
             u'SHINY_TOKEN')
201 201
         self.assertEqual(instance_from_db.firstname, u'SomeFirstnäme')
202 202
         self.assertEqual(instance_from_db.email, u'some@shri.de')
203 203
         self.assertEqual(
204
-            instance_from_db.email_invite_token_bcgv17, u'SHINY_TOKEN')
204
+            instance_from_db.email_invite_token_bcgv18, u'SHINY_TOKEN')
205 205
 
206 206
     def test_get_by_dues15_token(self):
207 207
         """

Loading…
Cancel
Save