From 9fcb963e76d06ca4f659bc052bb46c3d50f155ce Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Thu, 19 Jan 2017 18:14:31 +0200 Subject: Added checkin_enable setting --- servo/forms/admin.py | 22 +++++++++++++++------- servo/models/common.py | 5 +++++ servo/templates/admin/settings.html | 3 ++- 3 files changed, 22 insertions(+), 8 deletions(-) (limited to 'servo') diff --git a/servo/forms/admin.py b/servo/forms/admin.py index f1e610d..ec4ee56 100644 --- a/servo/forms/admin.py +++ b/servo/forms/admin.py @@ -136,17 +136,16 @@ class QueueForm(BaseModelForm): gsx_soldto = forms.ChoiceField(required=False, choices=()) users = forms.ModelMultipleChoiceField(queryset=User.active.all(), - widget=forms.CheckboxSelectMultiple, - required=False - ) + widget=forms.CheckboxSelectMultiple, + required=False) class Meta: model = Queue exclude = ('statuses',) widgets = { - 'description' : forms.Textarea(attrs={'rows': 4}), - 'keywords' : forms.Textarea(attrs={'rows': 4}), - 'locations' : forms.CheckboxSelectMultiple, + 'description': forms.Textarea(attrs={'rows': 4}), + 'keywords': forms.Textarea(attrs={'rows': 4}), + 'locations': forms.CheckboxSelectMultiple, } def __init__(self, *args, **kwargs): @@ -172,7 +171,7 @@ class QueueForm(BaseModelForm): return ftype = file_type(tpl.file.read()) - + if ftype != 'text/html': raise forms.ValidationError(_('Print tempates must be in HTML format')) @@ -292,6 +291,13 @@ class SettingsForm(BaseForm): ) # start checkin fields + checkin_enable = forms.BooleanField( + initial=True, + required=False, + label=_("Enable check-in interface"), + help_text=_("Uncheck to disable the check-in interface") + ) + checkin_user = forms.ModelChoiceField( required=False, label=_('User Account'), @@ -339,11 +345,13 @@ class SettingsForm(BaseForm): initial=True, required=False, label=_('Require device password'), + help_text=_('Check to make the "device password" field mandatory'), ) checkin_require_condition = forms.BooleanField( initial=True, required=False, label=_('Require device condition'), + help_text=_('Check to make the "device condition" field mandatory'), ) # end checkin fields diff --git a/servo/models/common.py b/servo/models/common.py index 1f9af7c..b2b6c51 100644 --- a/servo/models/common.py +++ b/servo/models/common.py @@ -497,6 +497,7 @@ class Location(models.Model): @classmethod def get_checkin_list(cls): + """List service locations that are marked for check-in.""" results = [] for l in cls.objects.filter(checkin=True): results.append({'pk': l.pk, 'name': l.title}) @@ -651,6 +652,10 @@ class Configuration(models.Model): return config.get(key) if key else config + @classmethod + def checkin_enabled(cls): + return cls.conf('checkin_enable') + def save(self, *args, **kwargs): config = super(Configuration, self).save(*args, **kwargs) # Using cache instead of session since it's shared among diff --git a/servo/templates/admin/settings.html b/servo/templates/admin/settings.html index 85f7b61..bec147b 100644 --- a/servo/templates/admin/settings.html +++ b/servo/templates/admin/settings.html @@ -13,7 +13,7 @@
  • {% trans "GSX" %}
  • {% trans "Outgoing Mail" %}
  • {% trans "Incoming Mail" %}
  • -
  • {% trans "Text Messages" %}
  • +
  • {% trans "SMS" %}
  • {% trans "Check-in" %}
  • @@ -92,6 +92,7 @@ {% endif %}
    + {% include "form_field_snippet.html" with field=form.checkin_enable %} {% include "form_field_snippet.html" with field=form.checkin_user %} {% include "form_field_snippet.html" with field=form.checkin_group %} {% include "form_field_snippet.html" with field=form.checkin_queue %} -- cgit v1.2.3