small fixes

This commit is contained in:
Qwann 2017-04-09 20:01:52 +02:00
parent e18c2c698c
commit 15873085e1
5 changed files with 12 additions and 29 deletions

View file

@ -26,11 +26,6 @@ class KPsul(JsonWebsocketConsumer):
pass pass
class KfetOpen(JsonWebsocketConsumer): class KfetOpen(JsonWebsocketConsumer):
# Set to True if you want them, else leave out
strict_ordering = False
slight_ordering = False
def connection_groups(self, **kwargs): def connection_groups(self, **kwargs):
return ['kfet.is_open'] return ['kfet.is_open']

View file

@ -9,6 +9,4 @@ def kfet_is_team(user):
def can_force_close(user): def can_force_close(user):
return user.has_perm('force_close_kfet') return user.has_perm('force_close_kfet')
teamkfet_required = user_passes_test(lambda u: kfet_is_team(u))
force_close_required = user_passes_test(lambda u: can_force_close(u))
teamkfet_required = user_passes_test(kfet_is_team) teamkfet_required = user_passes_test(kfet_is_team)

View file

@ -1,4 +1,4 @@
function kfet_open(init_date, init_satus, init_force_close, force_close_url, force_open_url) { function kfet_open(init_date, init_status, init_force_close, force_close_url, force_open_url) {
// VARIABLES // VARIABLES
var kfet_open_bullet = $('#kfet-open'); var kfet_open_bullet = $('#kfet-open');
var open_status = $('#open_status'); var open_status = $('#open_status');
@ -19,15 +19,15 @@ function kfet_open(init_date, init_satus, init_force_close, force_close_url, for
// EVENT // EVENT
force_close_button.click(forceClose); force_close_button.click(forceClose);
// INITIALISAITION // INITIALISATION
update_open(); update_open();
update_force_button(); update_force_button();
// On recherge toute les 30sec // On recharge toute les 30sec
// (dans le cas où le statut deviendrait inconn) // (dans le cas où le statut deviendrait inconnu)
setInterval(function() { setInterval(function() {
update_open(); update_open();
}, 30 * 1000); // 60 * 1000 milsec }, 30 * 1000); // 30 * 1000 milsec
// FONCTIONS // FONCTIONS
function forceClose(password = '') { function forceClose(password = '') {
@ -45,16 +45,12 @@ function kfet_open(init_date, init_satus, init_force_close, force_close_url, for
$xhr.setRequestHeader("KFetPassword", password); $xhr.setRequestHeader("KFetPassword", password);
}, },
}) })
.done(function() {})
.fail(function($xhr) { .fail(function($xhr) {
var data = $xhr.responseJSON; var data = $xhr.responseJSON;
switch ($xhr.status) { switch ($xhr.status) {
case 403: case 403:
requestAuth({'errors':{}}, forceClose); requestAuth({'errors':{}}, forceClose);
break; break;
case 400:
alert('lol');
break;
} }
lock = 0; lock = 0;
}); });
@ -89,7 +85,7 @@ function kfet_open(init_date, init_satus, init_force_close, force_close_url, for
open_status.html("?????"); open_status.html("?????");
} }
function update_open() { function update_open() {
nb_min = nb_min_diff(); var nb_min = nb_min_diff();
console.log("K-Fêt ouverte : " + (kfet_open&&(!force_close))); console.log("K-Fêt ouverte : " + (kfet_open&&(!force_close)));
console.log(nb_min + " minute(s) depuis la dernière mise à jour"); console.log(nb_min + " minute(s) depuis la dernière mise à jour");
if (force_close) { if (force_close) {

View file

@ -205,8 +205,9 @@ urlpatterns = [
url('^kfet_open/$', url('^kfet_open/$',
views.UpdateKfetOpen.as_view(), views.UpdateKfetOpen.as_view(),
name='kfet.kfet_open'), name='kfet.kfet_open'),
url('^force_close/$', url('^kfet_close/$',
views.UpdateForceClose.as_view(), permission_required('kfet.can_force_close')
(views.UpdateForceClose.as_view()),
name='kfet.force_close'), name='kfet.force_close'),
# ----- # -----

View file

@ -7,9 +7,8 @@ from django.shortcuts import render, get_object_or_404, redirect
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.core.cache import cache from django.core.cache import cache
from django.views.generic import ListView, DetailView, TemplateView, View from django.views.generic import ListView, DetailView, TemplateView, View
from django.views.generic.list import BaseListView, MultipleObjectTemplateResponseMixin from django.views.generic.detail import BaseDetailView
from django.views.generic.detail import BaseDetailView, SingleObjectTemplateResponseMixin from django.views.generic.edit import CreateView, UpdateView
from django.views.generic.edit import CreateView, UpdateView, DeleteView, FormView
from django.core.urlresolvers import reverse, reverse_lazy from django.core.urlresolvers import reverse, reverse_lazy
from django.contrib import messages from django.contrib import messages
from django.contrib.messages.views import SuccessMessageMixin from django.contrib.messages.views import SuccessMessageMixin
@ -25,7 +24,7 @@ from django.utils import timezone
from django.utils.crypto import get_random_string from django.utils.crypto import get_random_string
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
from gestioncof.models import CofProfile from gestioncof.models import CofProfile
from kfet.decorators import teamkfet_required, force_close_required from kfet.decorators import teamkfet_required
from kfet.models import ( from kfet.models import (
Account, Checkout, Article, Settings, AccountNegative, Account, Checkout, Article, Settings, AccountNegative,
CheckoutStatement, GenericTeamToken, Supplier, SupplierArticle, Inventory, CheckoutStatement, GenericTeamToken, Supplier, SupplierArticle, Inventory,
@ -125,12 +124,6 @@ class UpdateForceClose(View):
return HttpResponse("closed : %r at %s" % (force_close_get, return HttpResponse("closed : %r at %s" % (force_close_get,
time.isoformat())) time.isoformat()))
@method_decorator(login_required)
@method_decorator(teamkfet_required)
@method_decorator(force_close_required)
def dispatch(self, *args, **kwargs):
return super(UpdateForceClose, self).dispatch(*args, **kwargs)
@teamkfet_required @teamkfet_required
def login_genericteam(request): def login_genericteam(request):