Commit 13785fd5 authored by Skia's avatar Skia 🤘
Browse files

Prevent users that have never subscribed to subscribe on Eboutic

parent 4edd5354
Pipeline #564 passed with stage
in 2 minutes and 25 seconds
...@@ -346,10 +346,11 @@ class Selling(models.Model): ...@@ -346,10 +346,11 @@ 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
u = User.objects.filter(id=self.customer.user.id).first()
if u.was_subscribed():
if self.product and self.product.id == settings.SITH_PRODUCT_SUBSCRIPTION_ONE_SEMESTER: if self.product and self.product.id == settings.SITH_PRODUCT_SUBSCRIPTION_ONE_SEMESTER:
s = User.objects.filter(id=self.customer.user.id).first()
sub = Subscription( sub = Subscription(
member=s, member=u,
subscription_type='un-semestre', subscription_type='un-semestre',
payment_method="EBOUTIC", payment_method="EBOUTIC",
location="EBOUTIC", location="EBOUTIC",
...@@ -362,9 +363,9 @@ class Selling(models.Model): ...@@ -362,9 +363,9 @@ class Selling(models.Model):
start=sub.subscription_start) start=sub.subscription_start)
sub.save() sub.save()
elif self.product and self.product.id == settings.SITH_PRODUCT_SUBSCRIPTION_TWO_SEMESTERS: elif self.product and self.product.id == settings.SITH_PRODUCT_SUBSCRIPTION_TWO_SEMESTERS:
s = User.objects.filter(id=self.customer.user.id).first() u = User.objects.filter(id=self.customer.user.id).first()
sub = Subscription( sub = Subscription(
member=s, member=u,
subscription_type='deux-semestres', subscription_type='deux-semestres',
payment_method="EBOUTIC", payment_method="EBOUTIC",
location="EBOUTIC", location="EBOUTIC",
......
...@@ -78,6 +78,8 @@ class EbouticMain(TemplateView): ...@@ -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 ...@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment