mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-21 21:53:30 +00:00
Fix subscriptions with Sith account
This commit is contained in:
parent
4503fae287
commit
976ae09e55
@ -12,7 +12,7 @@ import string
|
||||
from club.models import Club
|
||||
from accounting.models import CurrencyField
|
||||
from core.models import Group, User
|
||||
from subscription.models import Subscriber
|
||||
from subscription.models import Subscriber, Subscription
|
||||
from subscription.views import get_subscriber
|
||||
|
||||
class Customer(models.Model):
|
||||
@ -269,6 +269,36 @@ class Selling(models.Model):
|
||||
self.customer.amount -= self.quantity * self.unit_price
|
||||
self.customer.save()
|
||||
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)
|
||||
|
||||
class Permanency(models.Model):
|
||||
|
@ -93,36 +93,6 @@ class Invoice(models.Model):
|
||||
date=self.date,
|
||||
)
|
||||
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.save()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user