Commit 325da79e authored by Skia's avatar Skia

Add support for subscription typed products in eboutic

parent dfb13c37
Pipeline #147 failed with stage
in 1 minute and 51 seconds
db.sqlite3
*.log
*.pyc
*__pycache__*
.DS_Store
......
......@@ -55,6 +55,7 @@ class Command(BaseCommand):
unix_name=settings.SITH_LAUNDERETTE_MANAGER['unix_name'],
address=settings.SITH_LAUNDERETTE_MANAGER['address'])
launderette_club.save()
self.reset_index("club")
for b in settings.SITH_COUNTER_BARS:
g = Group(name=b[1]+" admin")
g.save()
......@@ -271,10 +272,10 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site.
credit.save()
debit = AccountingType(code=607, label="Had to pay a beer", movement_type='debit')
debit.save()
Operation(journal=gj, date=date.today(), amount=666.42, label="Satanic answer",
Operation(journal=gj, date=date.today(), amount=666.42,
remark="An answer to life...", mode="CASH", done=True, accounting_type=credit, target_type="USER",
target_id=skia.id).save()
Operation(journal=gj, date=date.today(), amount=42, label="Answer",
Operation(journal=gj, date=date.today(), amount=42,
remark="An answer to life...", mode="CASH", done=False, accounting_type=debit, target_type="CLUB",
target_id=bar_club.id).save()
woenzco = Company(name="Woenzel & co")
......
......@@ -41,13 +41,13 @@
</div>
</div>
{% if user.membership.filter(end_date=None).exists() or user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) %}
{% if user.membership.filter(end_date=None).exists() or user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user == profile %}
{# if the user is member of a club, he can view the subscription state #}
<p>
{% if get_subscriber(profile).is_subscribed() %}
{% trans subscription_end=get_subscriber(profile).subscriptions.last().subscription_end %}User is subscriber until {{ subscription_end }}{% endtrans %}
{% trans subscription_end=get_subscriber(profile).subscriptions.last().subscription_end %}Subscribed until {{ subscription_end }}{% endtrans %}
{% else %}
{% trans %}User is not subscribed. {% endtrans %}
{% trans %}Not subscribed{% endtrans %}
<a href="{{ url('subscription:subscription') }}?member={{ profile.id }}">{% trans %}New subscription{% endtrans %}</a>
{% endif %}
</p>
......
......@@ -212,9 +212,12 @@ class CounterClick(DetailView):
total = self.sum_basket(request)
product = self.get_product(pid)
can_buy = False
for g in product.buying_groups.all():
if self.customer.user.is_in_group(g.name):
can_buy = True
if not product.buying_groups.exists():
can_buy = True
else:
for g in product.buying_groups.all():
if self.customer.user.is_in_group(g.name):
can_buy = True
if not can_buy:
request.session['not_allowed'] = True
return False
......
......@@ -5,6 +5,7 @@ from django.conf import settings
from accounting.models import CurrencyField
from counter.models import Counter, Product, Customer, Selling, Refilling
from core.models import User
from subscription.models import Subscription, Subscriber
class Basket(models.Model):
"""
......@@ -92,6 +93,36 @@ 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()
......
......@@ -55,6 +55,8 @@ class EbouticMain(TemplateView):
""" Add a product to the basket """
try:
p = Product.objects.filter(id=int(request.POST['product_id'])).first()
if not p.buying_groups.exists():
self.basket.add_product(p)
for g in p.buying_groups.all():
if request.user.is_in_group(g.name):
self.basket.add_product(p)
......
This diff is collapsed.
......@@ -277,6 +277,7 @@ SITH_SUBSCRIPTION_LOCATIONS = [
('BELFORT', _('Belfort')),
('SEVENANS', _('Sevenans')),
('MONTBELIARD', _('Montbéliard')),
('EBOUTIC', _('Eboutic')),
]
SITH_COUNTER_BARS = [
......@@ -307,6 +308,10 @@ SITH_COUNTER_BANK = [
# Defines which product type is the refilling type, and thus increases the account amount
SITH_COUNTER_PRODUCTTYPE_REFILLING = 11
# 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_TWO_SEMESTERS = 94
# Subscription durations are in semestres
# Be careful, modifying this parameter will need a migration to be applied
SITH_SUBSCRIPTIONS = {
......
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