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)
......
......@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-08-26 20:28+0200\n"
"POT-Creation-Date: 2016-08-29 02:59+0200\n"
"PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Skia <skia@libskia.so>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n"
......@@ -123,9 +123,9 @@ msgstr "numéro"
msgid "journal"
msgstr "classeur"
#: accounting/models.py:179 core/models.py:437 core/models.py:713
#: accounting/models.py:179 core/models.py:458 core/models.py:734
#: counter/models.py:200 counter/models.py:246 counter/models.py:296
#: eboutic/models.py:14 eboutic/models.py:47
#: eboutic/models.py:15 eboutic/models.py:48
msgid "date"
msgstr "date"
......@@ -134,7 +134,7 @@ msgid "comment"
msgstr "commentaire"
#: accounting/models.py:181 counter/models.py:201 counter/models.py:247
#: subscription/models.py:34
#: subscription/models.py:52
msgid "payment method"
msgstr "méthode de paiement"
......@@ -142,7 +142,7 @@ msgstr "méthode de paiement"
msgid "cheque number"
msgstr "numéro de chèque"
#: accounting/models.py:183 eboutic/models.py:115
#: accounting/models.py:183 eboutic/models.py:146
msgid "invoice"
msgstr "facture"
......@@ -179,7 +179,7 @@ msgstr "Compte"
msgid "Company"
msgstr "Entreprise"
#: accounting/models.py:190 sith/settings.py:290 sith/settings_sample.py:272
#: accounting/models.py:190 sith/settings.py:291 sith/settings_sample.py:273
msgid "Other"
msgstr "Autre"
......@@ -468,7 +468,7 @@ msgid "Done"
msgstr "Effectué"
#: accounting/templates/accounting/journal_details.jinja:34
#: counter/views.py:558
#: counter/views.py:561
msgid "Comment"
msgstr "Commentaire"
......@@ -488,8 +488,7 @@ msgstr "Éditer l'opération"
#: core/templates/core/create.jinja:12 core/templates/core/edit.jinja:12
#: core/templates/core/file_edit.jinja:8 core/templates/core/page_prop.jinja:8
#: core/templates/core/pagerev_edit.jinja:24
#: counter/templates/counter/counter_edit.jinja:12
#: counter/templates/counter/counter_edit.jinja:14
#: counter/templates/counter/cash_register_summary.jinja:22
#: subscription/templates/subscription/subscription.jinja:22
msgid "Save"
msgstr "Sauver"
......@@ -540,7 +539,7 @@ msgid "A club with that unix_name already exists"
msgstr "Un club avec ce nom UNIX existe déjà."
#: club/models.py:145 counter/models.py:280 counter/models.py:294
#: eboutic/models.py:13 eboutic/models.py:46 launderette/models.py:89
#: eboutic/models.py:14 eboutic/models.py:47 launderette/models.py:89
#: launderette/models.py:126
msgid "user"
msgstr "nom d'utilisateur"
......@@ -902,120 +901,120 @@ msgstr "adresse des parents"
msgid "is subscriber viewable"
msgstr "profil visible par les cotisants"
#: core/models.py:257
#: core/models.py:274
msgid "A user with that username already exists"
msgstr "Un utilisateur de ce nom d'utilisateur existe déjà"
#: core/models.py:376 core/templates/core/macros.jinja:17
#: core/models.py:393 core/templates/core/macros.jinja:17
#: core/templates/core/user_detail.jinja:14
#: core/templates/core/user_detail.jinja:16
#: core/templates/core/user_edit.jinja:16
msgid "Profile"
msgstr "Profil"
#: core/models.py:414
#: core/models.py:435
msgid "Visitor"
msgstr "Visiteur"
#: core/models.py:419
#: core/models.py:440
msgid "define if we show a users stats"
msgstr "Definit si l'on montre les statistiques de l'utilisateur"
#: core/models.py:421
#: core/models.py:442
msgid "Show your account statistics to others"
msgstr "Montrez vos statistiques de compte aux autres"
#: core/models.py:428
#: core/models.py:449
msgid "file name"
msgstr "nom du fichier"
#: core/models.py:429 core/models.py:562
#: core/models.py:450 core/models.py:583
msgid "parent"
msgstr "parent"
#: core/models.py:430 core/models.py:440
#: core/models.py:451 core/models.py:461
msgid "file"
msgstr "fichier"
#: core/models.py:431
#: core/models.py:452
msgid "owner"
msgstr "propriétaire"
#: core/models.py:432 core/models.py:568
#: core/models.py:453 core/models.py:589
msgid "edit group"
msgstr "groupe d'édition"
#: core/models.py:433 core/models.py:569
#: core/models.py:454 core/models.py:590
msgid "view group"
msgstr "groupe de vue"
#: core/models.py:434
#: core/models.py:455
msgid "is folder"
msgstr "est un dossier"
#: core/models.py:435
#: core/models.py:456
msgid "mime type"
msgstr "type mime"
#: core/models.py:436
#: core/models.py:457
msgid "size"
msgstr "taille"
#: core/models.py:466
#: core/models.py:487
msgid "Character '/' not authorized in name"
msgstr "Le caractère '/' n'est pas autorisé dans les noms de fichier"
#: core/models.py:469 core/models.py:474
#: core/models.py:490 core/models.py:495
msgid "Loop in folder tree"
msgstr "Boucle dans l'arborescence des dossiers"
#: core/models.py:478
#: core/models.py:499
msgid "You can not make a file be a children of a non folder file"
msgstr ""
"Vous ne pouvez pas mettre un fichier enfant de quelque chose qui n'est pas "
"un dossier"
#: core/models.py:482
#: core/models.py:503
msgid "Duplicate file"
msgstr "Un fichier de ce nom existe déjà"
#: core/models.py:492
#: core/models.py:513
msgid "You must provide a file"
msgstr "Vous devez fournir un fichier"
#: core/models.py:517
#: core/models.py:538
msgid "Folder: "
msgstr "Dossier : "
#: core/models.py:519
#: core/models.py:540
msgid "File: "
msgstr "Fichier : "
#: core/models.py:561 core/models.py:565
#: core/models.py:582 core/models.py:586
msgid "page name"
msgstr "nom de la page"
#: core/models.py:566
#: core/models.py:587
msgid "owner group"
msgstr "groupe propriétaire"
#: core/models.py:597
#: core/models.py:618
msgid "Duplicate page"
msgstr "Une page de ce nom existe déjà"
#: core/models.py:603
#: core/models.py:624
msgid "Loop in page tree"
msgstr "Boucle dans l'arborescence des pages"
#: core/models.py:710
#: core/models.py:731
msgid "revision"
msgstr "révision"
#: core/models.py:711
#: core/models.py:732
msgid "page title"
msgstr "titre de la page"
#: core/models.py:712
#: core/models.py:733
msgid "page content"
msgstr "contenu de la page"
......@@ -1111,8 +1110,7 @@ msgstr "Annuler"
#: core/templates/core/edit.jinja:4 core/templates/core/edit.jinja.py:8
#: core/templates/core/file_edit.jinja:4
#: counter/templates/counter/counter_edit.jinja:4
#: counter/templates/counter/counter_edit.jinja:8
#: counter/templates/counter/cash_register_summary.jinja:4
#, python-format
msgid "Edit %(obj)s"
msgstr "Éditer %(obj)s"
......@@ -1460,13 +1458,12 @@ msgid "Option: "
msgstr "Filière : "
#: core/templates/core/user_detail.jinja:48
#, python-format
msgid "User is subscriber until %(subscription_end)s"
msgstr "L'utilisateur est cotisant jusqu'au %(subscription_end)s"
msgid "Subscribed until %(subscription_end)s"
msgstr "Cotisant jusqu'au %(subscription_end)s"
#: core/templates/core/user_detail.jinja:50
msgid "User is not subscribed. "
msgstr "L'utilisateur n'est pas cotisant."
msgid "Not subscribed"
msgstr "Non cotisant"
#: core/templates/core/user_detail.jinja:51
#: subscription/templates/subscription/subscription.jinja:4
......@@ -1557,7 +1554,7 @@ msgstr "Gestion de Sith"
msgid "Subscriptions"
msgstr "Cotisations"
#: core/templates/core/user_tools.jinja:22 counter/views.py:473
#: core/templates/core/user_tools.jinja:22 counter/views.py:476
msgid "Counters"
msgstr "Comptoirs"
......@@ -1707,7 +1704,8 @@ msgstr "Bureau"
#: eboutic/templates/eboutic/eboutic_main.jinja:24
#: eboutic/templates/eboutic/eboutic_makecommand.jinja:8
#: eboutic/templates/eboutic/eboutic_payment_result.jinja:4
#: sith/settings.py:289 sith/settings_sample.py:271
#: sith/settings.py:290 sith/settings.py:298 sith/settings_sample.py:272
#: sith/settings_sample.py:280
msgid "Eboutic"
msgstr "Eboutic"
......@@ -1732,11 +1730,11 @@ msgstr "est validé"
msgid "refilling"
msgstr "rechargement"
#: counter/models.py:242 eboutic/models.py:102
#: counter/models.py:242 eboutic/models.py:133
msgid "unit price"
msgstr "prix unitaire"
#: counter/models.py:243 counter/models.py:320 eboutic/models.py:103
#: counter/models.py:243 counter/models.py:320 eboutic/models.py:134
msgid "quantity"
msgstr "quantité"
......@@ -1744,9 +1742,9 @@ msgstr "quantité"
msgid "Sith account"
msgstr "Compte utilisateur"
#: counter/models.py:248 sith/settings.py:282 sith/settings.py:287
#: sith/settings.py:308 sith/settings_sample.py:264
#: sith/settings_sample.py:269 sith/settings_sample.py:290
#: counter/models.py:248 sith/settings.py:283 sith/settings.py:288
#: sith/settings.py:310 sith/settings_sample.py:265
#: sith/settings_sample.py:270 sith/settings_sample.py:292
msgid "Credit card"
msgstr "Carte banquaire"
......@@ -1786,6 +1784,11 @@ msgstr "chèque"
msgid "cash register summary item"
msgstr "élément de relevé de caisse"
#: counter/templates/counter/cash_register_summary.jinja:8
#: counter/templates/counter/counter_main.jinja:43
msgid "Make a cash register summary"
msgstr "Faire un relevé de caisse"
#: counter/templates/counter/counter_click.jinja:29
msgid "Customer"
msgstr "Client"
......@@ -1882,10 +1885,6 @@ msgstr "valider"
msgid "Please, login"
msgstr "Merci de vous identifier"
#: counter/templates/counter/counter_main.jinja:43
msgid "Make a cash register summary"
msgstr "Faire un relevé de caisse"
#: counter/templates/counter/counter_main.jinja:46
msgid "Barman: "
msgstr "Barman : "
......@@ -1932,101 +1931,101 @@ msgstr "Mauvais identifiants"
msgid "User is not subscriber"
msgstr "L'utilisateur n'est pas cotisant."
#: counter/views.py:258
#: counter/views.py:261
msgid "END"
msgstr "FIN"
#: counter/views.py:260
#: counter/views.py:263
msgid "CAN"
msgstr "ANN"
#: counter/views.py:290
#: counter/views.py:293
msgid "You have not enough money to buy all the basket"
msgstr "Vous n'avez pas assez d'argent pour acheter le panier"
#: counter/views.py:470
#: counter/views.py:473
msgid "Parent product"
msgstr "Produit parent"
#: counter/views.py:471
#: counter/views.py:474
msgid "Buying groups"
msgstr "Groupes d'achat"
#: counter/views.py:538
#: counter/views.py:541
msgid "10 cents"
msgstr "10 centimes"
#: counter/views.py:539
#: counter/views.py:542
msgid "20 cents"
msgstr "20 centimes"
#: counter/views.py:540
#: counter/views.py:543
msgid "50 cents"
msgstr "50 centimes"
#: counter/views.py:541
#: counter/views.py:544
msgid "1 euro"
msgstr "1 €"
#: counter/views.py:542
#: counter/views.py:545
msgid "2 euros"
msgstr "2 €"
#: counter/views.py:543
#: counter/views.py:546
msgid "5 euros"
msgstr "5 €"
#: counter/views.py:544
#: counter/views.py:547
msgid "10 euros"
msgstr "10 €"
#: counter/views.py:545
#: counter/views.py:548
msgid "20 euros"
msgstr "20 €"
#: counter/views.py:546
#: counter/views.py:549
msgid "50 euros"
msgstr "50 €"
#: counter/views.py:547
#: counter/views.py:550
msgid "100 euros"
msgstr "100 €"
#: counter/views.py:548 counter/views.py:550 counter/views.py:552
#: counter/views.py:554 counter/views.py:556
#: counter/views.py:551 counter/views.py:553 counter/views.py:555
#: counter/views.py:557 counter/views.py:559
msgid "Check amount"
msgstr "Montant du chèque"
#: counter/views.py:549 counter/views.py:551 counter/views.py:553
#: counter/views.py:555 counter/views.py:557
#: counter/views.py:552 counter/views.py:554 counter/views.py:556
#: counter/views.py:558 counter/views.py:560
msgid "Check quantity"
msgstr "Nombre de chèque"
#: counter/views.py:559
#: counter/views.py:562
msgid "Emptied"
msgstr "Coffre vidé"
#: eboutic/models.py:48
#: eboutic/models.py:49
msgid "validated"
msgstr "validé"
#: eboutic/models.py:61
#: eboutic/models.py:62
msgid "Invoice already validated"
msgstr "Facture déjà validée"
#: eboutic/models.py:99
#: eboutic/models.py:130
msgid "product id"
msgstr "ID du produit"
#: eboutic/models.py:100
#: eboutic/models.py:131
msgid "product name"
msgstr "nom du produit"
#: eboutic/models.py:101
#: eboutic/models.py:132
msgid "product type id"
msgstr "id du type du produit"
#: eboutic/models.py:112
#: eboutic/models.py:143
msgid "basket"
msgstr "panier"
......@@ -2065,7 +2064,7 @@ msgstr "Le paiement a été effectué"
msgid "Return to eboutic"
msgstr "Retourner à l'eboutic"
#: eboutic/views.py:138
#: eboutic/views.py:140
msgid "You do not have enough money to buy the basket"
msgstr "Vous n'avez pas assez d'argent pour acheter le panier"
......@@ -2154,12 +2153,12 @@ msgid "Washing and drying"
msgstr "Lavage et séchage"
#: launderette/templates/launderette/launderette_book.jinja:26
#: sith/settings.py:418 sith/settings_sample.py:400
#: sith/settings.py:424 sith/settings_sample.py:406
msgid "Washing"
msgstr "Lavage"
#: launderette/templates/launderette/launderette_book.jinja:30
#: sith/settings.py:418 sith/settings_sample.py:400
#: sith/settings.py:424 sith/settings_sample.py:406
msgid "Drying"
msgstr "Séchage"
......@@ -2214,148 +2213,148 @@ msgstr "L'utilisateur n'a pas réservé de créneau"
msgid "Token not found"
msgstr "Jeton non trouvé"
#: sith/settings.py:173 sith/settings_sample.py:160
#: sith/settings.py:174 sith/settings_sample.py:161
msgid "English"
msgstr "Anglais"
#: sith/settings.py:174 sith/settings_sample.py:161
#: sith/settings.py:175 sith/settings_sample.py:162
msgid "French"
msgstr "Français"
#: sith/settings.py:279 sith/settings.py:286 sith/settings.py:306
#: sith/settings_sample.py:261 sith/settings_sample.py:268
#: sith/settings_sample.py:288
#: sith/settings.py:280 sith/settings.py:287 sith/settings.py:308
#: sith/settings_sample.py:262 sith/settings_sample.py:269
#: sith/settings_sample.py:290
msgid "Check"
msgstr "Chèque"
#: sith/settings.py:280 sith/settings.py:288 sith/settings.py:307
#: sith/settings_sample.py:262 sith/settings_sample.py:270
#: sith/settings_sample.py:289
#: sith/settings.py:281 sith/settings.py:289 sith/settings.py:309
#: sith/settings_sample.py:263 sith/settings_sample.py:271
#: sith/settings_sample.py:291
msgid "Cash"
msgstr "Espèces"
#: sith/settings.py:281 sith/settings_sample.py:263
#: sith/settings.py:282 sith/settings_sample.py:264
msgid "Transfert"
msgstr "Virement"
#: sith/settings.py:294 sith/settings_sample.py:276
#: sith/settings.py:295 sith/settings_sample.py:277
msgid "Belfort"
msgstr "Belfort"
#: sith/settings.py:295 sith/settings_sample.py:277
#: sith/settings.py:296 sith/settings_sample.py:278
msgid "Sevenans"
msgstr "Sevenans"
#: sith/settings.py:296 sith/settings_sample.py:278
#: sith/settings.py:297 sith/settings_sample.py:279
msgid "Montbéliard"
msgstr "Montbéliard"
#: sith/settings.py:331 sith/settings_sample.py:313
#: sith/settings.py:337 sith/settings_sample.py:319
msgid "One semester"
msgstr "Un semestre"
#: sith/settings.py:336 sith/settings_sample.py:318
#: sith/settings.py:342 sith/settings_sample.py:324
msgid "Two semesters"
msgstr "Deux semestres"
#: sith/settings.py:341 sith/settings_sample.py:323
#: sith/settings.py:347 sith/settings_sample.py:329
msgid "Common core cursus"
msgstr "Cursus tronc commun"
#: sith/settings.py:346 sith/settings.py:351 sith/settings_sample.py:328
#: sith/settings_sample.py:333
#: sith/settings.py:352 sith/settings.py:357 sith/settings_sample.py:334
#: sith/settings_sample.py:339
msgid "Branch cursus"
msgstr "Cursus branche"
#: sith/settings.py:356 sith/settings_sample.py:338
#: sith/settings.py:3