Correction nouveau neg

- Echec d'indentation corrigé
- Plus de CSS pour les pages normales
This commit is contained in:
Aurélien Delobelle 2016-08-20 01:20:06 +02:00
parent 056fb610de
commit 813b7230b6
6 changed files with 109 additions and 40 deletions

View file

@ -133,7 +133,7 @@ class Account(models.Model):
else:
overdraft_until = timezone.now() + overdraft_duration_max
# Checking it doesn't break 1 rule
if new_balance < overdraft_amount_max or timezone.now() > overdraft_until:
if new_balance < overdraft_amount or timezone.now() > overdraft_until:
stop_ope = True
perms.add('kfet.perform_negative_operations')
return perms, stop_ope

View file

@ -49,3 +49,46 @@ a:focus, a:hover {
text-transform:uppercase;
font-weight:bold;
}
.col-content-left, .col-content-right {
padding:0;
}
.content-left-top {
background:#fff;
padding:10px 30px;
}
.content-left .buttons {
background:#fff;
}
.content-left .buttons .btn {
display:block;
}
.content-left-top.frozen-account {
background:#000FBA;
color:#fff;
}
.content-left .block {
padding-top:10px;
}
.content-left .block .line {
font-size:16px;
line-height:30px;
}
.content-left .line.trigramme {
font-family:Oswald;
font-size:60px;
font-weight:bold;
text-align:center;
}
.content-left .line.balance {
font-size:45px;
text-align:center;
}

View file

@ -1,4 +1,5 @@
{% extends "kfet/base.html" %}
{% load kfet_tags %}
{% block title %}
{% if account.user == request.user %}
@ -19,35 +20,56 @@
{% 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.account.update' account.trigramme %}">
Modifier
</a>
<a class="btn btn-primary">Recharger par CB</a>
<div class="col-sm-4 col-md-3 col-content-left">
<div class="content-left">
<div class="content-left-top {% if account.is_frozen %}frozen-account{% endif %}">
<div class="line trigramme">{{ account.trigramme }}</div>
<div class="line balance">{{ account.balance|ukf:account.is_cof }} UKF</div>
<div class="block">
<div class="line">{{ account.name }}</div>
{% if perms.kfet.is_team %}
<div class="line">{{ account.nickname }}</div>
{% endif %}
<div class="line">
{% if account.email %}
{{ account.email }}
{% else %}
Pas d'email !
{% endif %}
</div>
<div class="line">
{{ account.departement }} {{ account.promo }}
</div>
<div class="line">Statut COF: {{ account.is_cof }}</div>
</div>
<div class="block block-neg">
{% if account.negative.start %}
<div class="line">En négatif depuis {{ account.negative.start }}</div>
{% endif %}
{% if account.negative.balance_offset %}
<div class="line">Solde réel: {{ account.real_balance }} €</div>
{% endif %}
{% if account.negative.authz_overdraft_amount %}
<div class="line">Découvert autorisé: {{ account.negative.authz_overdraft_amount }} €</div>
{% endif %}
{% if account.negative.authz_overdraft_until %}
<div class="line">Découvert autorisé jusqu'à : {{ account.negative.authz_overdraft_until }}</div>
{% endif %}
</div>
</div>
<div class="buttons">
<a class="btn btn-primary btn-lg" href="{% url 'kfet.account.update' account.trigramme %}">
Modifier
</a>
<a class="btn btn-primary btn-lg" disabled>
Recharger par CB
</a>
</div>
</div>
</div>
<div class="col-sm-8 col-md-9 col-content-right">
{% include "kfet/base_messages.html" %}
</div>
</div>
<p>Prénom: {{ account.first_name }}</p>
<p>Nom: {{ account.last_name }}</p>
{% if perms.kfet.is_team %}
<p>Surnom: {{ account.nickname }}</p>
{% endif %}
<p>Email: {{ account.email }}</p>
<p>Département: {{ account.departement }}</p>
<p>Promo: {{ account.promo }}</p>
<p>Statut COF: {{ account.is_cof }}</p>
<p>Compte gelé: {{ account.is_frozen }}</p>
<p>Solde: {{ account.balance }} €</p>
{% if account.negative.balance_offset %}
<p>Solde réel: {{ account.real_balance }} €</p>
{% endif %}
{% if account.negative.authorized_overdraft %}
<p>Découvert autorisé: {{ account.negative.authorized_overdraft }} €</p>
{% endif %}
{% if account.negative.start %}
<p>En négatif depuis {{ account.negative.start }}</p>
{% endif %}
{% endblock %}

View file

@ -36,7 +36,6 @@
</div>
</div>
{% endblock %}
{% include "kfet/base_messages.html" %}
{% block content %}{% endblock %}
{% include "kfet/base_footer.html" %}
</div>

View file

@ -1,6 +1,7 @@
from django import template
from django.utils.html import escape
from django.utils.safestring import mark_safe
from kfet.models import Settings
import re
register = template.Library()
@ -26,3 +27,7 @@ def highlight_clipper(clipper, q):
text = clipper.username
return highlight_text(escape(text), q)
@register.filter()
def ukf(balance, is_cof):
grant = is_cof and (1 + Settings.SUBVENTION_COF() / 100) or 1
return round(balance * 10 * grant)

View file

@ -545,17 +545,17 @@ def kpsul_perform_operations(request):
balance = F('balance') + operationgroup.amount)
operationgroup.on_acc.refresh_from_db()
if operationgroup.on_acc.balance < 0:
if hasattr(on_acc, 'negative'):
if not on_acc.negative.start:
on_acc.negative.start = timezone.now()
on_acc.negative.save()
else:
negative = AccountNegative(
account = operationgroup.on_acc, start = timezone.now())
negative.save()
elif (hasattr(on_acc, 'negative')
and not on_acc.negative.balance_offset):
on_acc.negative.delete()
if hasattr(operationgroup.on_acc, 'negative'):
if not operationgroup.on_acc.negative.start:
operationgroup.on_acc.negative.start = timezone.now()
operationgroup.on_acc.negative.save()
else:
negative = AccountNegative(
account = operationgroup.on_acc, start = timezone.now())
negative.save()
elif (hasattr(on_acc, 'negative')
and not on_acc.negative.balance_offset):
on_acc.negative.delete()
# Updating checkout's balance
if to_checkout_balance: