Prettier display

This commit is contained in:
Hugo LEVY-FALK 2018-12-14 18:25:26 +01:00
parent 1d08459618
commit a2b7b45327
4 changed files with 49 additions and 52 deletions

View file

@ -30,8 +30,7 @@
<nav id="nav"> <nav id="nav">
<ul> <ul>
<li class="current"><a href="{% url 'index' %}">Home</a></li> <li class="current"><a href="{% url 'index' %}">Home</a></li>
<li><a href="">Imprimer</a></li> <li><a href="{% url 'search' %}">Imprimer</a></li>
<li><a href="">Comptes</a></li>
</ul> </ul>
</nav> </nav>
@ -39,9 +38,11 @@
<section id="main"> <section id="main">
<div class="container"> <div class="container">
<div class="row gtr-200"> <div class="row gtr-200">
<div class="col-12"> <div class="col-2"></div>
<div class="col-8">
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
<div class="col-2"></div>
</div> </div>
</div> </div>
</section> </section>
@ -49,39 +50,6 @@
<!-- Footer --> <!-- Footer -->
<footer id="footer"> <footer id="footer">
<div class="container"> <div class="container">
<div class="row gtr-200">
<div class="col-12">
<!-- About -->
<section>
<h2 class="major"><span>What's this about?</span></h2>
<p>
This is <strong>TXT</strong>, yet another free responsive site template designed by
<a href="http://twitter.com/ajlkn">AJ</a> for <a href="http://html5up.net">HTML5 UP</a>. It's released under the
<a href="http://html5up.net/license/">Creative Commons Attribution</a> license so feel free to use it for
whatever you're working on (personal or commercial), just be sure to give us credit for the design.
That's basically it :)
</p>
</section>
</div>
<div class="col-12">
<!-- Contact -->
<section>
<h2 class="major"><span>Get in touch</span></h2>
<ul class="contact">
<li><a class="icon fa-facebook" href="#"><span class="label">Facebook</span></a></li>
<li><a class="icon fa-twitter" href="#"><span class="label">Twitter</span></a></li>
<li><a class="icon fa-instagram" href="#"><span class="label">Instagram</span></a></li>
<li><a class="icon fa-dribbble" href="#"><span class="label">Dribbble</span></a></li>
<li><a class="icon fa-linkedin" href="#"><span class="label">LinkedIn</span></a></li>
</ul>
</section>
</div>
</div>
<!-- Copyright --> <!-- Copyright -->
<div id="copyright"> <div id="copyright">
<ul class="menu"> <ul class="menu">

View file

@ -1,10 +1,11 @@
{% extends 'account/base.html' %} {% extends 'account/base.html' %}
{% block content %} {% block content %}
{% if title %}<h1>{{ title }}</h1>{% endif %}
<form action="" method="post"> <form action="" method="post">
{% csrf_token %} {% csrf_token %}
{{ form }} {{ form }}
<br/> <br/>
<input type="submit" value="Envoyer"> <input type="submit" value="{{ submit|default:"Envoyer" }}">
</form> </form>
{% endblock %} {% endblock %}

View file

@ -1,11 +1,12 @@
{% extends 'account/base.html' %} {% extends 'account/base.html' %}
{% block content %} {% block content %}
<h1>Rechercher un compte</h1>
<form action="" method="post"> <form action="" method="post">
{% csrf_token %} {% csrf_token %}
{{ form }} {{ form }}
<br/> <br/>
<input type="submit" value="Envoyer"> <input type="submit" value="Chercher">
</form> </form>
<table> <table>
<tr> <tr>

View file

@ -26,7 +26,12 @@ def refill_balance(request, pk):
return render( return render(
request, request,
'account/form.html', 'account/form.html',
locals() {
'account': account,
'form': form,
'title': "Recharge du solde",
'submit': "Recharger"
}
) )
@login_required @login_required
@ -45,15 +50,20 @@ def pay(request, pk):
return render( return render(
request, request,
'account/form.html', 'account/form.html',
locals() {
'account': account,
'form': form,
'title': "Paiement d'une impression",
'submit': "Payer"
}
) )
@login_required @login_required
def reset_balance(request, pk): def reset_balance(request, pk):
account = get_object_or_404(Account, pk=pk) account = get_object_or_404(Account, pk=pk)
account.calc_balance()
if request.POST: if request.POST:
account.calc_balance()
sale = Sale() sale = Sale()
sale.price = - account.balance sale.price = - account.balance
sale.title = "Remise à zéro du solde." sale.title = "Remise à zéro du solde."
@ -62,11 +72,17 @@ def reset_balance(request, pk):
account.calc_balance() account.calc_balance()
account.save() account.save()
return redirect(reverse('index')) return redirect(reverse('index'))
elif account.balance is 0:
return redirect(reverse('index'))
return render( return render(
request, request,
'account/form.html', 'account/form.html',
locals() {
'account': account,
'title': "Rendre {}".format(account.balance),
'submit': "Argent rendu"
}
) )
@login_required @login_required
@ -80,27 +96,30 @@ def create_account(request):
return render( return render(
request, request,
'account/form.html', 'account/form.html',
locals() {
'form': form,
'title': "Créer un compte",
'submit': "Créer"
}
) )
@login_required @login_required
def search(request): def search(request):
form = SearchForm(request.POST or None) form = SearchForm(request.POST or None)
accounts = Account.objects.order_by('firstname')
if form.is_valid(): if form.is_valid():
string = form.cleaned_data['search'] string = form.cleaned_data['search']
accounts = Account.objects.filter(firstname__istartswith=string)\ accounts = Account.objects.filter(firstname__istartswith=string)\
| Account.objects.filter(lastname__istartswith=string)\ | Account.objects.filter(lastname__istartswith=string)\
| Account.objects.filter(email__istartswith=string) | Account.objects.filter(email__istartswith=string)
return render(
request,
'account/list_accounts.html',
locals()
)
accounts = Account.objects.order_by('firstname')
return render( return render(
request, request,
'account/list_accounts.html', 'account/list_accounts.html',
locals() {
'accounts': accounts,
'form': form,
}
) )
@login_required @login_required
@ -122,7 +141,11 @@ def article(request, pk):
return render( return render(
request, request,
'account/form.html', 'account/form.html',
locals() {
'form': form,
'submit': "Éditer",
'title': "Édition d'un article"
}
) )
@login_required @login_required
@ -134,7 +157,11 @@ def new_article(request):
return render( return render(
request, request,
'account/form.html', 'account/form.html',
locals() {
'form': form,
'submit': "Créer",
'title': "Création d'un article"
}
) )
@login_required @login_required