From 1d6b5952f6b5c05d3e3c5fe6fc47b8b279afe232 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Thu, 29 Nov 2018 23:00:45 +0100 Subject: [PATCH] =?UTF-8?q?Nouveau=20r=C3=A9glage=20code=5Fduration=20+=20?= =?UTF-8?q?context=20processor=20mise=20en=20cache=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0056_optionalprinter_code_duration.py | 21 +++++++++++++++++++ preferences/models.py | 7 ++++++- .../preferences/display_preferences.html | 2 ++ re2o/context_processors.py | 3 +-- 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 preferences/migrations/0056_optionalprinter_code_duration.py diff --git a/preferences/migrations/0056_optionalprinter_code_duration.py b/preferences/migrations/0056_optionalprinter_code_duration.py new file mode 100644 index 00000000..2ccb85a0 --- /dev/null +++ b/preferences/migrations/0056_optionalprinter_code_duration.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2018-11-29 21:50 +from __future__ import unicode_literals + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('preferences', '0055_generaloption_main_site_url'), + ] + + operations = [ + migrations.AddField( + model_name='optionalprinter', + name='code_duration', + field=models.DurationField(default=datetime.timedelta(1), help_text='Digicode max duration for printer'), + ), + ] diff --git a/preferences/models.py b/preferences/models.py index 6e2699f3..11b9cb74 100644 --- a/preferences/models.py +++ b/preferences/models.py @@ -589,7 +589,7 @@ class MailMessageOption(AclMixin, models.Model): verbose_name = _("email message options") -class OptionalPrinter(AclMixin, models.Model): +class OptionalPrinter(AclMixin, PreferencesModel): """Preference for Printer app""" Printer_enabled = models.BooleanField( @@ -669,6 +669,11 @@ class OptionalPrinter(AclMixin, models.Model): default=0.0, ) + code_duration = models.DurationField( + default=timedelta(days=1), + help_text=_("Digicode max duration for printer") + ) + permissions = ( ("view_optionalprinter", _("Can view the printer options")), ) diff --git a/preferences/templates/preferences/display_preferences.html b/preferences/templates/preferences/display_preferences.html index 24a7d001..182c0a05 100644 --- a/preferences/templates/preferences/display_preferences.html +++ b/preferences/templates/preferences/display_preferences.html @@ -382,6 +382,8 @@ with this program; if not, write to the Free Software Foundation, Inc., {% trans "Staples price" %} {{ printeroptions.Staples_price }} + {% trans "Digicode duration" %} + {{ printeroptions.code_duration }} diff --git a/re2o/context_processors.py b/re2o/context_processors.py index 2e29800a..cbf46d11 100644 --- a/re2o/context_processors.py +++ b/re2o/context_processors.py @@ -70,8 +70,7 @@ def context_printer(request): """ Useful to know whether the printer app is activated or not """ - printerSettings = OptionalPrinter.objects.get() - printer = ('printer' in INSTALLED_APPS) and printerSettings.Printer_enabled + printer = ('printer' in INSTALLED_APPS) and OptionalPrinter.get_cached_value('Printer_enabled') return { 'printer': printer, }