From 976ae09e550051cd92ce191dc5d6548b81acb378 Mon Sep 17 00:00:00 2001 From: Skia Date: Sun, 4 Sep 2016 18:34:34 +0200 Subject: [PATCH] Fix subscriptions with Sith account --- counter/models.py | 32 +++++++++++++++++++++++++++++++- eboutic/models.py | 30 ------------------------------ 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/counter/models.py b/counter/models.py index d980aaaa..03fc92c6 100644 --- a/counter/models.py +++ b/counter/models.py @@ -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): diff --git a/eboutic/models.py b/eboutic/models.py index 98c019d5..ed14125c 100644 --- a/eboutic/models.py +++ b/eboutic/models.py @@ -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()