Merge branch 'k-fet' of git.eleves.ens.fr:cof-geek/gestioCOF into qwann/k-fet/stats

This commit is contained in:
Qwann 2016-12-11 20:45:52 +01:00
commit 4da9327666
5 changed files with 77 additions and 26 deletions

View file

@ -64,3 +64,22 @@
color:#FFF !important; color:#FFF !important;
background:#C8102E !important; background:#C8102E !important;
} }
.jconfirm .capslock {
position: relative ;
}
.jconfirm .capslock .glyphicon {
position: absolute;
padding: 10px;
right: 0px;
top: 15px;
font-size: 30px;
display: none ;
margin-left: 60px !important;
}
.jconfirm .capslock input {
padding-right: 50px;
padding-left: 50px;
}

View file

@ -88,7 +88,7 @@ function getErrorsHtml(data) {
function requestAuth(data, callback, focus_next = null) { function requestAuth(data, callback, focus_next = null) {
var content = getErrorsHtml(data); var content = getErrorsHtml(data);
content += '<input type="password" name="password" autofocus>', content += '<div class="capslock"><span class="glyphicon glyphicon-lock"></span><input type="password" name="password" autofocus><div>',
$.confirm({ $.confirm({
title: 'Authentification requise', title: 'Authentification requise',
content: content, content: content,
@ -102,14 +102,39 @@ function requestAuth(data, callback, focus_next = null) {
}, },
onOpen: function() { onOpen: function() {
var that = this; var that = this;
var capslock = -1 ; // 1 -> caps on ; 0 -> caps off ; -1 or 2 -> unknown
this.$content.find('input').on('keypress', function(e) { this.$content.find('input').on('keypress', function(e) {
if (e.keyCode == 13) if (e.keyCode == 13)
that.$confirmButton.click(); that.$confirmButton.click();
var s = String.fromCharCode(e.which);
if ((s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey)|| //caps on, shift off
(s.toUpperCase() !== s && s.toLowerCase() === s && e.shiftKey)) { //caps on, shift on
capslock = 1 ;
} else if ((s.toLowerCase() === s && s.toUpperCase() !== s && !e.shiftKey)|| //caps off, shift off
(s.toLowerCase() !== s && s.toUpperCase() === s && e.shiftKey)) { //caps off, shift on
capslock = 0 ;
}
if (capslock == 1)
$('.capslock .glyphicon').show() ;
else if (capslock == 0)
$('.capslock .glyphicon').hide() ;
});
// Capslock key is not detected by keypress
this.$content.find('input').on('keydown', function(e) {
if (e.which == 20) {
capslock = 1-capslock ;
}
if (capslock == 1)
$('.capslock .glyphicon').show() ;
else if (capslock == 0)
$('.capslock .glyphicon').hide() ;
}); });
}, },
onClose: function() { onClose: function() {
if (focus_next) if (focus_next)
this._lastFocused = focus_next; this._lastFocused = focus_next;
} }
}); });
} }

View file

@ -48,11 +48,11 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-xs-3"><b>F2</b></div> <div class="col-xs-3"><b>F2</b></div>
<div class="col-xs-9">Reset compte</div> <div class="col-xs-9">Reset panier</div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-xs-3"><b>Shift + F2</b></div> <div class="col-xs-3"><b>Shift + F2</b></div>
<div class="col-xs-9">Reset panier</div> <div class="col-xs-9">Reset compte</div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-xs-3"><b>F9</b></div> <div class="col-xs-3"><b>F9</b></div>
@ -114,10 +114,10 @@
<div class="kpsul_middle_left"> <div class="kpsul_middle_left">
<div class="kpsul_middle_left_top"> <div class="kpsul_middle_left_top">
<div id="special_operations"> <div id="special_operations">
<button role="button" class="btn" id="operation_deposit">Charge</button> <button role="button" class="btn" id="operation_deposit">Charge (F3)</button>
<button role="button" class="btn" id="operation_withdraw">Retrait</button> <button role="button" class="btn" id="operation_withdraw">Retrait (Shift+F3)</button>
<button role="button" class="btn" id="cool_reset">RAZ</button> <button role="button" class="btn" id="cool_reset">RAZ (F1)</button>
<button role="button" class="btn" id="ask_addcost">Major.</button> <button role="button" class="btn" id="ask_addcost">Major. (F9)</button>
</div> </div>
<div id="article_selection"> <div id="article_selection">
<input type="text" id="article_autocomplete" autocomplete="off"> <input type="text" id="article_autocomplete" autocomplete="off">
@ -245,12 +245,14 @@ $(document).ready(function() {
if (account_data['id'] != 0) { if (account_data['id'] != 0) {
var url_base = '{% url 'kfet.account.read' 'LIQ' %}'; var url_base = '{% url 'kfet.account.read' 'LIQ' %}';
url_base = url_base.substr(0, url_base.length - 3); url_base = url_base.substr(0, url_base.length - 3);
buttons += '<a href="'+ url_base + account_data['trigramme']+'" class="btn btn-primary" target="_blank" title="Modifier"><span class="glyphicon glyphicon-cog"></span></a>'; trigramme = encodeURIComponent(account_data['trigramme']) ;
buttons += '<a href="'+ url_base + trigramme +'" class="btn btn-primary" target="_blank" title="Modifier"><span class="glyphicon glyphicon-cog"></span></a>';
} }
if (account_data['id'] == 0) { if (account_data['id'] == 0) {
var trigramme = triInput.val().toUpperCase(); var trigramme = triInput.val().toUpperCase();
var url_base = '{% url 'kfet.account.create' %}' var url_base = '{% url 'kfet.account.create' %}'
if (isValidTrigramme(trigramme)) { if (isValidTrigramme(trigramme)) {
trigramme = encodeURIComponent(trigramme);
buttons += '<a href="'+url_base+'?trigramme='+trigramme+'" class="btn btn-primary" target="_blank" title="Créer"><span class="glyphicon glyphicon-plus"></span></a>'; buttons += '<a href="'+url_base+'?trigramme='+trigramme+'" class="btn btn-primary" target="_blank" title="Créer"><span class="glyphicon glyphicon-plus"></span></a>';
} }
} }
@ -924,7 +926,7 @@ $(document).ready(function() {
} }
}); });
}, },
onClose: function() { this._lastFocused = articleSelect; } onClose: function() { this._lastFocused = (articleSelect.val() ? articleNb : articleSelect) ; }
}); });
} }
@ -1250,13 +1252,13 @@ $(document).ready(function() {
return false; return false;
case 113: case 113:
if (e.shiftKey) { if (e.shiftKey) {
// Shift+F2 - Basket reset // Shift+F2 - Account reset
resetBasket();
articleSelect.focus();
} else {
// F2 - Account reset
resetAccount(); resetAccount();
triInput.focus(); triInput.focus();
} else {
// F2 - Basket reset
resetBasket();
articleSelect.focus();
} }
return false; return false;
case 114: case 114:

View file

@ -34,12 +34,12 @@
<tr class="transfer_form" id="{{ form.prefix }}"> <tr class="transfer_form" id="{{ form.prefix }}">
<td class="from_acc_data"></td> <td class="from_acc_data"></td>
<td class="from_acc"> <td class="from_acc">
<input type="text" name="from_acc" class="input_from_acc" autocomplete="off" spellcheck="false"> <input type="text" name="from_acc" class="input_from_acc" maxlength="3" autocomplete="off" spellcheck="false">
{{ form.from_acc }} {{ form.from_acc }}
</td> </td>
<td class="amount">{{ form.amount }}</td> <td class="amount">{{ form.amount }}</td>
<td class="to_acc"> <td class="to_acc">
<input type="text" name="to_acc" class="input_to_acc" autocomplete="off" spellcheck="false"> <input type="text" name="to_acc" class="input_to_acc" maxlength="3" autocomplete="off" spellcheck="false">
{{ form.to_acc }} {{ form.to_acc }}
</td> </td>
<td class="to_acc_data"></td> <td class="to_acc_data"></td>
@ -71,18 +71,21 @@ $(document).ready(function () {
var $next = $form.next('.transfer_form').find('.from_acc input'); var $next = $form.next('.transfer_form').find('.from_acc input');
} }
var $input_id = $input.next('input'); var $input_id = $input.next('input');
getAccountData(trigramme, function(data) { if (isValidTrigramme(trigramme)) {
$input_id.val(data.id); getAccountData(trigramme, function(data) {
$data.text(data.name); $input_id.val(data.id);
$next.focus(); $data.text(data.name);
}); $next.focus();
});
} else {
$input_id.val('');
$data.text('');
}
} }
$('.input_from_acc, .input_to_acc').on('input', function() { $('.input_from_acc, .input_to_acc').on('input', function() {
var tri = $(this).val().toUpperCase(); var tri = $(this).val().toUpperCase();
if (isValidTrigramme(tri)) { updateAccountData(tri, $(this));
updateAccountData(tri, $(this));
}
}); });
$('#transfers_form').on('submit', function(e) { $('#transfers_form').on('submit', function(e) {

View file

@ -493,7 +493,8 @@ class AccountGroupUpdate(UpdateView):
class AccountNegativeList(ListView): class AccountNegativeList(ListView):
queryset = (AccountNegative.objects queryset = (AccountNegative.objects
.select_related('account', 'account__cofprofile__user')) .select_related('account', 'account__cofprofile__user')
.exclude(account__trigramme='#13'))
template_name = 'kfet/account_negative.html' template_name = 'kfet/account_negative.html'
context_object_name = 'negatives' context_object_name = 'negatives'
@ -504,12 +505,13 @@ class AccountNegativeList(ListView):
'overdraft_duration': Settings.OVERDRAFT_DURATION(), 'overdraft_duration': Settings.OVERDRAFT_DURATION(),
} }
negs_sum = (AccountNegative.objects negs_sum = (AccountNegative.objects
.exclude(account__trigramme='#13')
.aggregate( .aggregate(
bal = Coalesce(Sum('account__balance'),0), bal = Coalesce(Sum('account__balance'),0),
offset = Coalesce(Sum('balance_offset'),0), offset = Coalesce(Sum('balance_offset'),0),
) )
) )
context['negatives_sum'] = negs_sum['bal'] + negs_sum['offset'] context['negatives_sum'] = negs_sum['bal'] - negs_sum['offset']
return context return context
# ----- # -----