aboutsummaryrefslogtreecommitdiffstats
path: root/servo
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2015-12-05 13:01:00 +0200
committerFilipp Lepalaan <filipp@mac.com>2015-12-05 13:01:00 +0200
commitea3518103895ad380d531502e32b03edf14cde47 (patch)
tree32debd00109726c887143e89cb854987f8613e43 /servo
parent6d5964987eddfe9d4e3dbbcb0142420359259c35 (diff)
downloadServo-ea3518103895ad380d531502e32b03edf14cde47.tar.gz
Servo-ea3518103895ad380d531502e32b03edf14cde47.tar.bz2
Servo-ea3518103895ad380d531502e32b03edf14cde47.zip
Cleanup
Diffstat (limited to 'servo')
-rw-r--r--servo/forms/account.py26
-rw-r--r--servo/models/repair.py3
-rwxr-xr-xservo/templates/orders/products.html12
-rwxr-xr-xservo/templates/products/index.html2
-rw-r--r--servo/views/account.py3
5 files changed, 24 insertions, 22 deletions
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 @@
<strong><a href="{% url 'products-get_info' item.code order.location.pk %}" data-modal="#modal">{{ product.code }}</a></strong><br/>
<div>{{ item.title }}</div>
{% if item.sn or item.kbb_sn %}
- <p><small class="muted">{% trans "Serial Number" %}: {{ item.sn }}{% if item.kbb_sn %}, KBB: {{ item.kbb_sn }}{% endif %}</small></p>
+ <p><small class="muted">{% trans "Serial Number" %}: {{ item.sn|default:"-" }}{% if item.kbb_sn %}, KBB: {{ item.kbb_sn }}{% endif %}</small></p>
{% endif %}
{% if product.is_apple_part %}
{% for repair in order.get_repairs %}
@@ -57,11 +57,11 @@
<td style="width:125px">
{% if order.is_editable %}
<div class="btn-group">
- {% if item.should_report %}
+ {% if item.should_report %}
<a href="{% url 'orders-report_product' pk=order.id item_id=item.id %}" title="Toggle report flag" class="btn btn-small btn-success nofollow active" data-toggle="button"><i class="icon-ok"></i></a>
- {% else %}
+ {% else %}
<a href="{% url 'orders-report_product' pk=order.id item_id=item.id %}" title="Toggle report flag" class="btn btn-small btn-success nofollow" data-toggle="button"><i class="icon-ok icon-white"></i></a>
- {% endif %}
+ {% endif %}
</div>
<div class="btn-group">
<a href="{% url 'orders-edit_product' pk=order.id item_id=item.id %}" class="btn btn-small" title="{% trans "Edit" %}" data-modal="#modal"><i class="icon-pencil"></i></a>
@@ -95,7 +95,7 @@
{% endwith %}
<p class="clearfix">
<hr/>
- {% if order.serviceorderitem_set.count %}
+{% if order.serviceorderitem_set.count %}
<h3 class="pull-right">{% trans "Order Total" %}: <a href="#" class="tt" title="{{ order.net_total|currency }}">{{ order.gross_total|currency }}</a></h3>
- {% endif %}
+{% endif %}
</p>
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 %}
<li class="divider"></li>
<li><a href="{% url 'products-download' group.slug %}">{% trans "Download Products" %}</a></li>
- <li class="disabled"><a href="{% url 'products-get_inventory_report' %}">{% trans "Download Inventory Report" %}</a></li>
+ <li><a href="{% url 'products-get_inventory_report' %}">{% trans "Download Inventory Report" %}</a></li>
<li><a href="{% url 'products-upload_products' %}" data-modal="#modal">{% trans "Upload Products" %}</a></li>
<li><a href="{% url 'products-upload_gsx_parts' %}" data-modal="#modal">{% trans "Upload Parts Database" %}</a></li>
</ul>
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())