mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 06:03:20 +00:00
Prevent users that have never subscribed to subscribe on Eboutic
This commit is contained in:
parent
4edd535460
commit
13785fd520
@ -346,36 +346,37 @@ class Selling(models.Model):
|
|||||||
self.customer.amount -= self.quantity * self.unit_price
|
self.customer.amount -= self.quantity * self.unit_price
|
||||||
self.customer.save()
|
self.customer.save()
|
||||||
self.is_validated = True
|
self.is_validated = True
|
||||||
if self.product and self.product.id == settings.SITH_PRODUCT_SUBSCRIPTION_ONE_SEMESTER:
|
u = User.objects.filter(id=self.customer.user.id).first()
|
||||||
s = User.objects.filter(id=self.customer.user.id).first()
|
if u.was_subscribed():
|
||||||
sub = Subscription(
|
if self.product and self.product.id == settings.SITH_PRODUCT_SUBSCRIPTION_ONE_SEMESTER:
|
||||||
member=s,
|
sub = Subscription(
|
||||||
subscription_type='un-semestre',
|
member=u,
|
||||||
payment_method="EBOUTIC",
|
subscription_type='un-semestre',
|
||||||
location="EBOUTIC",
|
payment_method="EBOUTIC",
|
||||||
)
|
location="EBOUTIC",
|
||||||
sub.subscription_start = Subscription.compute_start()
|
)
|
||||||
sub.subscription_start = Subscription.compute_start(
|
sub.subscription_start = Subscription.compute_start()
|
||||||
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'])
|
sub.subscription_start = Subscription.compute_start(
|
||||||
sub.subscription_end = Subscription.compute_end(
|
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'])
|
||||||
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'],
|
sub.subscription_end = Subscription.compute_end(
|
||||||
start=sub.subscription_start)
|
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'],
|
||||||
sub.save()
|
start=sub.subscription_start)
|
||||||
elif self.product and self.product.id == settings.SITH_PRODUCT_SUBSCRIPTION_TWO_SEMESTERS:
|
sub.save()
|
||||||
s = User.objects.filter(id=self.customer.user.id).first()
|
elif self.product and self.product.id == settings.SITH_PRODUCT_SUBSCRIPTION_TWO_SEMESTERS:
|
||||||
sub = Subscription(
|
u = User.objects.filter(id=self.customer.user.id).first()
|
||||||
member=s,
|
sub = Subscription(
|
||||||
subscription_type='deux-semestres',
|
member=u,
|
||||||
payment_method="EBOUTIC",
|
subscription_type='deux-semestres',
|
||||||
location="EBOUTIC",
|
payment_method="EBOUTIC",
|
||||||
)
|
location="EBOUTIC",
|
||||||
sub.subscription_start = Subscription.compute_start()
|
)
|
||||||
sub.subscription_start = Subscription.compute_start(
|
sub.subscription_start = Subscription.compute_start()
|
||||||
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'])
|
sub.subscription_start = Subscription.compute_start(
|
||||||
sub.subscription_end = Subscription.compute_end(
|
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'])
|
||||||
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'],
|
sub.subscription_end = Subscription.compute_end(
|
||||||
start=sub.subscription_start)
|
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'],
|
||||||
sub.save()
|
start=sub.subscription_start)
|
||||||
|
sub.save()
|
||||||
try:
|
try:
|
||||||
if self.product.eticket:
|
if self.product.eticket:
|
||||||
self.send_mail_customer()
|
self.send_mail_customer()
|
||||||
|
@ -78,6 +78,8 @@ class EbouticMain(TemplateView):
|
|||||||
kwargs['basket'] = self.basket
|
kwargs['basket'] = self.basket
|
||||||
kwargs['eboutic'] = Counter.objects.filter(type="EBOUTIC").first()
|
kwargs['eboutic'] = Counter.objects.filter(type="EBOUTIC").first()
|
||||||
kwargs['categories'] = ProductType.objects.all()
|
kwargs['categories'] = ProductType.objects.all()
|
||||||
|
if not self.request.user.was_subscribed():
|
||||||
|
kwargs['categories'] = kwargs['categories'].exclude(id=settings.SITH_PRODUCTTYPE_SUBSCRIPTION)
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
class EbouticCommand(TemplateView):
|
class EbouticCommand(TemplateView):
|
||||||
|
@ -332,6 +332,7 @@ SITH_COUNTER_PRODUCTTYPE_REFILLING = 11
|
|||||||
# Defines which product is the one year subscription and which one is the six month subscription
|
# Defines which product is the one year subscription and which one is the six month subscription
|
||||||
SITH_PRODUCT_SUBSCRIPTION_ONE_SEMESTER = 93
|
SITH_PRODUCT_SUBSCRIPTION_ONE_SEMESTER = 93
|
||||||
SITH_PRODUCT_SUBSCRIPTION_TWO_SEMESTERS = 94
|
SITH_PRODUCT_SUBSCRIPTION_TWO_SEMESTERS = 94
|
||||||
|
SITH_PRODUCTTYPE_SUBSCRIPTION = 23
|
||||||
|
|
||||||
# Subscription durations are in semestres
|
# Subscription durations are in semestres
|
||||||
# Be careful, modifying this parameter will need a migration to be applied
|
# Be careful, modifying this parameter will need a migration to be applied
|
||||||
|
Loading…
Reference in New Issue
Block a user