mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 18:44:23 +00:00
Update counters and some views
This commit is contained in:
parent
724f3d8d6f
commit
1f3e186e27
@ -13,12 +13,6 @@
|
|||||||
{% if user.is_in_group(settings.SITH_GROUPS['root']['name']) %}
|
{% if user.is_in_group(settings.SITH_GROUPS['root']['name']) %}
|
||||||
<li><a href="{{ url('core:group_list') }}">{% trans %}Groups{% endtrans %}</a></li>
|
<li><a href="{{ url('core:group_list') }}">{% trans %}Groups{% endtrans %}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if user.is_in_group(settings.SITH_GROUPS['counter-admin']['name']) %}
|
|
||||||
<li><a href="{{ url('counter:admin_list') }}">{% trans %}Counters management{% endtrans %}</a></li>
|
|
||||||
{% endif %}
|
|
||||||
{% if user.is_in_group(settings.SITH_GROUPS['accounting-admin']['name']) %}
|
|
||||||
<li><a href="{{ url('accounting:bank_list') }}">{% trans %}Accounting{% endtrans %}</a></li>
|
|
||||||
{% endif %}
|
|
||||||
{% if user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user.is_in_group(settings.SITH_GROUPS['root']['name']) %}
|
{% if user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user.is_in_group(settings.SITH_GROUPS['root']['name']) %}
|
||||||
<li><a href="{{ url('subscription:subscription') }}">{% trans %}Subscriptions{% endtrans %}</a></li>
|
<li><a href="{{ url('subscription:subscription') }}">{% trans %}Subscriptions{% endtrans %}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -27,6 +21,9 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<h4>{% trans %}Counters{% endtrans %}</h4>
|
<h4>{% trans %}Counters{% endtrans %}</h4>
|
||||||
<ul>
|
<ul>
|
||||||
|
{% if user.is_in_group(settings.SITH_GROUPS['counter-admin']['name']) or user.is_in_group(settings.SITH_GROUPS['root']['name']) %}
|
||||||
|
<li><a href="{{ url('counter:admin_list') }}">{% trans %}General counters management{% endtrans %}</a></li>
|
||||||
|
{% endif %}
|
||||||
{% for b in settings.SITH_COUNTER_BARS %}
|
{% for b in settings.SITH_COUNTER_BARS %}
|
||||||
{% if user.is_in_group(b[1]+" admin") %}
|
{% if user.is_in_group(b[1]+" admin") %}
|
||||||
<li><a href="{{ url('counter:details', counter_id=b[0]) }}">{{ b[1] }}</a> -
|
<li><a href="{{ url('counter:details', counter_id=b[0]) }}">{{ b[1] }}</a> -
|
||||||
@ -38,6 +35,9 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<h4>{% trans %}Accounting{% endtrans %}</h4>
|
<h4>{% trans %}Accounting{% endtrans %}</h4>
|
||||||
<ul>
|
<ul>
|
||||||
|
{% if user.is_in_group(settings.SITH_GROUPS['accounting-admin']['name']) or user.is_in_group(settings.SITH_GROUPS['root']['name']) %}
|
||||||
|
<li><a href="{{ url('accounting:bank_list') }}">{% trans %}General accounting{% endtrans %}</a></li>
|
||||||
|
{% endif %}
|
||||||
{% for m in user.membership.filter(end_date=None).filter(role__gte=7).all() %}
|
{% for m in user.membership.filter(end_date=None).filter(role__gte=7).all() %}
|
||||||
{% for b in m.club.bank_accounts.all() %}
|
{% for b in m.club.bank_accounts.all() %}
|
||||||
<li><strong>{% trans %}Bank account: {% endtrans %}</strong>
|
<li><strong>{% trans %}Bank account: {% endtrans %}</strong>
|
||||||
|
19
counter/migrations/0009_auto_20160721_1902.py
Normal file
19
counter/migrations/0009_auto_20160721_1902.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('counter', '0008_auto_20160718_1805'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='counter',
|
||||||
|
name='type',
|
||||||
|
field=models.CharField(max_length=255, verbose_name='subscription type', choices=[('BAR', 'Bar'), ('OFFICE', 'Office'), ('EBOUTIC', 'Eboutic')]),
|
||||||
|
),
|
||||||
|
]
|
@ -10,7 +10,6 @@ from random import randrange
|
|||||||
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
|
|
||||||
|
|
||||||
class Customer(models.Model):
|
class Customer(models.Model):
|
||||||
"""
|
"""
|
||||||
@ -82,7 +81,7 @@ class Counter(models.Model):
|
|||||||
products = models.ManyToManyField(Product, related_name="counters", blank=True)
|
products = models.ManyToManyField(Product, related_name="counters", blank=True)
|
||||||
type = models.CharField(_('subscription type'),
|
type = models.CharField(_('subscription type'),
|
||||||
max_length=255,
|
max_length=255,
|
||||||
choices=[('BAR',_('Bar')), ('OFFICE',_('Office'))])
|
choices=[('BAR',_('Bar')), ('OFFICE',_('Office')), ('EBOUTIC',_('Eboutic'))])
|
||||||
edit_groups = models.ManyToManyField(Group, related_name="editable_counters", blank=True)
|
edit_groups = models.ManyToManyField(Group, related_name="editable_counters", blank=True)
|
||||||
view_groups = models.ManyToManyField(Group, related_name="viewable_counters", blank=True)
|
view_groups = models.ManyToManyField(Group, related_name="viewable_counters", blank=True)
|
||||||
barmen_session = {}
|
barmen_session = {}
|
||||||
@ -132,7 +131,7 @@ class Counter(models.Model):
|
|||||||
|
|
||||||
def get_barmen_list(counter_id):
|
def get_barmen_list(counter_id):
|
||||||
"""
|
"""
|
||||||
Returns the barman list as list of Subscriber
|
Returns the barman list as list of User
|
||||||
|
|
||||||
Also handle the timeout of the barmen
|
Also handle the timeout of the barmen
|
||||||
"""
|
"""
|
||||||
@ -141,7 +140,7 @@ class Counter(models.Model):
|
|||||||
if counter_id in list(Counter.barmen_session.keys()):
|
if counter_id in list(Counter.barmen_session.keys()):
|
||||||
for b in Counter.barmen_session[counter_id]['users']:
|
for b in Counter.barmen_session[counter_id]['users']:
|
||||||
# Reminder: user is stored as a tuple with its login time
|
# Reminder: user is stored as a tuple with its login time
|
||||||
bl.append(Subscriber.objects.filter(id=b[0]).first())
|
bl.append(User.objects.filter(id=b[0]).first())
|
||||||
if (timezone.now() - Counter.barmen_session[counter_id]['time']) < timedelta(minutes=settings.SITH_BARMAN_TIMEOUT):
|
if (timezone.now() - Counter.barmen_session[counter_id]['time']) < timedelta(minutes=settings.SITH_BARMAN_TIMEOUT):
|
||||||
Counter.barmen_session[counter_id]['time'] = timezone.now()
|
Counter.barmen_session[counter_id]['time'] = timezone.now()
|
||||||
else:
|
else:
|
||||||
@ -151,9 +150,9 @@ class Counter(models.Model):
|
|||||||
Counter.barmen_session[counter_id]['users'] = set()
|
Counter.barmen_session[counter_id]['users'] = set()
|
||||||
return bl
|
return bl
|
||||||
|
|
||||||
def get_random_barman(counter_id): # TODO: improve this function
|
def get_random_barman(counter_id):
|
||||||
bl = Counter.get_barmen_list(counter_id)
|
bl = Counter.get_barmen_list(counter_id)
|
||||||
return bl[0]
|
return bl[randrange(0, len(bl))]
|
||||||
|
|
||||||
class Refilling(models.Model):
|
class Refilling(models.Model):
|
||||||
"""
|
"""
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
<h5>{% trans %}Customer{% endtrans %}</h5>
|
<h5>{% trans %}Customer{% endtrans %}</h5>
|
||||||
<p>{{ customer.user.get_display_name() }}, {{ customer.amount }} €</p>
|
<p>{{ customer.user.get_display_name() }}, {{ customer.amount }} €</p>
|
||||||
</div>
|
</div>
|
||||||
|
{% if counter.type == 'BAR' %}
|
||||||
<div>
|
<div>
|
||||||
<h5>{% trans %}Refilling{% endtrans %}</h5>
|
<h5>{% trans %}Refilling{% endtrans %}</h5>
|
||||||
<form method="post" action="{{ url('counter:click', counter_id=counter.id, user_id=customer.user.id) }}">
|
<form method="post" action="{{ url('counter:click', counter_id=counter.id, user_id=customer.user.id) }}">
|
||||||
@ -34,6 +35,7 @@
|
|||||||
<input type="submit" value="{% trans %}Go{% endtrans %}" />
|
<input type="submit" value="{% trans %}Go{% endtrans %}" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
<div>
|
<div>
|
||||||
<h5>{% trans %}Selling{% endtrans %}</h5>
|
<h5>{% trans %}Selling{% endtrans %}</h5>
|
||||||
{% if request.session['not_enough'] %}
|
{% if request.session['not_enough'] %}
|
||||||
@ -47,7 +49,7 @@
|
|||||||
</form>
|
</form>
|
||||||
<p>{% trans %}Basket: {% endtrans %}</p>
|
<p>{% trans %}Basket: {% endtrans %}</p>
|
||||||
<ul>
|
<ul>
|
||||||
{% for id,infos in request.session['basket'].items() %}
|
{% for id,infos in request.session['basket']|dictsort %}
|
||||||
{% set product = counter.products.filter(id=id).first() %}
|
{% set product = counter.products.filter(id=id).first() %}
|
||||||
{% set s = infos['qty'] * infos['price'] / 100 %}
|
{% set s = infos['qty'] * infos['price'] / 100 %}
|
||||||
<li>{{ del_product(id, '-') }} {{ infos['qty'] }} {{ add_product(id, '+') }} {{ product.name }}: {{ "%0.2f"|format(s) }} €</li>
|
<li>{{ del_product(id, '-') }} {{ infos['qty'] }} {{ add_product(id, '+') }} {{ product.name }}: {{ "%0.2f"|format(s) }} €</li>
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
<p>{% trans %}Please, login{% endtrans %}</p>
|
<p>{% trans %}Please, login{% endtrans %}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
{% if counter.type == 'BAR' %}
|
||||||
<div>
|
<div>
|
||||||
<h3>{% trans %}Barman: {% endtrans %}</h3>
|
<h3>{% trans %}Barman: {% endtrans %}</h3>
|
||||||
<ul>
|
<ul>
|
||||||
@ -51,6 +52,7 @@
|
|||||||
<p><input type="submit" value="{% trans %}login{% endtrans %}" /></p>
|
<p><input type="submit" value="{% trans %}login{% endtrans %}" /></p>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,7 +72,10 @@ class CounterMain(DetailView, ProcessFormView, FormMixin):
|
|||||||
kwargs['login_form'] = AuthenticationForm()
|
kwargs['login_form'] = AuthenticationForm()
|
||||||
kwargs['login_form'].fields['username'].widget.attrs['autofocus'] = True
|
kwargs['login_form'].fields['username'].widget.attrs['autofocus'] = True
|
||||||
kwargs['form'] = self.get_form()
|
kwargs['form'] = self.get_form()
|
||||||
|
if self.object.type == 'BAR':
|
||||||
kwargs['barmen'] = Counter.get_barmen_list(self.object.id)
|
kwargs['barmen'] = Counter.get_barmen_list(self.object.id)
|
||||||
|
elif self.request.user.is_authenticated():
|
||||||
|
kwargs['barmen'] = [self.request.user]
|
||||||
if 'last_basket' in self.request.session.keys():
|
if 'last_basket' in self.request.session.keys():
|
||||||
kwargs['last_basket'] = self.request.session.pop('last_basket')
|
kwargs['last_basket'] = self.request.session.pop('last_basket')
|
||||||
kwargs['last_customer'] = self.request.session.pop('last_customer')
|
kwargs['last_customer'] = self.request.session.pop('last_customer')
|
||||||
@ -109,8 +112,10 @@ class CounterClick(DetailView):
|
|||||||
request.session['not_enough'] = False
|
request.session['not_enough'] = False
|
||||||
self.refill_form = None
|
self.refill_form = None
|
||||||
ret = super(CounterClick, self).get(request, *args, **kwargs)
|
ret = super(CounterClick, self).get(request, *args, **kwargs)
|
||||||
if len(Counter.get_barmen_list(self.object.id)) < 1: # Check that at least one barman is logged in
|
if ((self.object.type != "BAR" and not request.user.is_authenticated()) or
|
||||||
return self.cancel(request) # Otherwise, go to main view
|
(self.object.type == "BAR" and
|
||||||
|
len(Counter.get_barmen_list(self.object.id)) < 1)): # Check that at least one barman is logged in
|
||||||
|
ret = self.cancel(request) # Otherwise, go to main view
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
@ -173,7 +178,7 @@ class CounterClick(DetailView):
|
|||||||
request.session['basket'][pid]['qty'] += q
|
request.session['basket'][pid]['qty'] += q
|
||||||
else:
|
else:
|
||||||
request.session['basket'][pid] = {'qty': q, 'price': int(price*100)}
|
request.session['basket'][pid] = {'qty': q, 'price': int(price*100)}
|
||||||
request.session['not_enough'] = False
|
request.session['not_enough'] = False # Reset not_enough to save the session
|
||||||
request.session.modified = True
|
request.session.modified = True
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -283,6 +288,7 @@ class CounterLogin(RedirectView):
|
|||||||
form = AuthenticationForm(request, data=request.POST)
|
form = AuthenticationForm(request, data=request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
user = Subscriber.objects.filter(username=form.cleaned_data['username']).first()
|
user = Subscriber.objects.filter(username=form.cleaned_data['username']).first()
|
||||||
|
if user.is_subscribed():
|
||||||
Counter.add_barman(self.counter_id, user.id)
|
Counter.add_barman(self.counter_id, user.id)
|
||||||
else:
|
else:
|
||||||
print("Error logging the barman") # TODO handle that nicely
|
print("Error logging the barman") # TODO handle that nicely
|
||||||
|
Binary file not shown.
@ -6,7 +6,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2016-07-21 12:08+0200\n"
|
"POT-Creation-Date: 2016-07-21 17:39+0200\n"
|
||||||
"PO-Revision-Date: 2016-07-18\n"
|
"PO-Revision-Date: 2016-07-18\n"
|
||||||
"Last-Translator: Skia <skia@libskia.so>\n"
|
"Last-Translator: Skia <skia@libskia.so>\n"
|
||||||
"Language-Team: AE info <ae.info@utbm.fr>\n"
|
"Language-Team: AE info <ae.info@utbm.fr>\n"
|
||||||
@ -113,8 +113,7 @@ msgstr "Il n'y a pas de types comptable dans ce site web."
|
|||||||
#: accounting/templates/accounting/bank_account_details.jinja:5
|
#: accounting/templates/accounting/bank_account_details.jinja:5
|
||||||
#: accounting/templates/accounting/club_account_details.jinja:5
|
#: accounting/templates/accounting/club_account_details.jinja:5
|
||||||
#: accounting/templates/accounting/journal_details.jinja:5
|
#: accounting/templates/accounting/journal_details.jinja:5
|
||||||
#: core/templates/core/user_tools.jinja:20
|
#: core/templates/core/user_tools.jinja:36
|
||||||
#: core/templates/core/user_tools.jinja:39
|
|
||||||
msgid "Accounting"
|
msgid "Accounting"
|
||||||
msgstr "Comptabilité"
|
msgstr "Comptabilité"
|
||||||
|
|
||||||
@ -147,7 +146,7 @@ msgstr "Nouveau compte club"
|
|||||||
#: club/templates/club/club_detail.jinja:7
|
#: club/templates/club/club_detail.jinja:7
|
||||||
#: core/templates/core/page_detail.jinja:7
|
#: core/templates/core/page_detail.jinja:7
|
||||||
#: core/templates/core/user_base.jinja:8
|
#: core/templates/core/user_base.jinja:8
|
||||||
#: core/templates/core/user_tools.jinja:33
|
#: core/templates/core/user_tools.jinja:30
|
||||||
#: counter/templates/counter/counter_list.jinja:14
|
#: counter/templates/counter/counter_list.jinja:14
|
||||||
msgid "Edit"
|
msgid "Edit"
|
||||||
msgstr "Éditer"
|
msgstr "Éditer"
|
||||||
@ -865,17 +864,21 @@ msgid "Sith management"
|
|||||||
msgstr "Gestion de Sith"
|
msgstr "Gestion de Sith"
|
||||||
|
|
||||||
#: core/templates/core/user_tools.jinja:17
|
#: core/templates/core/user_tools.jinja:17
|
||||||
msgid "Counters management"
|
|
||||||
msgstr "Gestion des comptoirs"
|
|
||||||
|
|
||||||
#: core/templates/core/user_tools.jinja:23
|
|
||||||
msgid "Subscriptions"
|
msgid "Subscriptions"
|
||||||
msgstr "Cotisations"
|
msgstr "Cotisations"
|
||||||
|
|
||||||
#: core/templates/core/user_tools.jinja:28
|
#: core/templates/core/user_tools.jinja:22
|
||||||
msgid "Counters"
|
msgid "Counters"
|
||||||
msgstr "Comptoirs"
|
msgstr "Comptoirs"
|
||||||
|
|
||||||
|
#: core/templates/core/user_tools.jinja:25
|
||||||
|
msgid "General counters management"
|
||||||
|
msgstr "Gestion générale des comptoirs"
|
||||||
|
|
||||||
|
#: core/templates/core/user_tools.jinja:39
|
||||||
|
msgid "General accounting"
|
||||||
|
msgstr "Comptabilité générale"
|
||||||
|
|
||||||
#: core/templates/core/user_tools.jinja:47
|
#: core/templates/core/user_tools.jinja:47
|
||||||
msgid "Club account: "
|
msgid "Club account: "
|
||||||
msgstr "Compte club : "
|
msgstr "Compte club : "
|
||||||
@ -1152,8 +1155,3 @@ msgid "You must either choose an existing user or create a new one properly"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Vous devez soit choisir un utilisateur existant, ou en créer un proprement."
|
"Vous devez soit choisir un utilisateur existant, ou en créer un proprement."
|
||||||
|
|
||||||
#~ msgid "View account"
|
|
||||||
#~ msgstr "Voir le compte"
|
|
||||||
|
|
||||||
#~ msgid "View account:"
|
|
||||||
#~ msgstr "Voir le compte:"
|
|
||||||
|
@ -44,6 +44,7 @@ INSTALLED_APPS = (
|
|||||||
'subscription',
|
'subscription',
|
||||||
'accounting',
|
'accounting',
|
||||||
'counter',
|
'counter',
|
||||||
|
'eboutic',
|
||||||
)
|
)
|
||||||
|
|
||||||
MIDDLEWARE_CLASSES = (
|
MIDDLEWARE_CLASSES = (
|
||||||
|
@ -27,5 +27,6 @@ urlpatterns = [
|
|||||||
url(r'^club/', include('club.urls', namespace="club", app_name="club")),
|
url(r'^club/', include('club.urls', namespace="club", app_name="club")),
|
||||||
url(r'^counter/', include('counter.urls', namespace="counter", app_name="counter")),
|
url(r'^counter/', include('counter.urls', namespace="counter", app_name="counter")),
|
||||||
url(r'^accounting/', include('accounting.urls', namespace="accounting", app_name="accounting")),
|
url(r'^accounting/', include('accounting.urls', namespace="accounting", app_name="accounting")),
|
||||||
|
url(r'^eboutic/', include('eboutic.urls', namespace="eboutic", app_name="eboutic")),
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # TODO: remove me for production!!!
|
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # TODO: remove me for production!!!
|
||||||
|
Loading…
Reference in New Issue
Block a user