Skip to content

Commit

Permalink
Merge pull request #2485 from Jorrre/fix/extend-membership-expriation…
Browse files Browse the repository at this point in the history
…-date

Ensure new expiration date isn't in the past when applying for a membership extension
  • Loading branch information
blauks authored Aug 19, 2020
2 parents 92b652d + 5c0466d commit d9b0611
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions apps/approval/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from apps.approval.forms import FieldOfStudyApplicationForm
from apps.approval.models import MembershipApproval
from apps.authentication.models import Membership, get_length_of_membership
from apps.authentication.models import get_length_of_membership


@login_required
Expand Down Expand Up @@ -116,9 +116,14 @@ def create_membership_application(request):
)
return redirect("profiles_active", active_tab="membership")

# Extend length of membership by 1 year
membership = Membership.objects.get(username=request.user.ntnu_username)
new_expiration_date = datetime.date(membership.expiration_date.year + 1, 9, 16)
# Grant membership until 16th of September this year if the request was sent previous to 1st of July,
# or until 16th of September next year if the request was sent after 1st of July
if timezone.now().date().month < 7:
new_expiration_date = datetime.date(timezone.now().year, 9, 16)
else:
new_expiration_date = datetime.date(
timezone.now().year, 9, 16
) + datetime.timedelta(days=365)

application = MembershipApproval(
applicant=request.user,
Expand Down

0 comments on commit d9b0611

Please sign in to comment.