3
0
Fork 0
mirror of https://github.com/nanoy42/coope synced 2024-11-29 08:02:25 +00:00

Merge branch 'automatic_lock' into dev

This commit is contained in:
Yoann Pétri 2019-01-20 12:15:14 +01:00
commit d421f4af4c
5 changed files with 49 additions and 0 deletions

View file

@ -39,3 +39,9 @@ def global_message():
gp,_ = GeneralPreferences.objects.get_or_create(pk=1) gp,_ = GeneralPreferences.objects.get_or_create(pk=1)
messages = gp.global_message.split("\n") messages = gp.global_message.split("\n")
return random.choice(messages) 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

View file

@ -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),
),
]

View file

@ -35,6 +35,7 @@ class GeneralPreferences(models.Model):
lost_pintes_allowed = models.PositiveIntegerField(default=0) lost_pintes_allowed = models.PositiveIntegerField(default=0)
floating_buttons = models.BooleanField(default=False) floating_buttons = models.BooleanField(default=False)
home_text = models.TextField(blank=True) home_text = models.TextField(blank=True)
automatic_logout_time = models.PositiveIntegerField(null=True)
history = HistoricalRecords() history = HistoricalRecords()
class Cotisation(models.Model): class Cotisation(models.Model):

View file

@ -136,6 +136,14 @@
</div> </div>
</div> </div>
<br> <br>
<h3>Déconnexion automatique</h3>
<div class="row uniform">
<div class="12u">
{{form.automatic_logout_time}}
<label for="{{form.automatic_logout_time.id_for_label}}">Temps (en minutes) au bout duquel l'utilisateur est déconnecté automatiquement (0 pour qu'il reste connecté)</label>
</div>
</div>
<br>
<h3>Texte de la page d'accueil</h3> <h3>Texte de la page d'accueil</h3>
<div class="row uniform"> <div class="row uniform">
<div class="12u"> <div class="12u">

View file

@ -44,5 +44,16 @@
{% include 'footer.html'%} {% include 'footer.html'%}
</footer> </footer>
</div> </div>
{% if request.user.is_authenticated %}
<script>
time = {% logout_time %};
function logout(){
window.location.replace("{% url 'users:logout' %}");
}
if(time != 0){
setTimeout(logout, 60000 * time);
}
</script>
{% endif %}
</body> </body>
</html> </html>