Merge branch 'aureplop/kpsul_js_refactor' into aureplop/js_basket
This commit is contained in:
commit
51083f9195
2 changed files with 28 additions and 1 deletions
|
@ -298,6 +298,8 @@ class CheckoutManager {
|
|||
read: template`<a class="btn btn-primary" href="${'url'}" title="En savoir plus" target="_blank"><span class="glyphicon glyphicon-info-sign"></span></a>`,
|
||||
statement_create: template`<a href="${'url'}" title="Effectuer un relevé" class="btn btn-primary" target="_blank"><span class="glyphicon glyphicon-euro"></span></a>`,
|
||||
};
|
||||
|
||||
OperationWebSocket.add_handler(data => this.update_data(data));
|
||||
}
|
||||
|
||||
update(id) {
|
||||
|
@ -326,6 +328,14 @@ class CheckoutManager {
|
|||
|
||||
}
|
||||
|
||||
update_data(ws_data) {
|
||||
let data = ws_data["checkouts"].find(o => o.id === this.checkout.id);
|
||||
if (!data)
|
||||
return;
|
||||
this.checkout.update(data);
|
||||
this._update_on_success(data);
|
||||
}
|
||||
|
||||
is_empty() { return this.checkout.is_empty(); }
|
||||
|
||||
display() {
|
||||
|
|
|
@ -765,7 +765,24 @@ class CheckoutStatementCreate(SuccessMessageMixin, CreateView):
|
|||
form.instance.balance_new = getAmountBalance(form.cleaned_data)
|
||||
form.instance.checkout_id = self.kwargs['pk_checkout']
|
||||
form.instance.by = self.request.user.profile.account_kfet
|
||||
return super(CheckoutStatementCreate, self).form_valid(form)
|
||||
res = super(CheckoutStatementCreate, self).form_valid(form)
|
||||
|
||||
ws_data = {
|
||||
'id': self.object.id,
|
||||
'at': self.object.at,
|
||||
'balance_new': self.object.balance_new,
|
||||
'balance_old': self.object.balance_old,
|
||||
'by': str(self.object.by),
|
||||
}
|
||||
consumers.KPsul.group_send('kfet.kpsul', {
|
||||
'checkouts': [{
|
||||
'id': self.object.checkout.id,
|
||||
'laststatement': ws_data,
|
||||
}],
|
||||
})
|
||||
|
||||
return res
|
||||
|
||||
|
||||
class CheckoutStatementUpdate(SuccessMessageMixin, UpdateView):
|
||||
model = CheckoutStatement
|
||||
|
|
Loading…
Reference in a new issue