Free subscription for jewels

This commit is contained in:
2017-08-21 21:29:33 +02:00
parent 02b317eee8
commit 94582a2d96
3 changed files with 114 additions and 5 deletions

View File

@ -104,6 +104,7 @@ class Subscription(models.Model):
'sbarro/esta': 9,
'cursus-alternant': 10,
'welcome-semestre': 11,
'un-mois': 12,
}
PAYMENT = {
"CHECK": 1,
@ -168,11 +169,11 @@ class Subscription(models.Model):
start = Subscription.compute_start(duration=duration)
# This can certainly be simplified, but it works like this
try:
return start.replace(month=(start.month - 1 + 6 * duration) % 12 + 1,
year=start.year + int(duration / 2) + (1 if start.month > 6 and duration % 2 == 1 else 0))
return start.replace(month=int((start.month - 1 + 6 * duration) % 12 + 1),
year=int(start.year + int(duration / 2) + (1 if start.month > 6 and duration % 2 == 1 else 0)))
except ValueError as e:
return start.replace(day=1, month=(start.month + 6 * duration) % 12 + 1,
year=start.year + int(duration / 2) + (1 if start.month > 6 and duration % 2 == 1 else 0))
return start.replace(day=1, month=int((start.month + 6 * duration) % 12 + 1),
year=int(start.year + int(duration / 2) + (1 if start.month > 6 and duration % 2 == 1 else 0)))
def can_be_edited_by(self, user):
return user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user.is_root