From 75329f510df704ec19b776331aea81e99145fbf1 Mon Sep 17 00:00:00 2001 From: Nanoy Date: Sun, 20 Jan 2019 12:14:53 +0100 Subject: [PATCH] Automatic logout --- coopeV3/templatetags/vip.py | 6 +++++ .../migrations/0007_auto_20190120_1208.py | 23 +++++++++++++++++++ preferences/models.py | 1 + .../preferences/general_preferences.html | 8 +++++++ templates/base.html | 11 +++++++++ 5 files changed, 49 insertions(+) create mode 100644 preferences/migrations/0007_auto_20190120_1208.py diff --git a/coopeV3/templatetags/vip.py b/coopeV3/templatetags/vip.py index 3d49afa..436cb03 100644 --- a/coopeV3/templatetags/vip.py +++ b/coopeV3/templatetags/vip.py @@ -39,3 +39,9 @@ def global_message(): gp,_ = GeneralPreferences.objects.get_or_create(pk=1) messages = gp.global_message.split("\n") return random.choice(messages) + +@register.simple_tag +def logout_time(): + gp, _ = GeneralPreferences.objects.get_or_create(pk=1) + logout_time = gp.automatic_logout_time + return logout_time \ No newline at end of file diff --git a/preferences/migrations/0007_auto_20190120_1208.py b/preferences/migrations/0007_auto_20190120_1208.py new file mode 100644 index 0000000..18d808a --- /dev/null +++ b/preferences/migrations/0007_auto_20190120_1208.py @@ -0,0 +1,23 @@ +# Generated by Django 2.1 on 2019-01-20 11:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('preferences', '0006_auto_20190119_2326'), + ] + + operations = [ + migrations.AddField( + model_name='generalpreferences', + name='automatic_logout_time', + field=models.PositiveIntegerField(null=True), + ), + migrations.AddField( + model_name='historicalgeneralpreferences', + name='automatic_logout_time', + field=models.PositiveIntegerField(null=True), + ), + ] diff --git a/preferences/models.py b/preferences/models.py index e5eada9..f4d1ce6 100644 --- a/preferences/models.py +++ b/preferences/models.py @@ -35,6 +35,7 @@ class GeneralPreferences(models.Model): lost_pintes_allowed = models.PositiveIntegerField(default=0) floating_buttons = models.BooleanField(default=False) home_text = models.TextField(blank=True) + automatic_logout_time = models.PositiveIntegerField(null=True) history = HistoricalRecords() class Cotisation(models.Model): diff --git a/preferences/templates/preferences/general_preferences.html b/preferences/templates/preferences/general_preferences.html index 44acc57..5c1e047 100644 --- a/preferences/templates/preferences/general_preferences.html +++ b/preferences/templates/preferences/general_preferences.html @@ -136,6 +136,14 @@
+

Déconnexion automatique

+
+
+ {{form.automatic_logout_time}} + +
+
+

Texte de la page d'accueil

diff --git a/templates/base.html b/templates/base.html index 98c4c04..b4c0ed2 100644 --- a/templates/base.html +++ b/templates/base.html @@ -44,5 +44,16 @@ {% include 'footer.html'%}
+ {% if request.user.is_authenticated %} + + {% endif %}