From 6e7c3bfc55e7b5e6d73e88824234bf9b72d5f9e8 Mon Sep 17 00:00:00 2001 From: Maxime Bombar Date: Sat, 20 Oct 2018 15:52:38 +0200 Subject: [PATCH] [Printer] Move Options Available from models to settings --- printer/models.py | 40 ++++++++-------------------------------- printer/settings.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 32 deletions(-) diff --git a/printer/models.py b/printer/models.py index 407e5b4a..f6dd3440 100644 --- a/printer/models.py +++ b/printer/models.py @@ -23,9 +23,14 @@ from .validators import ( ) from .settings import ( - MAX_PRINTFILE_SIZE, - ALLOWED_TYPES, - PRICES, + MAX_PRINTFILE_SIZE, + ALLOWED_TYPES, + PRICES, + FORMAT_AVAILABLE, + COLOR_CHOICES, + DISPOSITIONS_AVAILABLE, + STAPLING_OPTIONS, + PERFORATION_OPTIONS, ) from .utils import user_printing_path @@ -97,35 +102,6 @@ class JobWithOptions(RevMixin, models.Model): verbose_name=_("price"), default=0.0) pages = models.IntegerField(default=0) - FORMAT_AVAILABLE = ( - ('A4', 'A4'), - ('A3', 'A3'), - ) - COLOR_CHOICES = ( - ('Greyscale', 'Greyscale'), - ('Color', 'Color') - ) - DISPOSITIONS_AVAILABLE = ( - ('TwoSided', 'Two sided'), - ('OneSided', 'One sided'), - ('Booklet', 'Booklet') - ) - STAPLING_OPTIONS = ( - ('None', 'None'), - ('TopLeft', 'One top left'), - ('TopRight', 'One top right'), - ('LeftSided', 'Two left sided'), - ('RightSided', 'Two right sided') - ) - PERFORATION_OPTIONS = ( - ('None', 'None'), - ('TwoLeftSidedHoles', 'Two left sided holes'), - ('TwoRightSidedHoles', 'Two right sided holes'), - ('TwoTopHoles', 'Two top holes'), - ('TwoBottomHoles', 'Two bottom holes'), - ('FourLeftSidedHoles', 'Four left sided holes'), - ('FourRightSidedHoles', 'Four right sided holes') - ) format = models.CharField(max_length=255, choices=FORMAT_AVAILABLE, default='A4') color = models.CharField(max_length=255, choices=COLOR_CHOICES, default='Greyscale') diff --git a/printer/settings.py b/printer/settings.py index 7cd77408..562a4211 100644 --- a/printer/settings.py +++ b/printer/settings.py @@ -10,6 +10,41 @@ MAX_PRINTFILE_SIZE = settings.max_size * 1024 * 1024 # 25 MB ALLOWED_TYPES = ['application/pdf'] +A3_enabled = settings.A3_enabled +booklet_enabled = settings.booklet_enabled +color_enabled = settings.color_enabled +stapling_enabled = settings.stapling_enabled +perforation_enabled = settings.perforation_enabled + +FORMAT_AVAILABLE = ( + ('A4', 'A4'), + ('A3', 'A3'), +) +COLOR_CHOICES = ( + ('Greyscale', 'Greyscale'), + ('Color', 'Color') +) +DISPOSITIONS_AVAILABLE = ( + ('TwoSided', 'Two sided'), + ('OneSided', 'One sided'), + ('Booklet', 'Booklet') +) +STAPLING_OPTIONS = ( + ('None', 'None'), + ('TopLeft', 'One top left'), + ('TopRight', 'One top right'), + ('LeftSided', 'Two left sided'), + ('RightSided', 'Two right sided') +) +PERFORATION_OPTIONS = ( + ('None', 'None'), + ('TwoLeftSidedHoles', 'Two left sided holes'), + ('TwoRightSidedHoles', 'Two right sided holes'), + ('TwoTopHoles', 'Two top holes'), + ('TwoBottomHoles', 'Two bottom holes'), + ('FourLeftSidedHoles', 'Four left sided holes'), + ('FourRightSidedHoles', 'Four right sided holes') +) ## Config