forked from DGNum/gestioCOF
kfet_open is updatable
This commit is contained in:
parent
0ac1eaf414
commit
4808650fa0
4 changed files with 53 additions and 1 deletions
24
kfet/migrations/00048_kfet_open_cache.py
Normal file
24
kfet/migrations/00048_kfet_open_cache.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('kfet', '0047_auto_20170104_1528'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='settings',
|
||||
name='value_boolean',
|
||||
field=models.NullBooleanField(default=None),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='settings',
|
||||
name='value_datetime',
|
||||
field=models.DateTimeField(blank=True, null=True, default=None),
|
||||
),
|
||||
]
|
|
@ -569,6 +569,8 @@ class GlobalPermissions(models.Model):
|
|||
('special_add_account', "Créer un compte avec une balance initiale")
|
||||
)
|
||||
|
||||
|
||||
|
||||
class Settings(models.Model):
|
||||
name = models.CharField(
|
||||
max_length = 45,
|
||||
|
|
|
@ -167,6 +167,9 @@ urlpatterns = [
|
|||
permission_required('kfet.change_settings')
|
||||
(views.SettingsUpdate.as_view()),
|
||||
name='kfet.settings.update'),
|
||||
url('^settings/kfet_open/$',
|
||||
views.UpdateKfetOpen.as_view(),
|
||||
name='kfet.settings.kfet_open'),
|
||||
|
||||
# -----
|
||||
# Transfers urls
|
||||
|
|
|
@ -7,7 +7,7 @@ from builtins import *
|
|||
from django.shortcuts import render, get_object_or_404, redirect
|
||||
from django.core.exceptions import PermissionDenied, ValidationError
|
||||
from django.core.cache import cache
|
||||
from django.views.generic import ListView, DetailView
|
||||
from django.views.generic import ListView, DetailView, View
|
||||
from django.views.generic.edit import CreateView, UpdateView, DeleteView, FormView
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.contrib import messages
|
||||
|
@ -40,6 +40,29 @@ import statistics
|
|||
def home(request):
|
||||
return render(request, "kfet/base.html")
|
||||
|
||||
|
||||
def KFET_OPEN():
|
||||
kfet_open_date = cache.get('KFET_OPEN_DATE')
|
||||
kfet_open = cache.get('KFET_OPEN')
|
||||
if not kfet_open_date:
|
||||
kfet_open_date = timezone.now()
|
||||
cache.set('KFET_OPEN_DATE', kfet_open_date)
|
||||
if not kfet_open:
|
||||
kfet_open = False
|
||||
cache.set('KFET_OPEN', kfet_open)
|
||||
return (kfet_open, kfet_open_date)
|
||||
|
||||
|
||||
class UpdateKfetOpen(View):
|
||||
def get(self, request, *args, **kwargs):
|
||||
open_string = request.GET.get('open')
|
||||
is_open = not (open_string == "false" or open_string == "False")
|
||||
cache.set('KFET_OPEN', is_open)
|
||||
cache.set('KFET_OPEN_DATE', timezone.now())
|
||||
(is_open_get, time) = KFET_OPEN()
|
||||
return HttpResponse("%r at %s" % (is_open_get, time.isoformat()))
|
||||
|
||||
|
||||
@teamkfet_required
|
||||
def login_genericteam(request):
|
||||
# Check si besoin de déconnecter l'utilisateur de CAS
|
||||
|
|
Loading…
Reference in a new issue