diff options
Diffstat (limited to 'servo/forms')
-rw-r--r-- | servo/forms/admin.py | 14 | ||||
-rw-r--r-- | servo/forms/checkin.py | 52 |
2 files changed, 43 insertions, 23 deletions
diff --git a/servo/forms/admin.py b/servo/forms/admin.py index a33d4d4..e012bab 100644 --- a/servo/forms/admin.py +++ b/servo/forms/admin.py @@ -354,6 +354,20 @@ class SettingsForm(BaseForm): help_text=_('Check to make the "device condition" field mandatory'), ) + checkin_tech_name = forms.ChoiceField( + choices=( + ('full', _('Firstname Lastname')), + ('short', _('Firstname Lastinitial')), + ('first', _('Firstname')), + ('last', _('Lastname')), + ('none', _('None')), + ), + initial='full', + required=False, + label=_('Name format'), + help_text=_('Controls how the tech name is displayed in printouts.') + ) + # end checkin fields currency = forms.ChoiceField( diff --git a/servo/forms/checkin.py b/servo/forms/checkin.py index 161b5b2..f74a870 100644 --- a/servo/forms/checkin.py +++ b/servo/forms/checkin.py @@ -19,7 +19,7 @@ from servo.validators import (apple_sn_validator, from servo.forms.base import SearchFieldInput from servo.models import (Configuration, Device, Attachment, Location, - Customer, Queue,) + Customer, Queue, User,) # Generate list of years for purchase date picker @@ -28,13 +28,13 @@ YEARS = [x + 1 for x in range(y - 10, y)] def get_checkin_locations(user): - """Return possible checkin location choices for this user.""" - from servo.models import User + """ + Return possible checkin location choices for this user. + """ if user.is_authenticated: return user.locations.enabled() else: - user_id = Configuration.conf('checkin_user') - return User.objects.get(pk=user_id).locations.enabled() + return User.get_checkin_user().locations.enabled() class ConfirmationForm(forms.Form): @@ -113,6 +113,7 @@ class DeviceForm(forms.ModelForm): if not prod.is_ios: del(self.fields['imei']) + if not prod.is_mac: del(self.fields['username']) @@ -175,6 +176,28 @@ class CustomerForm(forms.Form): label=_('Notify by Email') ) + def __init__(self, request, *args, **kwargs): + + super(CustomerForm, self).__init__(*args, **kwargs) + + location = request.session['checkin_location'] + locations = get_checkin_locations(request.user) + + self.show_location_picker = len(locations) > 1 + self.fields['checkin_location'].initial = location + self.fields['checkout_location'].initial = location + + if self.show_location_picker: + self.fields['checkin_location'].queryset = locations + self.fields['checkout_location'].queryset = locations + else: + self.fields['checkin_location'].widget = forms.HiddenInput() + self.fields['checkout_location'].widget = forms.HiddenInput() + + if request.user.is_authenticated: + del(self.fields['agree_to_terms']) + self.fields['phone'].widget = SearchFieldInput() + def clean(self): cd = super(CustomerForm, self).clean() @@ -187,7 +210,6 @@ class CustomerForm(forms.Form): try: phonenumbers.parse(phone, country) except phonenumbers.NumberParseException as e: - print(e) msg = _('Enter a valid phone number') self._errors["phone"] = self.error_class([msg]) @@ -201,22 +223,6 @@ class CustomerForm(forms.Form): lname = self.cleaned_data.get('lname') return lname.capitalize() - def __init__(self, request, *args, **kwargs): - - super(CustomerForm, self).__init__(*args, **kwargs) - - location = request.session['checkin_location'] - locations = get_checkin_locations(request.user) - - self.fields['checkin_location'].queryset = locations - self.fields['checkin_location'].initial = location - self.fields['checkout_location'].queryset = locations - self.fields['checkout_location'].initial = location - - if request.user.is_authenticated: - del(self.fields['agree_to_terms']) - self.fields['phone'].widget = SearchFieldInput() - class AppleSerialNumberForm(forms.Form): sn = forms.CharField( @@ -268,7 +274,7 @@ class IssueForm(forms.Form): notes = forms.CharField( required=False, - label=_(u'Notes'), + label=_(u'Notes for technician'), widget=forms.Textarea(attrs={'class': 'span12'}), help_text=_('Will not appear on the print-out') ) |