mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-11 04:19:25 +00:00
Avoid unothorised customer to buy in counter by modifying url
This commit is contained in:
@ -6,7 +6,7 @@ from django.core.urlresolvers import reverse
|
||||
from django.forms import ValidationError
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
|
||||
from datetime import timedelta
|
||||
from datetime import timedelta, date
|
||||
import random
|
||||
import string
|
||||
import os
|
||||
@ -35,6 +35,11 @@ class Customer(models.Model):
|
||||
def __str__(self):
|
||||
return "%s - %s" % (self.user.username, self.account_id)
|
||||
|
||||
@property
|
||||
def can_buy(self):
|
||||
return (self.user.subscriptions.last() and
|
||||
(date.today() - self.user.subscriptions.last().subscription_end) < timedelta(days=90))
|
||||
|
||||
def generate_account_id(number):
|
||||
number = str(number)
|
||||
letter = random.choice(string.ascii_lowercase)
|
||||
|
Reference in New Issue
Block a user