mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-16 03:03:21 +00:00
Merge branch 'sli' into 'master'
Add ban for alcohol See merge request !17
This commit is contained in:
commit
3e99f97b7a
@ -22,7 +22,7 @@
|
|||||||
<h4>{% trans %}Accouting: {% endtrans %}</h4>
|
<h4>{% trans %}Accouting: {% endtrans %}</h4>
|
||||||
<ul>
|
<ul>
|
||||||
{% for ca in object.club_account.all() %}
|
{% for ca in object.club_account.all() %}
|
||||||
<li><a href="{{ url('accounting:club_details', c_account_id=ca.id) }}">{{ ca }}</a></li>
|
<li><a href="{{ url('accounting:club_details', c_account_id=ca.id) }}">{{ ca.get_display_name() }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -241,6 +241,14 @@ class User(AbstractBaseUser):
|
|||||||
from club.models import Club
|
from club.models import Club
|
||||||
return Club.objects.filter(unix_name=settings.SITH_LAUNDERETTE_MANAGER['unix_name']).first().get_membership_for(self)
|
return Club.objects.filter(unix_name=settings.SITH_LAUNDERETTE_MANAGER['unix_name']).first().get_membership_for(self)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_banned_alcohol(self):
|
||||||
|
return self.is_in_group(settings.SITH_GROUPS['banned-alcohol']['name'])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_banned_counter(self):
|
||||||
|
return self.is_in_group(settings.SITH_GROUPS['banned-from-counters']['name'])
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
create = False
|
create = False
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
@ -431,6 +439,14 @@ class AnonymousUser(AuthAnonymousUser):
|
|||||||
def is_launderette_manager(self):
|
def is_launderette_manager(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_banned_alcohol(self):
|
||||||
|
return False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_banned_conuter(self):
|
||||||
|
return False
|
||||||
|
|
||||||
def is_in_group(self, group_name):
|
def is_in_group(self, group_name):
|
||||||
"""
|
"""
|
||||||
The anonymous user is only the public group
|
The anonymous user is only the public group
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
{% extends "core/base.jinja" %}
|
{% extends "core/base.jinja" %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
|
{% if object %}
|
||||||
{% trans obj=object %}Edit {{ obj }}{% endtrans %}
|
{% trans obj=object %}Edit {{ obj }}{% endtrans %}
|
||||||
|
{% else %}
|
||||||
|
{% trans %}Save{% endtrans %}
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% if object %}
|
||||||
<h2>{% trans obj=object %}Edit {{ obj }}{% endtrans %}</h2>
|
<h2>{% trans obj=object %}Edit {{ obj }}{% endtrans %}</h2>
|
||||||
|
{% else %}
|
||||||
|
<h2>{% trans %}Save{% endtrans %}</h2>
|
||||||
|
{% endif %}
|
||||||
<form action="" method="post" enctype="multipart/form-data">
|
<form action="" method="post" enctype="multipart/form-data">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p() }}
|
{{ form.as_p() }}
|
||||||
|
@ -1,29 +1,31 @@
|
|||||||
{% extends "core/base.jinja" %}
|
{% extends "core/base.jinja" %}
|
||||||
|
|
||||||
{% macro monthly(obj) %}
|
{% macro monthly(obj) %}
|
||||||
<table>
|
<div>
|
||||||
<thead>
|
<table>
|
||||||
<tr>
|
<thead>
|
||||||
<td>{% trans %}Year{% endtrans %}</td>
|
|
||||||
<td>{% trans %}Month{% endtrans %}</td>
|
|
||||||
<td>{% trans %}Total{% endtrans %}</td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for array in obj %}
|
|
||||||
{% for tuple in array %}
|
|
||||||
{% if tuple[0] != 0 %}
|
|
||||||
{% set link=url('core:user_account_detail', user_id=profile.id, year=tuple[1].year, month=tuple[1].month) %}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ link }}">{{ tuple[1].year }}</a></td>
|
<td>{% trans %}Year{% endtrans %}</td>
|
||||||
<td><a href="{{ link }}">{{ tuple[1]|date("E") }}</a></td>
|
<td>{% trans %}Month{% endtrans %}</td>
|
||||||
<td><a href="{{ link }}">{{ tuple[0] }} €</a></td>
|
<td>{% trans %}Total{% endtrans %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for array in obj %}
|
||||||
|
{% for dict in array %}
|
||||||
|
{% if dict['sum'] != 0 %}
|
||||||
|
{% set link=url('core:user_account_detail', user_id=profile.id, year=dict['date'].year, month=dict['date'].month) %}
|
||||||
|
<tr>
|
||||||
|
<td><a href="{{ link }}">{{ dict['date'].year }}</a></td>
|
||||||
|
<td><a href="{{ link }}">{{ dict['date']|date("E") }}</a></td>
|
||||||
|
<td><a href="{{ link }}">{{ dict['sum'] }} €</a></td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
</tbody>
|
||||||
</tbody>
|
</table>
|
||||||
</table>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
@ -34,30 +36,42 @@
|
|||||||
{% if customer %}
|
{% if customer %}
|
||||||
<h3>{% trans %}User account{% endtrans %}</h3>
|
<h3>{% trans %}User account{% endtrans %}</h3>
|
||||||
<p>{% trans %}Amount: {% endtrans %}{{ customer.amount }} €</p>
|
<p>{% trans %}Amount: {% endtrans %}{{ customer.amount }} €</p>
|
||||||
|
<div id="drop">
|
||||||
{% if customer.refillings.exists() %}
|
{% if customer.refillings.exists() %}
|
||||||
<h4>{% trans %}Refillings{% endtrans %}</h4>
|
{% if customer.buyings.exists() %}
|
||||||
{{ monthly(refilling_month) }}
|
<h5>{% trans %}Account buyings{% endtrans %}</h5>
|
||||||
{% endif %}
|
{{ monthly(buyings_month) }}
|
||||||
{% if customer.buyings.exists() %}
|
{% endif %}
|
||||||
<h4>{% trans %}Account buyings{% endtrans %}</h4>
|
<h5>{% trans %}Refillings{% endtrans %}</h5>
|
||||||
{{ monthly(buyings_month) }}
|
{{ monthly(refilling_month) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if customer.user.invoices.exists() %}
|
{% if customer.user.invoices.exists() %}
|
||||||
<h4>{% trans %}Eboutic invoices{% endtrans %}</h4>
|
<h5>{% trans %}Eboutic invoices{% endtrans %}</h5>
|
||||||
{{ monthly(invoices_month) }}
|
{{ monthly(invoices_month) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if etickets %}
|
{% if etickets %}
|
||||||
<h4>{% trans %}Etickets{% endtrans %}</h4>
|
<h4>{% trans %}Etickets{% endtrans %}</h4>
|
||||||
<ul>
|
<div>
|
||||||
{% for s in etickets %}
|
<ul>
|
||||||
<li><a href="{{ url('counter:eticket_pdf', selling_id=s.id) }}">{{ s.quantity }} x {{ s.product.eticket }}</a></li>
|
{% for s in etickets %}
|
||||||
{% endfor %}
|
<li><a href="{{ url('counter:eticket_pdf', selling_id=s.id) }}">{{ s.quantity }} x {{ s.product.eticket }}</a></li>
|
||||||
</ul>
|
{% endfor %}
|
||||||
{% endif %}
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>{% trans %}User has no account{% endtrans %}</p>
|
<p>{% trans %}User has no account{% endtrans %}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block script %}
|
||||||
|
{{ super() }}
|
||||||
|
<script>
|
||||||
|
$(function(){
|
||||||
|
$("#drop").accordion();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,35 +9,6 @@
|
|||||||
<h3>{% trans %}User account{% endtrans %}</h3>
|
<h3>{% trans %}User account{% endtrans %}</h3>
|
||||||
<p>{% trans %}Amount: {% endtrans %}{{ customer.amount }} €</p>
|
<p>{% trans %}Amount: {% endtrans %}{{ customer.amount }} €</p>
|
||||||
<p><a href="{{ url('core:user_account', user_id=profile.id) }}">{% trans %}Back{% endtrans %}</a></p>
|
<p><a href="{{ url('core:user_account', user_id=profile.id) }}">{% trans %}Back{% endtrans %}</a></p>
|
||||||
{% if customer.refillings.exists() %}
|
|
||||||
<h4>{% trans %}Refillings{% endtrans %}</h4>
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td>{% trans %}Date{% endtrans %}</td>
|
|
||||||
<td>{% trans %}Counter{% endtrans %}</td>
|
|
||||||
<td>{% trans %}Barman{% endtrans %}</td>
|
|
||||||
<td>{% trans %}Amount{% endtrans %}</td>
|
|
||||||
<td>{% trans %}Payment method{% endtrans %}</td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for i in customer.refillings.order_by('-date').filter(
|
|
||||||
date__year=year, date__month=month) %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ i.date|localtime|date(DATETIME_FORMAT) }} - {{ i.date|localtime|time(DATETIME_FORMAT) }}</td>
|
|
||||||
<td>{{ i.counter }}</td>
|
|
||||||
<td><a href="{{ i.operator.get_absolute_url() }}">{{ i.operator.get_display_name() }}</a></td>
|
|
||||||
<td>{{ i.amount }} €</td>
|
|
||||||
<td>{{ i.get_payment_method_display() }}</td>
|
|
||||||
{% if i.is_owned_by(user) %}
|
|
||||||
<td><a href="{{ url('counter:refilling_delete', refilling_id=i.id) }}">Delete</a></td>
|
|
||||||
{% endif %}
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
{% endif %}
|
|
||||||
{% if customer.buyings.exists() %}
|
{% if customer.buyings.exists() %}
|
||||||
<h4>{% trans %}Account buyings{% endtrans %}</h4>
|
<h4>{% trans %}Account buyings{% endtrans %}</h4>
|
||||||
<table>
|
<table>
|
||||||
@ -71,6 +42,35 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if customer.refillings.exists() %}
|
||||||
|
<h4>{% trans %}Refillings{% endtrans %}</h4>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>{% trans %}Date{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Counter{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Barman{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Amount{% endtrans %}</td>
|
||||||
|
<td>{% trans %}Payment method{% endtrans %}</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for i in customer.refillings.order_by('-date').filter(
|
||||||
|
date__year=year, date__month=month) %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ i.date|localtime|date(DATETIME_FORMAT) }} - {{ i.date|localtime|time(DATETIME_FORMAT) }}</td>
|
||||||
|
<td>{{ i.counter }}</td>
|
||||||
|
<td><a href="{{ i.operator.get_absolute_url() }}">{{ i.operator.get_display_name() }}</a></td>
|
||||||
|
<td>{{ i.amount }} €</td>
|
||||||
|
<td>{{ i.get_payment_method_display() }}</td>
|
||||||
|
{% if i.is_owned_by(user) %}
|
||||||
|
<td><a href="{{ url('counter:refilling_delete', refilling_id=i.id) }}">Delete</a></td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endif %}
|
||||||
{% if customer.user.invoices.exists() %}
|
{% if customer.user.invoices.exists() %}
|
||||||
<h4>{% trans %}Eboutic invoices{% endtrans %}</h4>
|
<h4>{% trans %}Eboutic invoices{% endtrans %}</h4>
|
||||||
<table>
|
<table>
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user.is_root %}
|
{% if user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user.is_root %}
|
||||||
<li><a href="{{ url('subscription:subscription') }}">{% trans %}Subscriptions{% endtrans %}</a></li>
|
<li><a href="{{ url('subscription:subscription') }}">{% trans %}Subscriptions{% endtrans %}</a></li>
|
||||||
|
<li><a href="{{ url('club:club_new') }}">{% trans %}New club{% endtrans %}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -319,22 +319,29 @@ class UserUpdateProfileView(UserTabsMixin, CanEditMixin, UpdateView):
|
|||||||
form_class = UserProfileForm
|
form_class = UserProfileForm
|
||||||
current_tab = "edit"
|
current_tab = "edit"
|
||||||
edit_once = ['profile_pict', 'date_of_birth', 'first_name', 'last_name']
|
edit_once = ['profile_pict', 'date_of_birth', 'first_name', 'last_name']
|
||||||
|
board_only = []
|
||||||
|
|
||||||
def remove_once_edited_fields(self, request):
|
def remove_restricted_fields(self, request):
|
||||||
|
"""
|
||||||
|
Removes edit_once and board_only fields
|
||||||
|
"""
|
||||||
for i in self.edit_once:
|
for i in self.edit_once:
|
||||||
if getattr(self.form.instance, i) and not (request.user.is_board_member or request.user.is_root):
|
if getattr(self.form.instance, i) and not (request.user.is_board_member or request.user.is_root):
|
||||||
self.form.fields.pop(i, None)
|
self.form.fields.pop(i, None)
|
||||||
|
for i in self.board_only:
|
||||||
|
if not (request.user.is_board_member or request.user.is_root):
|
||||||
|
self.form.fields.pop(i, None)
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
self.form = self.get_form()
|
self.form = self.get_form()
|
||||||
self.remove_once_edited_fields(request)
|
self.remove_restricted_fields(request)
|
||||||
return self.render_to_response(self.get_context_data(form=self.form))
|
return self.render_to_response(self.get_context_data(form=self.form))
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
self.form = self.get_form()
|
self.form = self.get_form()
|
||||||
self.remove_once_edited_fields(request)
|
self.remove_restricted_fields(request)
|
||||||
files = request.FILES.items()
|
files = request.FILES.items()
|
||||||
self.form.process(files)
|
self.form.process(files)
|
||||||
if request.user.is_authenticated() and request.user.can_edit(self.object) and self.form.is_valid():
|
if request.user.is_authenticated() and request.user.can_edit(self.object) and self.form.is_valid():
|
||||||
@ -420,10 +427,10 @@ class UserAccountView(UserAccountBase):
|
|||||||
date__year=month.year,
|
date__year=month.year,
|
||||||
date__month=month.month
|
date__month=month.month
|
||||||
)
|
)
|
||||||
stats[i].append((
|
stats[i].append({
|
||||||
sum([calc(p) for p in q]),
|
'sum':sum([calc(p) for p in q]),
|
||||||
month
|
'date':month
|
||||||
))
|
})
|
||||||
i += 1
|
i += 1
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
<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) }}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="action" value="code">
|
<input type="hidden" name="action" value="code">
|
||||||
<input type="input" name="code" value="" autofocus id="code_field"/>
|
<input type="input" name="code" value="" autofocus class="focus" id="code_field"/>
|
||||||
<input type="submit" value="{% trans %}Go{% endtrans %}" />
|
<input type="submit" value="{% trans %}Go{% endtrans %}" />
|
||||||
</form>
|
</form>
|
||||||
<p>{% trans %}Basket: {% endtrans %}</p>
|
<p>{% trans %}Basket: {% endtrans %}</p>
|
||||||
@ -174,6 +174,9 @@ $( function() {
|
|||||||
$( function() {
|
$( function() {
|
||||||
$("#bar_ui").accordion({
|
$("#bar_ui").accordion({
|
||||||
heightStyle: "content",
|
heightStyle: "content",
|
||||||
|
activate: function(event, ui){
|
||||||
|
$(".focus").focus();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
$("#products").tabs();
|
$("#products").tabs();
|
||||||
});
|
});
|
||||||
|
@ -63,6 +63,9 @@ class RefillForm(forms.ModelForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = Refilling
|
model = Refilling
|
||||||
fields = ['amount', 'payment_method', 'bank']
|
fields = ['amount', 'payment_method', 'bank']
|
||||||
|
widgets = {
|
||||||
|
'amount': forms.NumberInput(attrs={'class':'focus'},)
|
||||||
|
}
|
||||||
|
|
||||||
class CounterTabsMixin(TabedViewMixin):
|
class CounterTabsMixin(TabedViewMixin):
|
||||||
def get_tabs_title(self):
|
def get_tabs_title(self):
|
||||||
@ -278,6 +281,12 @@ class CounterClick(CounterTabsMixin, DetailView):
|
|||||||
if product.limit_age >= 18 and not self.customer.user.date_of_birth:
|
if product.limit_age >= 18 and not self.customer.user.date_of_birth:
|
||||||
request.session['no_age'] = True
|
request.session['no_age'] = True
|
||||||
return False
|
return False
|
||||||
|
if product.limit_age >= 18 and self.customer.user.is_banned_alcohol:
|
||||||
|
request.session['not_allowed'] = True
|
||||||
|
return False
|
||||||
|
if self.customer.user.is_banned_counter:
|
||||||
|
request.session['not_allowed'] = True
|
||||||
|
return False
|
||||||
if self.customer.user.date_of_birth and self.customer.user.get_age() < product.limit_age: # Check if affordable
|
if self.customer.user.date_of_birth and self.customer.user.get_age() < product.limit_age: # Check if affordable
|
||||||
request.session['too_young'] = True
|
request.session['too_young'] = True
|
||||||
return False
|
return False
|
||||||
@ -1016,7 +1025,7 @@ class EticketPDFView(CanViewMixin, DetailView):
|
|||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
eticket = self.object.product.eticket
|
eticket = self.object.product.eticket
|
||||||
user = self.object.customer.user
|
user = self.object.customer.user
|
||||||
code = "%s %s %s" % (self.object.customer.user.id, self.object.product.id, self.object.quantity)
|
code = "%s %s %s %s" % (self.object.customer.user.id, self.object.product.id, self.object.id, self.object.quantity)
|
||||||
code += " " + eticket.get_hash(code)[:8].upper()
|
code += " " + eticket.get_hash(code)[:8].upper()
|
||||||
response = HttpResponse(content_type='application/pdf')
|
response = HttpResponse(content_type='application/pdf')
|
||||||
response['Content-Disposition'] = 'filename="eticket.pdf"'
|
response['Content-Disposition'] = 'filename="eticket.pdf"'
|
||||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -256,6 +256,18 @@ SITH_GROUPS = {
|
|||||||
'id': 5,
|
'id': 5,
|
||||||
'name': "Counter admin",
|
'name': "Counter admin",
|
||||||
},
|
},
|
||||||
|
'banned-alcohol': {
|
||||||
|
'id': 6,
|
||||||
|
'name': "Banned from buying alcohol",
|
||||||
|
},
|
||||||
|
'banned-from-counters': {
|
||||||
|
'id': 7,
|
||||||
|
'name': "Banned from counters",
|
||||||
|
},
|
||||||
|
'banned-to-subscribe': {
|
||||||
|
'id': 8,
|
||||||
|
'name': "Banned to subscribe",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SITH_BOARD_SUFFIX="-bureau"
|
SITH_BOARD_SUFFIX="-bureau"
|
||||||
|
Loading…
Reference in New Issue
Block a user