few cleans

This commit is contained in:
Aurélien Delobelle 2017-04-05 04:26:50 +02:00
parent f1aaad7317
commit 6be6202b3f
3 changed files with 20 additions and 12 deletions

View file

@ -284,6 +284,11 @@ class Account extends APIModelObject {
return Urls['kfet.account.read'](trigramme_url);
}
static url_update_for(trigramme) {
var trigramme_url = encodeURIComponent(trigramme);
return Urls['kfet.account.update'](trigramme_url);
}
/**
* @default <tt>this.trigramme</tt>
*/
@ -352,6 +357,10 @@ class Checkout extends APIModelObject {
return Urls['kfet.checkout.read'](api_pk);
}
static url_update_for(api_pk) {
return Urls['kfet.checkout.update'](api_pk);
}
/**
* @default {@link Formatters.CheckoutFormatter}
*/

View file

@ -36,8 +36,8 @@ class AccountManager {
this.search = new AccountSearch(this);
// buttons: search, read or create
this.$buttons_container = this._$container.find('.buttons');
this.buttons_templates = {
this._$buttons_container = this._$container.find('.buttons');
this._buttons_templates = {
create: template`<a href="${'url'}" class="btn btn-primary" target="_blank" title="Créer ce compte"><span class="glyphicon glyphicon-plus"></span></a>`,
read: template`<a href="${'url'}" class="btn btn-primary" target="_blank" title="Détails du compte"><span class="glyphicon glyphicon-info-sign"></span></a>`,
search: template`<button class="btn btn-primary search" title="Rechercher"><span class="glyphicon glyphicon-search"></span></button>`,
@ -65,16 +65,16 @@ class AccountManager {
var trigramme = this.selection.get();
if (trigramme.isValidTri()) {
var url = Account.url_create(trigramme);
buttons = this.buttons_templates.create({url: url});
buttons = this._buttons_templates['create']({url: url});
} else { /* trigramme input is empty or invalid */
buttons = this.buttons_templates.search();
buttons = this._buttons_templates['search']();
}
} else { /* an account is loaded */
var url = this.account.url_read;
buttons = this.buttons_templates.read({url: url});
buttons = this._buttons_templates['read']({url: url});
}
this.$buttons_container.html(buttons);
this._$buttons_container.html(buttons);
}
update(trigramme) {
@ -261,8 +261,8 @@ class CheckoutManager {
this.laststatement = new Statement();
this.laststatement_display_prefix = '#checkout-last_statement_';
this.$buttons_container = this._$container.find('.buttons');
this.buttons_templates = {
this._$buttons_container = this._$container.find('.buttons');
this._buttons_templates = {
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>`,
}
@ -327,12 +327,12 @@ class CheckoutManager {
var buttons = '';
if (!this.is_empty()) {
var url_newcheckout = Statement.url_create(this.checkout.id);
buttons += this.buttons_templates.statement_create({
buttons += this._buttons_templates['statement_create']({
url: url_newcheckout});
var url_read = this.checkout.url_read;
buttons += this.buttons_templates.read({url: url_read});
buttons += this._buttons_templates['read']({url: url_read});
}
this.$buttons_container.html(buttons);
this._$buttons_container.html(buttons);
}
reset() {

View file

@ -62,7 +62,6 @@ class JSONResponseMixin(object):
"""
Returns a JSON response, transforming 'context' to make the payload.
"""
print(context)
return JsonResponse(
self.get_data(context),
**response_kwargs