From 5059c5f79356ec666c1a3e9d497656303d7df8a1 Mon Sep 17 00:00:00 2001 From: Yingtong Li Date: Tue, 1 Mar 2022 19:10:17 +1100 Subject: [PATCH] Membership renewal when promotions module is disabled --- .../jinja2/ssmembership/renew/review.html | 54 ++++++++++--------- .../jinja2/ssmembership/signup/index.html | 54 ++++++++++--------- ssmembership/views.py | 32 +++++------ 3 files changed, 73 insertions(+), 67 deletions(-) diff --git a/ssmembership/jinja2/ssmembership/renew/review.html b/ssmembership/jinja2/ssmembership/renew/review.html index ecdd011..1248170 100644 --- a/ssmembership/jinja2/ssmembership/renew/review.html +++ b/ssmembership/jinja2/ssmembership/renew/review.html @@ -2,7 +2,7 @@ {# Society Self-Service - Copyright © 2018-2020 Yingtong Li (RunasSudo) + Copyright © 2018-2022 Yingtong Li (RunasSudo) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -79,32 +79,34 @@ -
-

MUMUS Mail

- -
- - -
-
- -
- {% for group in import('sspromotions.models').Group.objects.all() %} - {% if group.subscribable %} -
-
- - -
-
- {% endif %} - {% endfor %} -

MUMUS Mail is personalised for you. Choose the groups that you would like to see first in each edition of MUMUS Mail.

+ {% if 'sspromotions' in settings.INSTALLED_APPS %} +
+

MUMUS Mail

+ +
+ +
-
+
+ +
+ {% for group in import('sspromotions.models').Group.objects.all() %} + {% if group.subscribable %} +
+
+ + +
+
+ {% endif %} + {% endfor %} +

MUMUS Mail is personalised for you. Choose the groups that you would like to see first in each edition of MUMUS Mail.

+
+
+ {% endif %}
diff --git a/ssmembership/jinja2/ssmembership/signup/index.html b/ssmembership/jinja2/ssmembership/signup/index.html index 09701e7..969a630 100644 --- a/ssmembership/jinja2/ssmembership/signup/index.html +++ b/ssmembership/jinja2/ssmembership/signup/index.html @@ -2,7 +2,7 @@ {# Society Self-Service - Copyright © 2018-2019 Yingtong Li (RunasSudo) + Copyright © 2018-2022 Yingtong Li (RunasSudo) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -72,32 +72,34 @@
-
-

MUMUS Mail

- -
- - -
-
- -
- {% for group in import('sspromotions.models').Group.objects.all() %} - {% if group.subscribable %} -
-
- - -
-
- {% endif %} - {% endfor %} -

MUMUS Mail is personalised for you. Choose the groups that you would like to see first in each edition of MUMUS Mail.

+ {% if 'sspromotions' in settings.INSTALLED_APPS %} +
+

MUMUS Mail

+ +
+ +
-
+
+ +
+ {% for group in import('sspromotions.models').Group.objects.all() %} + {% if group.subscribable %} +
+
+ + +
+
+ {% endif %} + {% endfor %} +

MUMUS Mail is personalised for you. Choose the groups that you would like to see first in each edition of MUMUS Mail.

+
+
+ {% endif %}
diff --git a/ssmembership/views.py b/ssmembership/views.py index 8924ad5..5b60ee3 100644 --- a/ssmembership/views.py +++ b/ssmembership/views.py @@ -1,5 +1,5 @@ # Society Self-Service -# Copyright © 2018-2020 Yingtong Li (RunasSudo) +# Copyright © 2018-2022 Yingtong Li (RunasSudo) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -157,13 +157,14 @@ def renew_save(request): member.save() # Update bulletin - import sspromotions.models - sspromotions.models.BulletinSubscription.set_member_subscribed(member, True if request.POST['bulletin_subscribe'] == '1' else False) - for group in sspromotions.models.Group.objects.filter(subscribable=True).all(): - if ('bulletin_group_' + str(group.id)) in request.POST and request.POST['bulletin_group_' + str(group.id)]: - group.subscribe_member(member, True) - else: - group.subscribe_member(member, False) + if 'sspromotions' in settings.INSTALLED_APPS: + import sspromotions.models + sspromotions.models.BulletinSubscription.set_member_subscribed(member, True if request.POST['bulletin_subscribe'] == '1' else False) + for group in sspromotions.models.Group.objects.filter(subscribable=True).all(): + if ('bulletin_group_' + str(group.id)) in request.POST and request.POST['bulletin_group_' + str(group.id)]: + group.subscribe_member(member, True) + else: + group.subscribe_member(member, False) return render(request, 'ssmembership/renew/complete.html') @@ -209,12 +210,13 @@ def signup_save(request): member.save() # Update bulletin - import sspromotions.models - sspromotions.models.BulletinSubscription.set_member_subscribed(member, True if request.POST['bulletin_subscribe'] == '1' else False) - for group in sspromotions.models.Group.objects.filter(subscribable=True).all(): - if ('bulletin_group_' + str(group.id)) in request.POST and request.POST['bulletin_group_' + str(group.id)]: - group.subscribe_member(member, True) - else: - group.subscribe_member(member, False) + if 'sspromotions' in settings.INSTALLED_APPS: + import sspromotions.models + sspromotions.models.BulletinSubscription.set_member_subscribed(member, True if request.POST['bulletin_subscribe'] == '1' else False) + for group in sspromotions.models.Group.objects.filter(subscribable=True).all(): + if ('bulletin_group_' + str(group.id)) in request.POST and request.POST['bulletin_group_' + str(group.id)]: + group.subscribe_member(member, True) + else: + group.subscribe_member(member, False) return render(request, 'ssmembership/signup/complete.html')