Integrate membership renewal with bulletin

This commit is contained in:
Yingtong Li 2019-01-26 17:22:54 +11:00
parent 3dfea0f8a0
commit 59b9bddd8a
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 36 additions and 0 deletions

View File

@ -67,6 +67,32 @@
</select>
</div>
<div class="ui divider"></div>
<h2>Bulletin subscriptions</h2>
<div class="ui required inline grid field">
<label class="three wide column">Opt-in/out</label>
<select id="drop_bulletin_subscribe" class="ui dropdown eleven wide column" name="bulletin_subscribe">
<option value="0">Do not email me the MUMUS Bulletin</option>
<option value="1" selected>Email me the weekly MUMUS Bulletin</option>
</select>
</div>
<div class="ui inline grid field">
<label class="three wide column">Subscriptions</label>
<div class="eleven wide column">
{% for group in import('sspromotions.models').Group.objects.all() %}
{% if group.subscribable %}
<div class="field" style="display: inline; margin-right: 1em;">
<div class="ui checkbox">
<input type="checkbox" name="bulletin_group_{{ group.id }}" id="bulletin_group_{{ group.id }}">
<label for="bulletin_group_{{ group.id }}">{{ group.name }}</label>
</div>
</div>
{% endif %}
{% endfor %}
<p style="margin-top: 0.5em;">The MUMUS Bulletin is now personalised. Choose the groups that you would like to see first in your weekly email bulletin.</p>
</div>
</div>
<div class="ui divider"></div>
{% if errors %}
<div class="ui visible error message"><ul>
{% for error in errors %}

View File

@ -142,6 +142,16 @@ def import_save(request):
with transaction.atomic():
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)
mimport.delete_by_email(request.POST['email_orig'])
return render(request, 'ssmembership/import/complete.html')