Commit 631b0c2c authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Merge branch 'feature/old-member-supporter-registration' into 'master'

Make it possible for previous members to prolong their benefactorship

Closes #684

See merge request !954
parents 4c972b52 2d665e72
......@@ -7,19 +7,24 @@
<h1>{% trans "renewal" %}</h1>
<p class="tcenter">
{% blocktrans trimmed %}
A membership costs € {{ year_fees }} per year, or € {{ study_fees }} for your entire study duration.<br/>
Note: Only Computing Science and Information Sciences students at the Radboud University can become a member.<br/><br/>
It is still possible to be associated with Thalia, even if you do not study Computing Science or Information Sciences (anymore): You can become a supporter. For at least € {{ year_fees }} per year, you too can enjoy everything Thalia has to offer.
{% endblocktrans %}
{% blocktrans trimmed %}
A membership costs € {{ year_fees }} per year, or € {{ study_fees }} for your entire study duration.<br/>
Note: Only Computing Science and Information Sciences students at the Radboud University can become a member.<br/>
<br/>
It is still possible to be associated with Thalia, even if you do not study Computing Science or Information
Sciences (anymore): You can become a supporter. For at least € {{ year_fees }} per year, you too can enjoy
everything Thalia has to offer.
{% endblocktrans %}
</p>
<p class="tcenter">
{% blocktrans trimmed %}
Are you currently paying per year for your membership? During the lecture year you're allowed to change your membership to one for your entire study duration without paying a double fee.
Choose 'until graduation' option in the form below and click send. Just make you currently have an active membership.<br/><br/>
If your membership is almost expiring or has expired you can renew it starting one month before expiration.
{% endblocktrans %}
{% blocktrans trimmed %}
Are you currently paying per year for your membership? During the lecture year you're allowed to change your
membership to one for your entire study duration without paying a double fee.
Choose 'until graduation' option in the form below and click send. Just make you currently have an active
membership.<br/><br/>
If your membership is almost expiring or has expired you can renew it starting one month before expiration.
{% endblocktrans %}
</p>
<hr/>
......@@ -36,55 +41,73 @@
<hr/>
{% if membership is None %}
<p class="tcenter">
{% blocktrans trimmed %}
We do not have any previous memberships in our system. Contact the board to renew your membership.
{% endblocktrans %}
</p>
<p class="tcenter">
{% blocktrans trimmed %}
We do not have any previous memberships in our system. Contact the board to renew your membership.
{% endblocktrans %}
</p>
{% elif membership.type == 'honorary' %}
<p class="tcenter">
{% blocktrans trimmed %}
You're a honorary member. That means that you never have to renew your membership.
{% endblocktrans %}
</p>
{% elif membership.type == 'supporter' %}
<p class="tcenter">
{% blocktrans trimmed %}
You're a supporter. Contact the board to renew your membership.
{% endblocktrans %}
</p>
<p class="tcenter">
{% blocktrans trimmed %}
You're a honorary member. That means that you never have to renew your membership.
{% endblocktrans %}
</p>
{% elif membership.type == 'supporter' and not was_member %}
<p class="tcenter">
{% blocktrans trimmed %}
You're a supporter. Contact the board to renew your membership.
{% endblocktrans %}
</p>
{% elif membership.until is None %}
<p class="tcenter">
{% blocktrans trimmed %}
You currently have an active membership for your entire study duration.<br/>
Did you graduate or stop with your studies for some other reason?<br/>
Please let us know by sending an email to info@thalia.nu.
{% endblocktrans %}
</p>
<p class="tcenter">
{% blocktrans trimmed %}
You currently have an active membership for your entire study duration.<br/>
Did you graduate or stop with your studies for some other reason?<br/>
Please let us know by sending an email to info@thalia.nu.
{% endblocktrans %}
</p>
{% else %}
{% for error in form.errors.items %}
{% for message in error.1 %}
<div class="alert alert-error">
{{ message }}
<button type="button" class="close"><span class="alert-icon-close"></span></button>
</div>
{% for error in form.errors.items %}
{% for message in error.1 %}
<div class="alert alert-error">
{{ message }}
<button type="button" class="close"><span class="alert-icon-close"></span></button>
</div>
{% endfor %}
{% endfor %}
{% endfor %}
<form method="post" enctype="multipart/form-data" class="form-horizontal span8 offset2">
{% csrf_token %}
<form method="post" enctype="multipart/form-data" class="form-horizontal span8 offset2">
{% csrf_token %}
{% form_field form 'length' %}
{% if not membership.type == 'supporter' %}
{% form_field form 'membership_type' %}
{% form_field form 'length' %}
{% else %}
<div class="control-group row">
<label class="control-label" for="id_membership_type">{% trans 'membership type'|capfirst %}:</label>
<div class="controls">
<input type="text" readonly disabled value="{% trans 'Supporter' %}"/>
</div>
</div>
<div class="control-group row">
<label class="control-label" for="id_membership_length">{% trans 'membership length'|capfirst %}</label>
<div class="controls">
<input type="text" readonly disabled value="{% trans 'One year' %}"/>
</div>
</div>
{% endif %}
<div class="control-group row">
<div class="controls">
<label class="checkbox">
<input type="checkbox" name="privacy_policy" required="" id="id_privacy_policy">
{% blocktrans trimmed %}I accept the <a target="_blank" href="{{ privacy_policy_url }}">privacy policy</a>{% endblocktrans %}.
</label>
<div class="control-group row">
<div class="controls">
<label class="checkbox">
<input type="checkbox" name="privacy_policy" required="" id="id_privacy_policy">
{% blocktrans trimmed %}
I accept the <a target="_blank" href="{{ privacy_policy_url }}">privacy policy</a>
{% endblocktrans %}.
</label>
</div>
</div>
</div>
<input type="submit" value="{% trans 'send'|capfirst %}" class="btn btn-style1 pull-right login" />
</form>
<input type="submit" value="{% trans 'send'|capfirst %}" class="btn btn-style1 pull-right login"/>
</form>
{% endif %}
{% endblock %}
......@@ -5,7 +5,7 @@ from django.contrib.auth import get_user_model
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.http import HttpRequest, HttpResponse
from django.http import HttpRequest, HttpResponse, QueryDict
from django.template.defaultfilters import floatformat
from django.test import Client, TestCase
from django.urls import reverse
......@@ -425,28 +425,35 @@ class RenewalFormViewTest(TestCase):
)
self.view.request = MagicMock()
context = self.view.get_context_data(form=MagicMock())
self.assertEqual(len(context), 7)
self.assertEqual(context['year_fees'], floatformat(
settings.MEMBERSHIP_PRICES[Entry.MEMBERSHIP_YEAR], 2))
self.assertEqual(context['study_fees'], floatformat(
settings.MEMBERSHIP_PRICES[Entry.MEMBERSHIP_STUDY], 2))
with mock.patch('members.models.Membership.objects') as qs_mock:
Membership.objects.filter().exists.return_value = True
context = self.view.get_context_data(form=MagicMock())
self.assertEqual(len(context), 8)
self.assertEqual(context['year_fees'], floatformat(
settings.MEMBERSHIP_PRICES[Entry.MEMBERSHIP_YEAR], 2))
self.assertEqual(context['study_fees'], floatformat(
settings.MEMBERSHIP_PRICES[Entry.MEMBERSHIP_STUDY], 2))
self.assertEqual(context['was_member'], True)
Membership.objects.filter().exists.return_value = False
context = self.view.get_context_data(form=MagicMock())
self.assertEqual(context['was_member'], False)
with self.subTest("With latest membership"):
self.view.request.member.latest_membership = membership
with self.subTest("With latest membership"):
self.view.request.member.latest_membership = membership
context = self.view.get_context_data(form=MagicMock())
self.assertEqual(context['membership'], membership)
self.assertEqual(context['membership_type'], _('Member'))
self.assertEqual(context['privacy_policy_url'],
reverse('privacy-policy'))
context = self.view.get_context_data(form=MagicMock())
self.assertEqual(context['membership'], membership)
self.assertEqual(context['membership_type'], _('Member'))
self.assertEqual(context['privacy_policy_url'],
reverse('privacy-policy'))
with self.subTest('Without latest membership'):
self.view.request.member.latest_membership = None
with self.subTest('Without latest membership'):
self.view.request.member.latest_membership = None
context = self.view.get_context_data(form=MagicMock())
self.assertEqual(context['membership'], None)
self.assertFalse('membership_type' in context)
context = self.view.get_context_data(form=MagicMock())
self.assertEqual(context['membership'], None)
self.assertFalse('membership_type' in context)
def test_get_form(self):
self.view.request = _get_mock_request()
......@@ -479,14 +486,32 @@ class RenewalFormViewTest(TestCase):
@mock.patch('django.views.generic.FormView.post')
def test_post(self, super_post):
request = _get_mock_request()
request.member = MagicMock()
request.member.pk = 2
request.member.latest_membership = Membership(
until=timezone.now().date(),
type=Membership.MEMBER
)
self.view.request = request
self.view.post(request)
with self.subTest('Member type'):
request.POST = QueryDict()
request.member.latest_membership.type = Membership.MEMBER
self.view.post(request)
request = super_post.call_args[0][0]
self.assertEqual(request.POST['member'], 2)
self.assertEqual(request.POST['membership_type'], Membership.MEMBER)
request = super_post.call_args[0][0]
self.assertEqual(request.POST['member'], 2)
self.assertFalse('membership_type' in request.POST)
with self.subTest('Benefactor type'):
request.POST = QueryDict()
request.member.latest_membership.type = Membership.SUPPORTER
self.view.post(request)
request = super_post.call_args[0][0]
self.assertEqual(request.POST['member'], 2)
self.assertEqual(request.POST['membership_type'], Membership.SUPPORTER)
self.assertEqual(request.POST['length'], Entry.MEMBERSHIP_YEAR)
@mock.patch('registrations.emails.send_new_renewal_board_message')
def test_form_valid(self, board_mail):
......
......@@ -154,6 +154,8 @@ class RenewalFormView(FormView):
context['study_fees'] = floatformat(settings.MEMBERSHIP_PRICES[
Entry.MEMBERSHIP_STUDY], 2)
context['membership'] = self.request.member.latest_membership
context['was_member'] = (Membership.objects.filter(user=self.request.member,
type=Membership.MEMBER).exists())
if context['membership'] is not None:
context['membership_type'] = (context['membership']
.get_type_display())
......@@ -182,8 +184,10 @@ class RenewalFormView(FormView):
def post(self, request, *args, **kwargs):
request.POST = request.POST.dict()
if request.member.latest_membership.type == Membership.SUPPORTER:
request.POST['membership_type'] = Membership.SUPPORTER
request.POST['length'] = Entry.MEMBERSHIP_YEAR
request.POST['member'] = request.member.pk
request.POST['membership_type'] = Membership.MEMBER
return super().post(request, *args, **kwargs)
def form_valid(self, form):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment