mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-24 20:33:11 +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,
|
Reminder,
|
||||||
RadiusKey,
|
RadiusKey,
|
||||||
SwitchManagementCred,
|
SwitchManagementCred,
|
||||||
|
OptionalPrinter,
|
||||||
)
|
)
|
||||||
from topologie.models import Switch
|
from topologie.models import Switch
|
||||||
|
|
||||||
|
@ -347,3 +348,12 @@ class DelMailContactForm(Form):
|
||||||
else:
|
else:
|
||||||
self.fields['mailcontacts'].queryset = MailContact.objects.all()
|
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")
|
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")
|
||||||
|
|
|
@ -296,11 +296,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
</div>
|
</div>
|
||||||
<div id="collapse_asso" class="panel-collapse panel-body collapse">
|
<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">
|
<table class="table table-striped">
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% trans "Name" %}</th>
|
<th>{% trans "Name" %}</th>
|
||||||
|
@ -332,6 +327,69 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
</div>
|
</div>
|
||||||
</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 panel-default" id="mail">
|
||||||
<div class="panel-heading" data-toggle="collapse" href="#collapse_mail">
|
<div class="panel-heading" data-toggle="collapse" href="#collapse_mail">
|
||||||
<h4 class="panel-title">
|
<h4 class="panel-title">
|
||||||
|
@ -439,4 +497,3 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,11 @@ urlpatterns = [
|
||||||
views.edit_options,
|
views.edit_options,
|
||||||
name='edit-options'
|
name='edit-options'
|
||||||
),
|
),
|
||||||
|
url(
|
||||||
|
r'^edit_options/(?P<section>OptionalPrinter)$',
|
||||||
|
views.edit_options,
|
||||||
|
name='edit-options'
|
||||||
|
),
|
||||||
url(
|
url(
|
||||||
r'^edit_options/(?P<section>GeneralOption)$',
|
r'^edit_options/(?P<section>GeneralOption)$',
|
||||||
views.edit_options,
|
views.edit_options,
|
||||||
|
|
|
@ -62,7 +62,8 @@ from .models import (
|
||||||
HomeOption,
|
HomeOption,
|
||||||
Reminder,
|
Reminder,
|
||||||
RadiusKey,
|
RadiusKey,
|
||||||
SwitchManagementCred
|
SwitchManagementCred,
|
||||||
|
OptionalPrinter,
|
||||||
)
|
)
|
||||||
from . import models
|
from . import models
|
||||||
from . import forms
|
from . import forms
|
||||||
|
@ -70,7 +71,7 @@ from . import forms
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@can_view_all(OptionalUser, OptionalMachine, OptionalTopologie, GeneralOption,
|
@can_view_all(OptionalUser, OptionalMachine, OptionalTopologie, GeneralOption,
|
||||||
AssoOption, MailMessageOption, HomeOption)
|
AssoOption, MailMessageOption, HomeOption, OptionalPrinter)
|
||||||
def display_options(request):
|
def display_options(request):
|
||||||
"""Vue pour affichage des options (en vrac) classé selon les models
|
"""Vue pour affichage des options (en vrac) classé selon les models
|
||||||
correspondants dans un tableau"""
|
correspondants dans un tableau"""
|
||||||
|
@ -86,6 +87,7 @@ def display_options(request):
|
||||||
reminder_list = Reminder.objects.all()
|
reminder_list = Reminder.objects.all()
|
||||||
radiuskey_list = RadiusKey.objects.all()
|
radiuskey_list = RadiusKey.objects.all()
|
||||||
switchmanagementcred_list = SwitchManagementCred.objects.all()
|
switchmanagementcred_list = SwitchManagementCred.objects.all()
|
||||||
|
printeroptions, _created = OptionalPrinter.objects.get_or_create()
|
||||||
return form({
|
return form({
|
||||||
'useroptions': useroptions,
|
'useroptions': useroptions,
|
||||||
'machineoptions': machineoptions,
|
'machineoptions': machineoptions,
|
||||||
|
@ -99,6 +101,7 @@ def display_options(request):
|
||||||
'reminder_list': reminder_list,
|
'reminder_list': reminder_list,
|
||||||
'radiuskey_list' : radiuskey_list,
|
'radiuskey_list' : radiuskey_list,
|
||||||
'switchmanagementcred_list': switchmanagementcred_list,
|
'switchmanagementcred_list': switchmanagementcred_list,
|
||||||
|
'printeroptions': printeroptions,
|
||||||
}, 'preferences/display_preferences.html', request)
|
}, 'preferences/display_preferences.html', request)
|
||||||
|
|
||||||
|
|
||||||
|
@ -398,4 +401,3 @@ def del_mailcontact(request, instances):
|
||||||
'preferences/preferences.html',
|
'preferences/preferences.html',
|
||||||
request
|
request
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""printer.settings
|
"""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']
|
ALLOWED_TYPES = ['application/pdf']
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,13 +15,13 @@ ALLOWED_TYPES = ['application/pdf']
|
||||||
## Config
|
## Config
|
||||||
|
|
||||||
## Depreciation
|
## Depreciation
|
||||||
depr = 2.16
|
depr = settings.depreciation_coef
|
||||||
|
|
||||||
PRICES = {
|
PRICES = {
|
||||||
'Depreciation': depr,
|
'Depreciation': depr,
|
||||||
'A3': 0.670,
|
'A3': settings.A3_price,
|
||||||
'A4': 2.1504,
|
'A4': settings.A4_price,
|
||||||
'Color': 9.0 + depr,
|
'Color': settings.Color_price + depr,
|
||||||
'Greyscale': 0.9 + depr,
|
'Greyscale': settings.Greyscale_price + depr,
|
||||||
'Staples': 1.3333,
|
'Staples': settings.Staples_price,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue