From ea3518103895ad380d531502e32b03edf14cde47 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Sat, 5 Dec 2015 13:01:00 +0200 Subject: Cleanup --- servo/forms/account.py | 26 +++++++++++++------------- servo/models/repair.py | 3 +++ servo/templates/orders/products.html | 12 ++++++------ servo/templates/products/index.html | 2 +- servo/views/account.py | 3 +-- 5 files changed, 24 insertions(+), 22 deletions(-) (limited to 'servo') diff --git a/servo/forms/account.py b/servo/forms/account.py index ac31720..d4704bb 100644 --- a/servo/forms/account.py +++ b/servo/forms/account.py @@ -29,22 +29,18 @@ class ProfileForm(BaseModelForm): 'queues': forms.CheckboxSelectMultiple } - password1 = forms.CharField( - widget=forms.PasswordInput, - required=False, - label=_("Password") - ) - password2 = forms.CharField( - widget=forms.PasswordInput, - required=False, - label=_("Confirmation") - ) + password1 = forms.CharField(widget=forms.PasswordInput, + required=False, + label=_("Password")) + password2 = forms.CharField(widget=forms.PasswordInput, + required=False, + label=_("Confirmation")) def clean(self): cd = super(ProfileForm, self).clean() if cd.get('gsx_password') == "": - del cd['gsx_password'] + del(cd['gsx_password']) cd['tech_id'] = cd['tech_id'].upper() @@ -55,9 +51,13 @@ class ProfileForm(BaseModelForm): return cd def clean_photo(self): + MAX_FILESIZE = 1*1024*1024 # 1 MB + from django.template.defaultfilters import filesizeformat photo = self.cleaned_data.get('photo') - if photo and photo.size > 1*1024*1024: - raise forms.ValidationError(_('File size of photo is too large')) + if photo and photo.size > MAX_FILESIZE: + size = filesizeformat(MAX_FILESIZE) + error = _('Profile picture should be no larger than %s') % size + raise forms.ValidationError(error) return photo diff --git a/servo/models/repair.py b/servo/models/repair.py index 4dd363b..c7ae4a1 100644 --- a/servo/models/repair.py +++ b/servo/models/repair.py @@ -280,6 +280,9 @@ class Repair(models.Model): return self.confirmation or _("New GSX Repair") def set_parts(self, parts): + """ + Resets this Repair's part listing + """ ServicePart.objects.filter(repair=self).delete() for p in parts: part = ServicePart.from_soi(self, p) diff --git a/servo/templates/orders/products.html b/servo/templates/orders/products.html index e8185af..7088945 100755 --- a/servo/templates/orders/products.html +++ b/servo/templates/orders/products.html @@ -25,7 +25,7 @@ {{ product.code }}
{{ item.title }}
{% if item.sn or item.kbb_sn %} -

{% trans "Serial Number" %}: {{ item.sn }}{% if item.kbb_sn %}, KBB: {{ item.kbb_sn }}{% endif %}

+

{% trans "Serial Number" %}: {{ item.sn|default:"-" }}{% if item.kbb_sn %}, KBB: {{ item.kbb_sn }}{% endif %}

{% endif %} {% if product.is_apple_part %} {% for repair in order.get_repairs %} @@ -57,11 +57,11 @@ {% if order.is_editable %}
- {% if item.should_report %} + {% if item.should_report %} - {% else %} + {% else %} - {% endif %} + {% endif %}
@@ -95,7 +95,7 @@ {% endwith %}


- {% if order.serviceorderitem_set.count %} +{% if order.serviceorderitem_set.count %}

{% trans "Order Total" %}: {{ order.gross_total|currency }}

- {% endif %} +{% endif %}

diff --git a/servo/templates/products/index.html b/servo/templates/products/index.html index be5f8f2..24c4d5f 100755 --- a/servo/templates/products/index.html +++ b/servo/templates/products/index.html @@ -35,7 +35,7 @@ {% endif %}
  • {% trans "Download Products" %}
  • -
  • {% trans "Download Inventory Report" %}
  • +
  • {% trans "Download Inventory Report" %}
  • {% trans "Upload Products" %}
  • {% trans "Upload Parts Database" %}
  • diff --git a/servo/views/account.py b/servo/views/account.py index ff3dbfb..5d5c376 100644 --- a/servo/views/account.py +++ b/servo/views/account.py @@ -50,8 +50,7 @@ def settings(request): return redirect(settings) else: - print("Error in user settings: %s" % form.errors) - messages.error(request, _("Error in user details")) + messages.error(request, _("Error in profile data")) return render(request, "accounts/settings.html", locals()) -- cgit v1.2.3