forked from DGNum/gestioCOF
Commandes sur #13
- Un commentaire est demandé. Une permission est nécessaire (afin d'enregistrer la personne ayant enregistré la commande) - Fix annulation K-Psul. Appuyer sur Suppr appelait tout le temps `cancelOperations` même si aucune opération à supprimer n'était sélectionné.
This commit is contained in:
parent
bbbfd4aef5
commit
9e66137c09
5 changed files with 71 additions and 12 deletions
|
@ -222,7 +222,7 @@ class KPsulOperationGroupForm(forms.ModelForm):
|
||||||
widget = forms.HiddenInput())
|
widget = forms.HiddenInput())
|
||||||
class Meta:
|
class Meta:
|
||||||
model = OperationGroup
|
model = OperationGroup
|
||||||
fields = ['on_acc', 'checkout']
|
fields = ['on_acc', 'checkout', 'comment']
|
||||||
widgets = {
|
widgets = {
|
||||||
'on_acc' : forms.HiddenInput(),
|
'on_acc' : forms.HiddenInput(),
|
||||||
}
|
}
|
||||||
|
|
18
kfet/migrations/0035_auto_20160823_1505.py
Normal file
18
kfet/migrations/0035_auto_20160823_1505.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('kfet', '0034_auto_20160823_0206'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='globalpermissions',
|
||||||
|
options={'managed': False, 'permissions': (('is_team', 'Is part of the team'), ('perform_deposit', 'Effectuer une charge'), ('perform_negative_operations', 'Enregistrer des commandes en négatif'), ('override_frozen_protection', "Forcer le gel d'un compte"), ('cancel_old_operations', 'Annuler des commandes non récentes'), ('manage_perms', 'Gérer les permissions K-Fêt'), ('manage_addcosts', 'Gérer les majorations'), ('perform_commented_operations', 'Enregistrer des commandes avec commentaires'))},
|
||||||
|
),
|
||||||
|
]
|
|
@ -86,6 +86,10 @@ class Account(models.Model):
|
||||||
def is_cash(self):
|
def is_cash(self):
|
||||||
return self.trigramme == 'LIQ'
|
return self.trigramme == 'LIQ'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def need_comment(self):
|
||||||
|
return self.trigramme == '#13'
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_validandfree(trigramme):
|
def is_validandfree(trigramme):
|
||||||
data = { 'is_valid' : False, 'is_free' : False }
|
data = { 'is_valid' : False, 'is_free' : False }
|
||||||
|
@ -109,13 +113,13 @@ class Account(models.Model):
|
||||||
if self.is_cash:
|
if self.is_cash:
|
||||||
# Yes, so no perms and no stop
|
# Yes, so no perms and no stop
|
||||||
return set(), False
|
return set(), False
|
||||||
|
if self.need_comment:
|
||||||
|
perms.add('kfet.perform_commented_operations')
|
||||||
# Checking is frozen account
|
# Checking is frozen account
|
||||||
if self.is_frozen:
|
if self.is_frozen:
|
||||||
perms.add('kfet.override_frozen_protection')
|
perms.add('kfet.override_frozen_protection')
|
||||||
new_balance = self.balance + amount
|
new_balance = self.balance + amount
|
||||||
if new_balance < 0 and amount < 0:
|
if new_balance < 0 and amount < 0:
|
||||||
print(new_balance)
|
|
||||||
print(amount)
|
|
||||||
# Retrieving overdraft amount limit
|
# Retrieving overdraft amount limit
|
||||||
if (hasattr(self, 'negative')
|
if (hasattr(self, 'negative')
|
||||||
and self.negative.authz_overdraft_amount is not None):
|
and self.negative.authz_overdraft_amount is not None):
|
||||||
|
@ -518,6 +522,7 @@ class GlobalPermissions(models.Model):
|
||||||
('cancel_old_operations', 'Annuler des commandes non récentes'),
|
('cancel_old_operations', 'Annuler des commandes non récentes'),
|
||||||
('manage_perms', 'Gérer les permissions K-Fêt'),
|
('manage_perms', 'Gérer les permissions K-Fêt'),
|
||||||
('manage_addcosts', 'Gérer les majorations'),
|
('manage_addcosts', 'Gérer les majorations'),
|
||||||
|
('perform_commented_operations', 'Enregistrer des commandes avec commentaires'),
|
||||||
)
|
)
|
||||||
|
|
||||||
class Settings(models.Model):
|
class Settings(models.Model):
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
|
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
<form id="operationgroup_form">{{ operationgroup_form }}</form>
|
|
||||||
|
|
||||||
<div class="row kpsul_top">
|
<div class="row kpsul_top">
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="row" id="account">
|
<div class="row" id="account">
|
||||||
|
@ -100,9 +98,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form id="operation_formset" style="display:none">
|
<form id="operationgroup_form" style="display:none;">{{ operationgroup_form }}</form>
|
||||||
{{ operation_formset.as_p }}
|
<form id="operation_formset" style="display:none;">{{ operation_formset }}</form>
|
||||||
</form>
|
|
||||||
|
|
||||||
<div style="display:none;" id="operation_empty_html" data-opeindex="__prefix__">
|
<div style="display:none;" id="operation_empty_html" data-opeindex="__prefix__">
|
||||||
{{ operation_formset.empty_form }}
|
{{ operation_formset.empty_form }}
|
||||||
|
@ -351,7 +348,7 @@ $(document).ready(function() {
|
||||||
callback(password);
|
callback(password);
|
||||||
},
|
},
|
||||||
onOpen: function() {
|
onOpen: function() {
|
||||||
var that = this
|
var that = this;
|
||||||
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();
|
||||||
|
@ -361,6 +358,34 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function askComment(callback) {
|
||||||
|
var comment = $('#id_comment').val();
|
||||||
|
$.confirm({
|
||||||
|
title: 'Commentaire requis',
|
||||||
|
content: '<input type="text" name="comment_opegroup" value="'+comment+'" autofocus>',
|
||||||
|
backgroundDismiss: true,
|
||||||
|
animation: 'top',
|
||||||
|
closeAnimation: 'bottom',
|
||||||
|
keyboardEnabled: true,
|
||||||
|
confirm: function() {
|
||||||
|
$('#id_comment').val(this.$content.find('input').val());
|
||||||
|
callback();
|
||||||
|
},
|
||||||
|
onOpen: function() {
|
||||||
|
var that = this;
|
||||||
|
this.$content.find('input').on('keypress', function(e) {
|
||||||
|
if (e.keyCode == 13)
|
||||||
|
that.$confirmButton.click();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onClose: function() { this._lastFocused = articleSelect; }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetComment() {
|
||||||
|
$('#id_comment').val('');
|
||||||
|
}
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
// Errors ajax
|
// Errors ajax
|
||||||
// -----
|
// -----
|
||||||
|
@ -438,7 +463,11 @@ $(document).ready(function() {
|
||||||
requestAuth(data, performOperations);
|
requestAuth(data, performOperations);
|
||||||
break;
|
break;
|
||||||
case 400:
|
case 400:
|
||||||
displayErrors(getErrorsHtml(data));
|
if ('need_comment' in data['errors']) {
|
||||||
|
askComment(performOperations);
|
||||||
|
} else {
|
||||||
|
displayErrors(getErrorsHtml(data));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -705,7 +734,6 @@ $(document).ready(function() {
|
||||||
|
|
||||||
function addPurchase(id, nb) {
|
function addPurchase(id, nb) {
|
||||||
var amount_euro = amountEuroPurchase(id, nb).toFixed(2);
|
var amount_euro = amountEuroPurchase(id, nb).toFixed(2);
|
||||||
console.log(amount_euro);
|
|
||||||
var index = addPurchaseToFormset(article_data[1], nb, amount_euro);
|
var index = addPurchaseToFormset(article_data[1], nb, amount_euro);
|
||||||
article_basket_html = $(item_basket_default_html);
|
article_basket_html = $(item_basket_default_html);
|
||||||
article_basket_html
|
article_basket_html
|
||||||
|
@ -1165,7 +1193,8 @@ $(document).ready(function() {
|
||||||
history_container.find('.ope.ui-selected').each(function () {
|
history_container.find('.ope.ui-selected').each(function () {
|
||||||
opes_to_cancel.push($(this).attr('data-ope'));
|
opes_to_cancel.push($(this).attr('data-ope'));
|
||||||
});
|
});
|
||||||
cancelOperations(opes_to_cancel);
|
if (opes_to_cancel.length > 0)
|
||||||
|
cancelOperations(opes_to_cancel);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1239,6 +1268,7 @@ $(document).ready(function() {
|
||||||
function coolReset(give_tri_focus=true) {
|
function coolReset(give_tri_focus=true) {
|
||||||
resetAccount();
|
resetAccount();
|
||||||
resetBasket();
|
resetBasket();
|
||||||
|
resetComment();
|
||||||
resetSelectable();
|
resetSelectable();
|
||||||
if (give_tri_focus)
|
if (give_tri_focus)
|
||||||
triInput.focus();
|
triInput.focus();
|
||||||
|
|
|
@ -719,6 +719,12 @@ def kpsul_perform_operations(request):
|
||||||
amount = operationgroup.amount)
|
amount = operationgroup.amount)
|
||||||
required_perms |= perms
|
required_perms |= perms
|
||||||
|
|
||||||
|
if operationgroup.on_acc.need_comment:
|
||||||
|
operationgroup.comment = operationgroup.comment.strip()
|
||||||
|
if not operationgroup.comment:
|
||||||
|
data['errors']['need_comment'] = True
|
||||||
|
return JsonResponse(data, status=400)
|
||||||
|
|
||||||
if stop or not request.user.has_perms(required_perms):
|
if stop or not request.user.has_perms(required_perms):
|
||||||
missing_perms = get_missing_perms(required_perms, request.user)
|
missing_perms = get_missing_perms(required_perms, request.user)
|
||||||
if missing_perms:
|
if missing_perms:
|
||||||
|
|
Loading…
Add table
Reference in a new issue