From 2c849c7064c74813f7afda1dcc6138cd55060d78 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Thu, 29 Nov 2018 22:54:51 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20chargement=20du=20r=C3=A9glage=20printer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- printer/models.py | 5 ++++- printer/utils.py | 3 +-- printer/views.py | 1 - 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/printer/models.py b/printer/models.py index b2553ea1..a7f8213a 100644 --- a/printer/models.py +++ b/printer/models.py @@ -27,6 +27,8 @@ from .validators import ( FileValidator, ) +from preferences.models import OptionalPrinter + from .settings import ( MAX_PRINTFILE_SIZE, ALLOWED_TYPES, @@ -65,7 +67,8 @@ class Digicode(RevMixin, models.Model, AclMixin, FieldPermissionModelMixin): @classmethod def active_codes(cls): - return cls.objects.filter(created__gte = timezone.now() - datetime.timedelta(days=3)) + code_duration = OptionalPrinter.get_cached_value('code_duration') + return cls.objects.filter(created__gte = timezone.now() - code_duration) def _gen_code(user): try_again = True diff --git a/printer/utils.py b/printer/utils.py index 6892ca5c..0aa3e22f 100644 --- a/printer/utils.py +++ b/printer/utils.py @@ -16,8 +16,7 @@ def printer_enabled(): """ Check whether the printer is enabled or not """ - settings, created = OptionalPrinter.objects.get_or_create() - return settings.Printer_enabled + return OptionalPrinter.get_cached_value('Printer_enabled') def pdfinfo(file_path): diff --git a/printer/views.py b/printer/views.py index b8865744..e45cb9fb 100644 --- a/printer/views.py +++ b/printer/views.py @@ -19,7 +19,6 @@ from re2o.base import ( re2o_paginator, SortTable ) -from . import settings from .utils import pdfinfo, send_mail_printer, printer_enabled