Fix subscriptions with Sith account

This commit is contained in:
Skia 2016-09-04 18:34:34 +02:00
parent 4503fae287
commit 976ae09e55
2 changed files with 31 additions and 31 deletions

View File

@ -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):
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):

View File

@ -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()