mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-16 08:23:12 +00:00
[Printer][Preferences] Put Printer Options into Preferences database
This commit is contained in:
parent
62aef50c08
commit
d3048fdd5f
6 changed files with 182 additions and 26 deletions
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -208,7 +208,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<th>{% trans "VLAN for machines rejected by RADIUS" %}</th>
|
||||
<td>{{ topologieoptions.vlan_decision_nok }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr>
|
||||
<th>Placement sur ce vlan par default en cas de rejet</th>
|
||||
<td>{{ topologieoptions.vlan_decision_nok }}</td>
|
||||
</tr>
|
||||
|
@ -254,11 +254,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<th>Switchs configurés automatiquement</th>
|
||||
<td>{{ topologieoptions.provisioned_switchs|join:", " }} {% if topologieoptions.provisioned_switchs %}<span class="label label-success"> OK{% else %}<span class="label label-danger">Manquant{% endif %}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr>
|
||||
<th>Plage d'ip de management des switchs</th>
|
||||
<td>{{ topologieoptions.switchs_ip_type }} {% if topologieoptions.switchs_ip_type %}<span class="label label-success"> OK{% else %}<span class="label label-danger">Manquant{% endif %}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr>
|
||||
<th>Serveur des config des switchs</th>
|
||||
<td>{{ topologieoptions.switchs_management_interface }} {% if topologieoptions.switchs_management_interface %} - {{ topologieoptions.switchs_management_interface_ip }} <span class="label label-success"> OK{% else %}<span class="label label-danger">Manquant{% endif %}</span></td>
|
||||
</tr>
|
||||
|
@ -296,11 +296,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
</div>
|
||||
<div id="collapse_asso" class="panel-collapse panel-body collapse">
|
||||
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:edit-options' 'AssoOption' %}">
|
||||
<i class="fa fa-edit"></i>
|
||||
{% trans "Edit" %}
|
||||
</a>
|
||||
<p></p>
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>{% trans "Name" %}</th>
|
||||
|
@ -332,6 +327,69 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="panel panel-default" id="printer">
|
||||
<div class="panel-heading" data-toggle="collapse" href="#collapse_printer">
|
||||
<h4 class="panel-title">
|
||||
<a><i class="fa fa-print"></i> {% trans "Printer preferences" %}</a>
|
||||
<h4>
|
||||
</div>
|
||||
<div id="collapse_printer" class="panel-collapse panel-body collapse">
|
||||
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:edit-options' 'OptionalPrinter' %}">
|
||||
<i class="fa fa-edit"></i>
|
||||
{% trans "Edit" %}
|
||||
</a>
|
||||
<p>
|
||||
</p>
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>{% trans "Printer Enabled" %}</th>
|
||||
<td>{{ printeroptions.Printer_enabled }}</td>
|
||||
<th>{% trans "Color enabled" %}</th>
|
||||
<td>{{ printeroptions.color_enabled }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans "A3 enabled" %}</th>
|
||||
<td>{{ printeroptions.A3_enabled }}</td>
|
||||
<th>{% trans "Booklet enabled" %}</th>
|
||||
<td>{{ printeroptions.booklet_enabled }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans "Stapling enabled" %}</th>
|
||||
<td>{{ printeroptions.stapling_enabled }}</td>
|
||||
<th>{% trans "Perforation_enabled" %}</th>
|
||||
<td>{{ printeroptions.perforation_enabled }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans "Max size available (in MB)" %}</th>
|
||||
<td>{{ printeroptions.max_size }}</td>
|
||||
<th>{% trans "Depreciation coefficient" %}</th>
|
||||
<td>{{ printeroptions.depreciation_coef }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans "A3 price" %}</th>
|
||||
<td>{{ printeroptions.A3_price }}</td>
|
||||
<th>{% trans "A4 price" %}</th>
|
||||
<td>{{ printeroptions.A4_price }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans "Color price" %}</th>
|
||||
<td>{{ printeroptions.Color_price }}</td>
|
||||
<th>{% trans "Greyscale price" %}</th>
|
||||
<td>{{ printeroptions.Greyscale_price }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans "Staples price" %}</th>
|
||||
<td>{{ printeroptions.Staples_price }}</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="panel panel-default" id="mail">
|
||||
<div class="panel-heading" data-toggle="collapse" href="#collapse_mail">
|
||||
<h4 class="panel-title">
|
||||
|
@ -439,4 +497,3 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -46,6 +46,11 @@ urlpatterns = [
|
|||
views.edit_options,
|
||||
name='edit-options'
|
||||
),
|
||||
url(
|
||||
r'^edit_options/(?P<section>OptionalPrinter)$',
|
||||
views.edit_options,
|
||||
name='edit-options'
|
||||
),
|
||||
url(
|
||||
r'^edit_options/(?P<section>GeneralOption)$',
|
||||
views.edit_options,
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue