aboutsummaryrefslogtreecommitdiffstats
path: root/servo
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2021-06-17 20:49:00 +0300
committerFilipp Lepalaan <filipp@mac.com>2021-06-17 20:49:00 +0300
commit3418ece690ca90d676a7d8ae654da7770ae312fb (patch)
tree5daa04838cda0e85da32865fde42b14f310a2627 /servo
parent3421b809f432ee49586df91b627ef70aa3e07cbf (diff)
downloadServo-master.tar.gz
Servo-master.tar.bz2
Servo-master.zip
Add print options for tech nameHEADmaster
Diffstat (limited to 'servo')
-rw-r--r--servo/forms/admin.py14
-rw-r--r--servo/forms/checkin.py52
-rw-r--r--servo/models/account.py32
-rw-r--r--servo/templates/admin/settings.html1
-rw-r--r--servo/templates/checkin/newindex.html4
-rwxr-xr-xservo/templates/orders/print_confirmation.html2
-rwxr-xr-xservo/templates/orders/print_receipt.html2
-rw-r--r--servo/views/admin.py8
-rw-r--r--servo/views/checkin.py4
9 files changed, 83 insertions, 36 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')
)
diff --git a/servo/models/account.py b/servo/models/account.py
index 2641e81..cb0b82a 100644
--- a/servo/models/account.py
+++ b/servo/models/account.py
@@ -210,9 +210,41 @@ class User(AbstractUser):
def get_icon(self):
return 'icon-star' if self.is_staff else 'icon-user'
+ def get_initials(self):
+ """
+ Returns firstinitiallastinitial
+ """
+ if self.first_name and self.last_name:
+ return '{0}{1}'.format(self.first_name[0], self.last_name[0])
+
+ def get_shortname(self):
+ """Returns Firstname Lastinitial."""
+ if self.first_name and self.last_name:
+ return '{0} {1}.'.format(self.first_name, self.last_name[0])
+
def get_name(self):
return self.full_name if len(self.full_name) > 1 else self.username
+ def get_print_name(self):
+ """
+ Returns name of user/tech according to system settings
+ """
+ conf = Configuration.conf('checkin_tech_name')
+ if conf == 'full':
+ return self.get_full_name()
+
+ if conf == 'short':
+ return self.get_shortname()
+
+ if conf == 'first':
+ return self.first_name
+
+ if conf == 'last':
+ return self.last_name
+
+ if conf == 'none':
+ return ''
+
def get_location(self):
return self.location
diff --git a/servo/templates/admin/settings.html b/servo/templates/admin/settings.html
index 35007d4..fd9452f 100644
--- a/servo/templates/admin/settings.html
+++ b/servo/templates/admin/settings.html
@@ -105,6 +105,7 @@
{% include "form_field_snippet.html" with field=form.checkin_group %}
{% include "form_field_snippet.html" with field=form.checkin_queue %}
{% include "form_field_snippet.html" with field=form.checkin_checklist %}
+ {% include "form_field_snippet.html" with field=form.checkin_tech_name %}
{% include "form_field_snippet.html" with field=form.checkin_password %}
{% include "form_field_snippet.html" with field=form.checkin_require_password %}
{% include "form_field_snippet.html" with field=form.checkin_require_condition %}
diff --git a/servo/templates/checkin/newindex.html b/servo/templates/checkin/newindex.html
index 55a52fa..e2782e9 100644
--- a/servo/templates/checkin/newindex.html
+++ b/servo/templates/checkin/newindex.html
@@ -123,8 +123,8 @@
</tbody>
</table>
{% endif %}
- {% bootstrap_field customer_form.checkin_location %}
- {% bootstrap_field customer_form.checkout_location %}
+ {% bootstrap_field customer_form.checkin_location %}
+ {% bootstrap_field customer_form.checkout_location %}
{% if request.user.is_authenticated %}
{% bootstrap_field device_form.queue %}
{% endif %}
diff --git a/servo/templates/orders/print_confirmation.html b/servo/templates/orders/print_confirmation.html
index da8fd33..8dd8bc4 100755
--- a/servo/templates/orders/print_confirmation.html
+++ b/servo/templates/orders/print_confirmation.html
@@ -191,7 +191,7 @@
<table class="table">
<tbody>
<tr>
- <td style="width:40%">{{ order.created_by.get_full_name }}</td>
+ <td style="width:40%">{{ order.created_by.get_print_name }}</td>
<td style="width:40%">&nbsp;</td>
<td style="width:20%">{% now "SHORT_DATE_FORMAT" %}</td>
</tr>
diff --git a/servo/templates/orders/print_receipt.html b/servo/templates/orders/print_receipt.html
index c4de827..0839b44 100755
--- a/servo/templates/orders/print_receipt.html
+++ b/servo/templates/orders/print_receipt.html
@@ -39,7 +39,7 @@
<p class="text-right">
<strong>{% trans "Date of invoice" %}: {{ invoice.created_at|date:"SHORT_DATE_FORMAT" }}</strong><br/>
<strong>{% trans "Payment method" %}: {{ invoice.get_payment_methods|join:", " }}</strong><br/>
- <strong>{% trans "Sales Person" %}: {{ invoice.created_by.get_full_name }}</strong><br/>
+ <strong>{% trans "Sales Person" %}: {{ invoice.created_by.get_print_name }}</strong><br/>
</p>
{% endblock customer_pickup %}
diff --git a/servo/views/admin.py b/servo/views/admin.py
index 5d1da4a..4f32829 100644
--- a/servo/views/admin.py
+++ b/servo/views/admin.py
@@ -224,14 +224,6 @@ def settings(request):
p.set_exchange_sales_price()
p.save()
- # formset = ShippingMethodFormset(request.POST)
-
- # if not formset.is_valid():
- # messages.error(request, _('Error in shipping method settings'))
- # return render(request, 'admin/settings.html', locals())
-
- # formset.save()
-
messages.success(request, _('Settings saved'))
return redirect(settings)
diff --git a/servo/views/checkin.py b/servo/views/checkin.py
index fc1719a..dd60bd2 100644
--- a/servo/views/checkin.py
+++ b/servo/views/checkin.py
@@ -57,7 +57,9 @@ def find_customer(request, phone):
def init_locale(request):
- """Initialize locale for the check-in interface."""
+ """
+ Initialize locale for the check-in interface.
+ """
lc = settings.INSTALL_LOCALE.split('.')
locale.setlocale(locale.LC_TIME, lc)
locale.setlocale(locale.LC_NUMERIC, lc)