diff --git a/preferences/forms.py b/preferences/forms.py
index 2f90927f..955d396a 100644
--- a/preferences/forms.py
+++ b/preferences/forms.py
@@ -42,6 +42,7 @@ from .models import (
Reminder,
RadiusKey,
SwitchManagementCred,
+ OptionalPrinter,
)
from topologie.models import Switch
@@ -347,3 +348,12 @@ class DelMailContactForm(Form):
else:
self.fields['mailcontacts'].queryset = MailContact.objects.all()
+class EditOptionalPrinterForm(ModelForm):
+ """Set preference for Printer App"""
+ class Meta:
+ model = OptionalPrinter
+ fields = '__all__'
+
+ def __init__(self, *args, **kwargs):
+ prefix = kwargs.pop('prefix', self.Meta.model.__name__)
+ super(EditOptionalPrinterForm, self).__init__(*args, prefix=prefix, **kwargs)
diff --git a/preferences/models.py b/preferences/models.py
index 43ff7580..6e2699f3 100644
--- a/preferences/models.py
+++ b/preferences/models.py
@@ -588,3 +588,88 @@ class MailMessageOption(AclMixin, models.Model):
)
verbose_name = _("email message options")
+
+class OptionalPrinter(AclMixin, models.Model):
+ """Preference for Printer app"""
+
+ Printer_enabled = models.BooleanField(
+ default=False,
+ help_text=_("Is printer Available ?"),
+ )
+
+ A3_enabled = models.BooleanField(
+ default=False,
+ help_text=_("Can print in A3 format ?"),
+ )
+
+ A3_enabled = models.BooleanField(
+ default=False,
+ help_text=_("Can print in A3 format ?"),
+ )
+
+ booklet_enabled = models.BooleanField(
+ default=False,
+ help_text=_("Can print in booklet format ?"),
+ )
+
+ color_enabled = models.BooleanField(
+ default=False,
+ help_text=_("Can print in color ?"),
+ )
+
+ stapling_enabled = models.BooleanField(
+ default=False,
+ help_text=_("Can use staples ?"),
+ )
+
+ perforation_enabled = models.BooleanField(
+ default=False,
+ help_text=_("Can perforate ?"),
+ )
+
+ max_size = models.IntegerField(
+ default=25,
+ help_text=_("Maximum size in MB of files to be printed")
+ )
+
+ depreciation_coef = models.DecimalField(
+ max_digits=5,
+ decimal_places=2,
+ default=0.0,
+ help_text=_('Set depreciation coefficient'),
+ )
+
+ A3_price = models.DecimalField(
+ max_digits=5,
+ decimal_places=2,
+ default=0.0,
+ )
+
+ A4_price = models.DecimalField(
+ max_digits=5,
+ decimal_places=2,
+ default=0.0,
+ )
+
+ Color_price = models.DecimalField(
+ max_digits=5,
+ decimal_places=2,
+ default=0.0,
+ )
+
+ Greyscale_price = models.DecimalField(
+ max_digits=5,
+ decimal_places=2,
+ default=0.0,
+ )
+
+ Staples_price = models.DecimalField(
+ max_digits=5,
+ decimal_places=2,
+ default=0.0,
+ )
+
+ permissions = (
+ ("view_optionalprinter", _("Can view the printer options")),
+ )
+ verbose_name = _("Printer Options")
diff --git a/preferences/templates/preferences/display_preferences.html b/preferences/templates/preferences/display_preferences.html
index 3fde911d..24a7d001 100644
--- a/preferences/templates/preferences/display_preferences.html
+++ b/preferences/templates/preferences/display_preferences.html
@@ -208,7 +208,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% trans "VLAN for machines rejected by RADIUS" %} |
{{ topologieoptions.vlan_decision_nok }} |
-
+
Placement sur ce vlan par default en cas de rejet |
{{ topologieoptions.vlan_decision_nok }} |
@@ -254,11 +254,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Switchs configurés automatiquement |
{{ topologieoptions.provisioned_switchs|join:", " }} {% if topologieoptions.provisioned_switchs %} OK{% else %}Manquant{% endif %} |
-
+
Plage d'ip de management des switchs |
{{ topologieoptions.switchs_ip_type }} {% if topologieoptions.switchs_ip_type %} OK{% else %}Manquant{% endif %} |
-
+
Serveur des config des switchs |
{{ topologieoptions.switchs_management_interface }} {% if topologieoptions.switchs_management_interface %} - {{ topologieoptions.switchs_management_interface_ip }} OK{% else %}Manquant{% endif %} |
@@ -296,11 +296,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
-
-
- {% trans "Edit" %}
-
-
{% trans "Name" %} |
@@ -332,6 +327,69 @@ with this program; if not, write to the Free Software Foundation, Inc.,
+
+
+
+
+
+
+
+ {% trans "Edit" %}
+
+
+
+
+
+ {% trans "Printer Enabled" %} |
+ {{ printeroptions.Printer_enabled }} |
+ {% trans "Color enabled" %} |
+ {{ printeroptions.color_enabled }} |
+
+
+ {% trans "A3 enabled" %} |
+ {{ printeroptions.A3_enabled }} |
+ {% trans "Booklet enabled" %} |
+ {{ printeroptions.booklet_enabled }} |
+
+
+ {% trans "Stapling enabled" %} |
+ {{ printeroptions.stapling_enabled }} |
+ {% trans "Perforation_enabled" %} |
+ {{ printeroptions.perforation_enabled }} |
+
+
+ {% trans "Max size available (in MB)" %} |
+ {{ printeroptions.max_size }} |
+ {% trans "Depreciation coefficient" %} |
+ {{ printeroptions.depreciation_coef }} |
+
+
+ {% trans "A3 price" %} |
+ {{ printeroptions.A3_price }} |
+ {% trans "A4 price" %} |
+ {{ printeroptions.A4_price }} |
+
+
+ {% trans "Color price" %} |
+ {{ printeroptions.Color_price }} |
+ {% trans "Greyscale price" %} |
+ {{ printeroptions.Greyscale_price }} |
+
+
+ {% trans "Staples price" %} |
+ {{ printeroptions.Staples_price }} |
+
+
+
+
+
+
+
+
@@ -439,4 +497,3 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endblock %}
-
diff --git a/preferences/urls.py b/preferences/urls.py
index 63ca6a39..515cf1b6 100644
--- a/preferences/urls.py
+++ b/preferences/urls.py
@@ -46,6 +46,11 @@ urlpatterns = [
views.edit_options,
name='edit-options'
),
+ url(
+ r'^edit_options/(?P
OptionalPrinter)$',
+ views.edit_options,
+ name='edit-options'
+ ),
url(
r'^edit_options/(?PGeneralOption)$',
views.edit_options,
diff --git a/preferences/views.py b/preferences/views.py
index ee81ae89..2c5ac800 100644
--- a/preferences/views.py
+++ b/preferences/views.py
@@ -62,7 +62,8 @@ from .models import (
HomeOption,
Reminder,
RadiusKey,
- SwitchManagementCred
+ SwitchManagementCred,
+ OptionalPrinter,
)
from . import models
from . import forms
@@ -70,7 +71,7 @@ from . import forms
@login_required
@can_view_all(OptionalUser, OptionalMachine, OptionalTopologie, GeneralOption,
- AssoOption, MailMessageOption, HomeOption)
+ AssoOption, MailMessageOption, HomeOption, OptionalPrinter)
def display_options(request):
"""Vue pour affichage des options (en vrac) classé selon les models
correspondants dans un tableau"""
@@ -86,6 +87,7 @@ def display_options(request):
reminder_list = Reminder.objects.all()
radiuskey_list = RadiusKey.objects.all()
switchmanagementcred_list = SwitchManagementCred.objects.all()
+ printeroptions, _created = OptionalPrinter.objects.get_or_create()
return form({
'useroptions': useroptions,
'machineoptions': machineoptions,
@@ -98,7 +100,8 @@ def display_options(request):
'mailcontact_list': mailcontact_list,
'reminder_list': reminder_list,
'radiuskey_list' : radiuskey_list,
- 'switchmanagementcred_list': switchmanagementcred_list,
+ 'switchmanagementcred_list': switchmanagementcred_list,
+ 'printeroptions': printeroptions,
}, 'preferences/display_preferences.html', request)
@@ -398,4 +401,3 @@ def del_mailcontact(request, instances):
'preferences/preferences.html',
request
)
-
diff --git a/printer/settings.py b/printer/settings.py
index 4aac7c93..7cd77408 100644
--- a/printer/settings.py
+++ b/printer/settings.py
@@ -1,15 +1,12 @@
-
-
-
-
-
"""printer.settings
-Define variables, to be changed into a configuration table.
+Define variables used in printer app
"""
+from preferences.models import OptionalPrinter
+settings = OptionalPrinter.objects.get()
-MAX_PRINTFILE_SIZE = 25 * 1024 * 1024 # 25 MB
+MAX_PRINTFILE_SIZE = settings.max_size * 1024 * 1024 # 25 MB
ALLOWED_TYPES = ['application/pdf']
@@ -18,13 +15,13 @@ ALLOWED_TYPES = ['application/pdf']
## Config
## Depreciation
-depr = 2.16
+depr = settings.depreciation_coef
PRICES = {
'Depreciation': depr,
- 'A3': 0.670,
- 'A4': 2.1504,
- 'Color': 9.0 + depr,
- 'Greyscale': 0.9 + depr,
- 'Staples': 1.3333,
+ 'A3': settings.A3_price,
+ 'A4': settings.A4_price,
+ 'Color': settings.Color_price + depr,
+ 'Greyscale': settings.Greyscale_price + depr,
+ 'Staples': settings.Staples_price,
}