Commit 976ae09e authored by Skia's avatar Skia
Browse files

Fix subscriptions with Sith account

parent 4503fae2
Pipeline #189 failed with stage
in 1 minute and 57 seconds
...@@ -12,7 +12,7 @@ import string ...@@ -12,7 +12,7 @@ import string
from club.models import Club from club.models import Club
from accounting.models import CurrencyField from accounting.models import CurrencyField
from core.models import Group, User from core.models import Group, User
from subscription.models import Subscriber from subscription.models import Subscriber, Subscription
from subscription.views import get_subscriber from subscription.views import get_subscriber
class Customer(models.Model): class Customer(models.Model):
...@@ -269,6 +269,36 @@ class Selling(models.Model): ...@@ -269,6 +269,36 @@ 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.id == settings.SITH_PRODUCT_SUBSCRIPTION_ONE_SEMESTER:
s = Subscriber.objects.filter(id=self.customer.user.id).first()
sub = Subscription(
member=s,
subscription_type='un-semestre',
payment_method="EBOUTIC",
location="EBOUTIC",
)
sub.subscription_start = Subscription.compute_start()
sub.subscription_start = Subscription.compute_start(
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'])
sub.subscription_end = Subscription.compute_end(
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'],
start=sub.subscription_start)
sub.save()
elif self.product.id == settings.SITH_PRODUCT_SUBSCRIPTION_TWO_SEMESTERS:
s = Subscriber.objects.filter(id=self.customer.user.id).first()
sub = Subscription(
member=s,
subscription_type='deux-semestres',
payment_method="EBOUTIC",
location="EBOUTIC",
)
sub.subscription_start = Subscription.compute_start()
sub.subscription_start = Subscription.compute_start(
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'])
sub.subscription_end = Subscription.compute_end(
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'],
start=sub.subscription_start)
sub.save()
super(Selling, self).save(*args, **kwargs) super(Selling, self).save(*args, **kwargs)
class Permanency(models.Model): class Permanency(models.Model):
......
...@@ -93,36 +93,6 @@ class Invoice(models.Model): ...@@ -93,36 +93,6 @@ class Invoice(models.Model):
date=self.date, date=self.date,
) )
new.save() new.save()
if i.product_id == settings.SITH_PRODUCT_SUBSCRIPTION_ONE_SEMESTER:
s = Subscriber.objects.filter(id=self.user.id).first()
sub = Subscription(
member=s,
subscription_type='un-semestre',
payment_method="EBOUTIC",
location="EBOUTIC",
)
sub.subscription_start = Subscription.compute_start()
sub.subscription_start = Subscription.compute_start(
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'])
sub.subscription_end = Subscription.compute_end(
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'],
start=sub.subscription_start)
sub.save()
elif i.product_id == settings.SITH_PRODUCT_SUBSCRIPTION_TWO_SEMESTERS:
s = Subscriber.objects.filter(id=self.user.id).first()
sub = Subscription(
member=s,
subscription_type='deux-semestres',
payment_method="EBOUTIC",
location="EBOUTIC",
)
sub.subscription_start = Subscription.compute_start()
sub.subscription_start = Subscription.compute_start(
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'])
sub.subscription_end = Subscription.compute_end(
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'],
start=sub.subscription_start)
sub.save()
self.validated = True self.validated = True
self.save() self.save()
......
Markdown is supported
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