diff --git a/website/registrations/forms.py b/website/registrations/forms.py index e3602906c..792ee57a8 100644 --- a/website/registrations/forms.py +++ b/website/registrations/forms.py @@ -243,6 +243,7 @@ def clean(self): if ( self.cleaned_data["member"].latest_membership and self.cleaned_data["member"].latest_membership.study_long + and self.cleaned_data["membership_type"] != Membership.BENEFACTOR ): raise ValidationError("It's not possible to renew a study long membership.") diff --git a/website/registrations/services.py b/website/registrations/services.py index 783515b64..7d539af1c 100644 --- a/website/registrations/services.py +++ b/website/registrations/services.py @@ -254,12 +254,12 @@ def complete_renewal(renewal: Renewal): latest_membership = member.latest_membership current_membership = member.current_membership - if (latest_membership and latest_membership.study_long) or ( - current_membership - and (current_membership.study_long or current_membership.until is None) - and not renewal.membership_type == Membership.BENEFACTOR - ): - raise ValueError("This member already has a never ending membership") + if ( + latest_membership + and latest_membership.study_long + and renewal.membership_type != Membership.BENEFACTOR + ) or (current_membership and current_membership.until is None): + raise ValueError("This member already has a never ending membership.") until = timezone.datetime(year=lecture_year + 1, month=9, day=1).date() with transaction.atomic(): if renewal.length == Renewal.MEMBERSHIP_STUDY: diff --git a/website/registrations/templates/registrations/renewal.html b/website/registrations/templates/registrations/renewal.html index 360ab5988..7d1e14fcd 100644 --- a/website/registrations/templates/registrations/renewal.html +++ b/website/registrations/templates/registrations/renewal.html @@ -129,11 +129,6 @@

{% trans "Membership history" %}

have to renew your membership. {% endblocktrans %}

- {% elif latest_membership.study_long %} -

- You seem to be on the wrong page for your membership type. - follow this link to renew your membership. -

{% elif not request.member.profile.is_minimized %} {% for error in form.errors.items %} {% for message in error.1 %} @@ -144,11 +139,19 @@

{% trans "Membership history" %}

data-benefactor-type="{{ benefactor_type }}"> {% csrf_token %}
- {% if not latest_membership.type == 'benefactor' %} + {% if not latest_membership.type == 'benefactor' and not latest_membership.study_long %} {% bootstrap_field form.membership_type %} {% bootstrap_field form.length %} {% bootstrap_field form.contribution form_group_class='form-row required-field d-none' %} {% else %} + {% if latest_membership.study_long %} +
+
+ You seem to have a membership which you can freely extend until the end of your studies. If you are still studying Computing Science/Information Sience, click this link to extend your membership for free. Otherwise continue with the form below to become benefactor. +
+
+ {% endif %} +
diff --git a/website/registrations/tests/test_views.py b/website/registrations/tests/test_views.py index 4d50c4694..6c28bfd71 100644 --- a/website/registrations/tests/test_views.py +++ b/website/registrations/tests/test_views.py @@ -466,8 +466,8 @@ def test_post(self, super_post): request.member = MagicMock() request.member.pk = 2 self.view.request = request + request.member.latest_membership.study_long = False - request.member.latest_membership.type = Membership.MEMBER self.view.post(request) request = super_post.call_args[0][0] diff --git a/website/registrations/views.py b/website/registrations/views.py index bcd6d0051..ca2c3c837 100644 --- a/website/registrations/views.py +++ b/website/registrations/views.py @@ -12,7 +12,9 @@ from django.views import View from django.views.generic import CreateView, FormView from django.views.generic.base import TemplateResponseMixin, TemplateView + from django_ratelimit.decorators import ratelimit + from members.decorators import membership_required from members.models import Membership @@ -289,7 +291,10 @@ def get_form(self, form_class=None): def post(self, request, *args, **kwargs): request.POST = request.POST.dict() - if request.member.latest_membership.type == Membership.BENEFACTOR: + if ( + request.member.latest_membership.type == Membership.BENEFACTOR + or request.member.latest_membership.study_long + ): request.POST["membership_type"] = Membership.BENEFACTOR request.POST["length"] = Entry.MEMBERSHIP_YEAR request.POST["member"] = request.member.pk