Affichage et auth sur les caisses et relevés

- Auth K-Fêt fonctionne
- Affichage repris
This commit is contained in:
Aurélien Delobelle 2016-08-22 01:57:28 +02:00
parent 74c3f07c66
commit 90e8ece783
7 changed files with 117 additions and 54 deletions

View file

@ -1,22 +1,36 @@
{% extends "kfet/base.html" %}
{% block title %}Caisses{% endblock %}
{% block title %}Liste des caisses{% endblock %}
{% block content-header-title %}Caisses{% endblock %}
{% block content %}
<div class="row">
<div class="col-lg-12">
<div class="btn-group btn-group-lg">
<a class="btn btn-primary" href="{% url 'kfet.checkout.create' %}">Créer une caisse</a>
<div class="col-sm-4 col-md-3 col-content-left">
<div class="content-left">
<div class="content-left-top text-center">
<div class="line">{{ checkouts|length }} caisses</div>
</div>
<div class="buttons">
<a class="btn btn-primary btn-lg" href="{% url 'kfet.checkout.create' %}">Créer un compte</a>
</div>
</div>
</div>
<div class="col-sm-8 col-md-9 col-content-right">
{% include 'kfet/base_messages.html' %}
<div class="content-right">
<div class="content-right-block">
<h2>Liste des caisses</h2>
<div>
<ul>
{% for checkout in checkouts %}
<li><a href="{% url 'kfet.checkout.read' checkout.pk %}">{{ checkout }}</a></li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
</div>
<ul>
{% for checkout in checkouts %}
<li><a href="{% url 'kfet.checkout.read' checkout.pk %}">{{ checkout }}</a></li>
{% endfor %}
</ul>
{% endblock %}

View file

@ -16,6 +16,9 @@
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
{% endfor %}
{% if not perms.kfet.add_checkout %}
<input type="password" name="KFETPASSWORD">
{% endif %}
<input type="submit" value="Enregistrer">
</form>

View file

@ -6,32 +6,32 @@
{% block content %}
<div class="row">
<div class="col-lg-12">
<div class="btn-group btn-group-lg">
<a class="btn btn-primary{% if checkout.is_protected %} disabled{% endif %}" href="{% url 'kfet.checkout.update' checkout.pk %}">Modifier</a>
<a class="btn btn-primary" href="{% url 'kfet.checkoutstatement.create' checkout.pk %}">Effectuer un relevé</a>
<div class="col-sm-4 col-md-3 col-content-left">
<div class="content-left">
{% include 'kfet/left_checkout.html' %}
</div>
</div>
<div class="col-sm-8 col-md-9 col-content-right">
{% include "kfet/base_messages.html" %}
<div class="content-right">
<div class="content-right-block">
<h2>Relevés</h2>
<div>
{% with statements=checkout.statements.all %}
{% if not statements %}
Pas de relevé
{% else %}
<ul>
{% for statement in statements %}
<li>{{ statement }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</div>
</div>
</div>
</div>
</div>
<p>Nom: {{ checkout.name }}</p>
<p>Valide du {{ checkout.valid_from|date:'l j F Y, G:i' }} au {{ checkout.valid_to|date:'l j F Y, G:i' }}</p>
<p>Créée par: {{ checkout.created_by }}</p>
<p>Balance: {{ checkout.balance }} €</p>
<p>Protected: {{ checkout.is_protected }}</p>
Relevés:
{% with statements=checkout.statements.all %}
{% if not statements %}
Pas de relevé
{% else %}
<ul>
{% for statement in statements %}
<li>{{ statement }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</ul>
{% endblock %}

View file

@ -6,18 +6,35 @@
{% block content %}
<form action="" method="post">
{% csrf_token %}
{% for field in form %}
{{ field.errors }}
{{ field.label_tag }}
<div style="position:relative">{{ field }}</div>
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
{% endfor %}
<input type=submit value="Mettre à jour">
</form>
<div class="row">
<div class="col-sm-4 col-md-3 col-content-left">
<div class="content-left">
{% include 'kfet/left_checkout.html' %}
</div>
</div>
<div class="col-sm-8 col-md-9 col-content-right">
{% include "kfet/base_messages.html" %}
<div class="content-right">
<div class="content-right-block">
<form action="" method="post">
{% csrf_token %}
{% for field in form %}
{{ field.errors }}
{{ field.label_tag }}
<div style="position:relative">{{ field }}</div>
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
{% endfor %}
{% if not perms.kfet.add_checkout %}
<input type="password" name="KFETPASSWORD">
{% endif %}
<input type=submit value="Mettre à jour">
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">

View file

@ -5,12 +5,27 @@
{% block content %}
En caisse : {{ checkout.balance }}
<form action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Enregistrer">
</form>
<div class="row">
<div class="col-sm-4 col-md-3 col-content-left">
<div class="content-left">
{% include 'kfet/left_checkout.html' %}
</div>
</div>
<div class="col-sm-8 col-md-9 col-content-right">
{% include "kfet/base_messages.html" %}
<div class="content-right">
<div class="content-right-block">
<form action="" method="post">
{% csrf_token %}
{{ form.as_p }}
{% if not perms.ket.add_checkoutstatement %}
<input type="password" name="KFETPASSWORD">
{% endif %}
<input type="submit" value="Enregistrer">
</form>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,13 @@
<div class="content-left-top">
<div class="line trigramme">{{ checkout.name }}</div>
<div class="line balance">{{ checkout.balance|floatformat:2 }} €</div>
<div class="block">
<div class="line">Valide du {{ checkout.valid_from|date:'l j F Y, G:i' }}</div>
<div class="line">au {{ checkout.valid_to|date:'l j F Y, G:i' }}</div>
<div class="line">Créée par {{ checkout.created_by }}</div>
</div>
</div>
<div class="buttons">
<a class="btn btn-primary btn-lg {% if checkout.is_protected %} disabled{% endif %}" href="{% url 'kfet.checkout.update' checkout.pk %}">Modifier</a>
<a class="btn btn-primary btn-lg" href="{% url 'kfet.checkoutstatement.create' checkout.pk %}">Effectuer un relevé</a>
</div>

View file

@ -403,7 +403,8 @@ class CheckoutStatementCreate(SuccessMessageMixin, CreateView):
def form_valid(self, form):
# Checking permission
if not self.request.user.has_perm('kfet.add_checkoutstatement'):
raise PermissionDenied
form.add_error(None, 'Permission refusée')
return self.form_invalid(form)
# Creating
form.instance.checkout_id = self.kwargs['pk_checkout']
form.instance.by = self.request.user.profile.account_kfet