Add associate membership registration
This commit is contained in:
parent
1e3ff7475a
commit
ff29819ca1
29
ssmembership/jinja2/ssmembership/signup/complete.html
Normal file
29
ssmembership/jinja2/ssmembership/signup/complete.html
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{% extends 'ssmain/base.html' %}
|
||||||
|
|
||||||
|
{#
|
||||||
|
Society Self-Service
|
||||||
|
Copyright © 2018-2019 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
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#}
|
||||||
|
|
||||||
|
{% block title %}Subscription complete{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Subscription complete</h1>
|
||||||
|
|
||||||
|
<p>Your associate membership and email subscription have been successfully processed.</p>
|
||||||
|
|
||||||
|
<p>You can view and edit your membership details by <a href="{{ url('membership') }}">logging in</a>.</p>
|
||||||
|
{% endblock %}
|
114
ssmembership/jinja2/ssmembership/signup/index.html
Normal file
114
ssmembership/jinja2/ssmembership/signup/index.html
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
{% extends 'ssmain/base.html' %}
|
||||||
|
|
||||||
|
{#
|
||||||
|
Society Self-Service
|
||||||
|
Copyright © 2018-2019 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
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#}
|
||||||
|
|
||||||
|
{% block title %}Subscribe to {{ settings.ORG_NAME }} Mail{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Subscribe to {{ settings.ORG_NAME }} Mail</h1>
|
||||||
|
|
||||||
|
<p>To become an associate member of {{ settings.ORG_NAME }} and subscribe to {{ settings.ORG_NAME }} Mail, please enter your details below:</p>
|
||||||
|
|
||||||
|
<form class="ui form" method="POST" action="{{ url('signup_save') }}">
|
||||||
|
{% if errors %}
|
||||||
|
<div class="ui visible error message"><ul>
|
||||||
|
{% for error in errors %}
|
||||||
|
<li>{{ error }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul></div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="ui required inline grid field">
|
||||||
|
<label class="three wide column">Student ID</label>
|
||||||
|
<input class="nine wide column" type="text" name="student_id" value="{{ member.student_id }}">
|
||||||
|
</div>
|
||||||
|
<div class="ui required inline grid field">
|
||||||
|
<label class="three wide column">Student email</label>
|
||||||
|
<input class="nine wide column" type="text" name="email" value="{{ member.email }}">
|
||||||
|
</div>
|
||||||
|
<div class="ui divider"></div>
|
||||||
|
<div class="ui required inline grid field">
|
||||||
|
<label class="three wide column">First name</label>
|
||||||
|
<input class="nine wide column" type="text" name="first_name" value="{{ member.first_name }}">
|
||||||
|
</div>
|
||||||
|
<div class="ui required inline grid field">
|
||||||
|
<label class="three wide column">Last name</label>
|
||||||
|
<input class="nine wide column" type="text" name="last_name" value="{{ member.last_name }}">
|
||||||
|
</div>
|
||||||
|
<div class="ui required inline grid field">
|
||||||
|
<label class="three wide column">Phone number</label>
|
||||||
|
<input class="nine wide column" type="text" name="phone" value="{{ member.phone }}">
|
||||||
|
</div>
|
||||||
|
<div class="ui divider"></div>
|
||||||
|
<div class="ui required inline grid field">
|
||||||
|
<label class="three wide column">Year level</label>
|
||||||
|
<select id="drop_year" class="ui dropdown eleven wide column" name="year">
|
||||||
|
<option value="">Year level</option>
|
||||||
|
{% for year in years %}
|
||||||
|
<option value="{{ year[0] }}">{{ year[1] }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="ui required inline grid field">
|
||||||
|
<label class="three wide column">MSA membership</label>
|
||||||
|
<select id="drop_msa" class="ui dropdown eleven wide column" name="is_msa">
|
||||||
|
<option value="">MSA membership</option>
|
||||||
|
<option value="0">No, I am not an MSA member</option>
|
||||||
|
<option value="1">Yes, I am an MSA member</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="ui divider"></div>
|
||||||
|
<h2>MUMUS Mail</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 send me MUMUS Mail (not recommended)</option>
|
||||||
|
<option value="1" selected>Keep me updated with MUMUS Mail</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;">MUMUS Mail is personalised for you. Choose the groups that you would like to see first in each edition of MUMUS Mail.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ui divider"></div>
|
||||||
|
<input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
|
||||||
|
<input class="ui primary button" type="submit" name='submit' value="Subscribe">
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block script %}
|
||||||
|
{{ super() }}
|
||||||
|
<script>
|
||||||
|
$('.ui.dropdown').dropdown();
|
||||||
|
$('#drop_year').dropdown('set selected', '{{ member.year }}');
|
||||||
|
$('#drop_msa').dropdown('set selected', '{{ 1 if member.is_msa else 0 }}');
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
@ -24,4 +24,6 @@ urlpatterns = [
|
|||||||
path('onboard/signed', views.onboard_signed, name='monboard_signed'),
|
path('onboard/signed', views.onboard_signed, name='monboard_signed'),
|
||||||
path('onboard/search', views.onboard_search, name='monboard_search'),
|
path('onboard/search', views.onboard_search, name='monboard_search'),
|
||||||
path('onboard/save', views.onboard_save, name='monboard_save'),
|
path('onboard/save', views.onboard_save, name='monboard_save'),
|
||||||
|
path('signup/', views.signup_index, name='signup_index'),
|
||||||
|
path('signup/save', views.signup_save, name='signup_save'),
|
||||||
]
|
]
|
||||||
|
@ -23,6 +23,7 @@ from django.db import transaction
|
|||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from . import monboard
|
from . import monboard
|
||||||
from . import models
|
from . import models
|
||||||
@ -159,3 +160,55 @@ def onboard_save(request):
|
|||||||
|
|
||||||
monboard.delete_by_email(request.POST['email_orig'])
|
monboard.delete_by_email(request.POST['email_orig'])
|
||||||
return render(request, 'ssmembership/onboard/complete.html')
|
return render(request, 'ssmembership/onboard/complete.html')
|
||||||
|
|
||||||
|
def signup_index(request):
|
||||||
|
return render(request, 'ssmembership/signup/index.html', {
|
||||||
|
'member': models.Member(),
|
||||||
|
'years': models.Member.YEARS
|
||||||
|
})
|
||||||
|
|
||||||
|
def signup_save(request):
|
||||||
|
if request.method != 'POST':
|
||||||
|
return redirect(reverse('signup_index'))
|
||||||
|
|
||||||
|
member = models.Member()
|
||||||
|
member.student_id = request.POST['student_id']
|
||||||
|
member.email = request.POST['email']
|
||||||
|
member.first_name = request.POST['first_name']
|
||||||
|
member.last_name = request.POST['last_name']
|
||||||
|
member.phone = request.POST['phone']
|
||||||
|
member.year = int(request.POST['year'])
|
||||||
|
member.is_msa = True if request.POST['is_msa'] == '1' else '0'
|
||||||
|
member.member_type = 2 # Associate Member
|
||||||
|
|
||||||
|
# Calculate expiration date
|
||||||
|
member.expires = timezone.now().date().replace(month=3, day=20)
|
||||||
|
member.expires = member.expires.replace(year=member.expires.year+1)
|
||||||
|
if member.expires < timezone.now().date(): # Add 1 year if after Mar 20, else add 2 years
|
||||||
|
member.expires = member.expires.replace(year=member.expires.year+1)
|
||||||
|
|
||||||
|
errors = member.validation_problems()
|
||||||
|
|
||||||
|
if models.Member.objects.filter(email=request.POST['email']).count() > 0:
|
||||||
|
errors.append('Member with this email already exists')
|
||||||
|
|
||||||
|
if len(errors) > 0:
|
||||||
|
return render(request, 'ssmembership/signup/index.html', {
|
||||||
|
'member': member,
|
||||||
|
'years': models.Member.YEARS,
|
||||||
|
'errors': errors
|
||||||
|
})
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
return render(request, 'ssmembership/signup/complete.html')
|
||||||
|
Loading…
Reference in New Issue
Block a user