From 4194e8ee556f3109057fab0afb7894927b52713e Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Wed, 30 Sep 2015 02:08:19 +0300 Subject: Cleanup --- servo/forms/repairs.py | 3 +- servo/management/commands/cleandups.py | 24 ------- servo/management/commands/clearcache.py | 24 ------- servo/management/commands/cron.py | 2 +- servo/management/commands/dbbackup.py | 6 +- servo/management/commands/updateprices.py | 2 +- servo/models/__init__.py | 24 ------- servo/models/account.py | 12 ++-- servo/models/customer.py | 24 ------- servo/models/purchases.py | 23 +++++-- servo/models/rules.py | 24 ------- servo/templates/orders/dispatch.html | 12 ++-- servo/templates/orders/notes.html | 2 +- servo/templates/orders/products.html | 2 +- servo/templates/purchases/view_po.html | 82 ++++++++++++------------ servo/templates/shipments/list_bulk_returns.html | 6 +- servo/templates/shipments/list_incoming.html | 4 +- servo/templates/shipments/list_returns.html | 6 +- servo/urls/admin.py | 28 -------- servo/urls/invoices.py | 24 ------- servo/views/admin.py | 47 +------------- servo/views/customer.py | 2 +- servo/views/device.py | 6 +- servo/views/gsx.py | 4 +- servo/views/invoices.py | 26 +------- servo/views/note.py | 2 +- servo/views/order.py | 6 +- servo/views/purchases.py | 14 ++-- servo/views/shipments.py | 6 +- 29 files changed, 115 insertions(+), 332 deletions(-) (limited to 'servo') diff --git a/servo/forms/repairs.py b/servo/forms/repairs.py index 9a07250..9348d1f 100644 --- a/servo/forms/repairs.py +++ b/servo/forms/repairs.py @@ -34,8 +34,9 @@ class GsxCustomerForm(BaseForm): class GsxComponentForm(forms.Form): def __init__(self, *args, **kwargs): components = kwargs.get('components') - del kwargs['components'] + del(kwargs['components']) super(GsxComponentForm, self).__init__(*args, **kwargs) + if len(components): components = json.loads(components) for k, v in components.items(): diff --git a/servo/management/commands/cleandups.py b/servo/management/commands/cleandups.py index fa333bf..a7a2d46 100644 --- a/servo/management/commands/cleandups.py +++ b/servo/management/commands/cleandups.py @@ -1,28 +1,4 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2013, First Party Software -# All rights reserved. - -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. import logging from django.core.management.base import BaseCommand diff --git a/servo/management/commands/clearcache.py b/servo/management/commands/clearcache.py index 826ddef..7c00ef4 100644 --- a/servo/management/commands/clearcache.py +++ b/servo/management/commands/clearcache.py @@ -1,28 +1,4 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2013, First Party Software -# All rights reserved. - -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. from django.core.cache import cache from django.core.management.base import BaseCommand diff --git a/servo/management/commands/cron.py b/servo/management/commands/cron.py index d1b2806..5255104 100755 --- a/servo/management/commands/cron.py +++ b/servo/management/commands/cron.py @@ -49,7 +49,7 @@ class Command(BaseCommand): po = PurchaseOrder.objects.get(pk=details.purchaseOrderNumber) po.invoice_id = i po.invoice.save("%s.pdf" % i, File(open(details.invoiceData))) - except Exception, e: + except Exception as e: raise e def update_warranty(self): diff --git a/servo/management/commands/dbbackup.py b/servo/management/commands/dbbackup.py index 4858b77..af253a1 100644 --- a/servo/management/commands/dbbackup.py +++ b/servo/management/commands/dbbackup.py @@ -2,8 +2,8 @@ import os import sys +import subprocess from time import strftime -from subprocess import call from django.conf import settings from django.core.management.base import BaseCommand @@ -15,6 +15,6 @@ class Command(BaseCommand): db = settings.DATABASES['default'] fn = '%s_%s.pgdump' % (db['NAME'], strftime('%Y%m%d_%H%I')) fn = os.path.join(settings.BACKUP_DIR, fn) - - call(['/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_dump', '-Fc', db['NAME'], '-U', db['USER'], + + subprocess.call(['/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_dump', '-Fc', db['NAME'], '-U', db['USER'], '-f' , fn], env={'PGPASSWORD': db['PASSWORD']}) diff --git a/servo/management/commands/updateprices.py b/servo/management/commands/updateprices.py index c3a073c..50da680 100644 --- a/servo/management/commands/updateprices.py +++ b/servo/management/commands/updateprices.py @@ -33,7 +33,7 @@ class Command(BaseCommand): i.update_price() i.save() counter += 1 - except Exception, e: + except Exception as e: logging.debug(e) print '%d product prices updated' % counter diff --git a/servo/models/__init__.py b/servo/models/__init__.py index 1a109c8..1a06d71 100644 --- a/servo/models/__init__.py +++ b/servo/models/__init__.py @@ -1,28 +1,4 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2013, First Party Software -# All rights reserved. - -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. from common import * from product import * diff --git a/servo/models/account.py b/servo/models/account.py index 14535b2..46eb674 100644 --- a/servo/models/account.py +++ b/servo/models/account.py @@ -73,7 +73,7 @@ class User(AbstractUser): max_length=32, choices=LOCALES, default=LOCALES[0][0], - verbose_name=_('language'), + verbose_name=_('Language'), help_text=_("Select which language you want to use Servo in.") ) @@ -108,7 +108,7 @@ class User(AbstractUser): ) notify_by_email = models.BooleanField( default=False, - verbose_name=_('email notifications'), + verbose_name=_('Email notifications'), help_text=_("Event notifications will also be emailed to you.") ) autoprint = models.BooleanField( @@ -120,7 +120,7 @@ class User(AbstractUser): blank=True, default='', max_length=16, - verbose_name=_("tech ID") + verbose_name=_("Tech ID") ) gsx_userid = models.CharField( blank=True, @@ -141,7 +141,7 @@ class User(AbstractUser): null=True, blank=True, upload_to="avatars", - verbose_name=_('photo'), + verbose_name=_('Photo'), help_text=_("Maximum avatar size is 1MB") ) @@ -168,6 +168,10 @@ class User(AbstractUser): @classmethod def refresh_nomail(cls): + """ + Refreshes the list of emails that shouldn't + be notified by email + """ users = cls.active.filter(notify_by_email=False) nomail = [u.email for u in users] cache.set('nomail', nomail) diff --git a/servo/models/customer.py b/servo/models/customer.py index 2d1aec8..f147883 100644 --- a/servo/models/customer.py +++ b/servo/models/customer.py @@ -1,28 +1,4 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2013, First Party Software -# All rights reserved. - -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. import phonenumbers from django.db import models diff --git a/servo/models/purchases.py b/servo/models/purchases.py index 787fcc5..184f303 100644 --- a/servo/models/purchases.py +++ b/servo/models/purchases.py @@ -34,13 +34,13 @@ class PurchaseOrder(models.Model): blank=True, default='', max_length=32, - verbose_name=_("reference"), + verbose_name=_("Reference"), ) confirmation = models.CharField( blank=True, default='', max_length=32, - verbose_name=_("confirmation"), + verbose_name=_("Confirmation"), ) created_by = models.ForeignKey(settings.AUTH_USER_MODEL, editable=False) @@ -50,22 +50,22 @@ class PurchaseOrder(models.Model): supplier = models.CharField( blank=True, max_length=32, - verbose_name=_("supplier") + verbose_name=_("Supplier") ) carrier = models.CharField( blank=True, max_length=32, - verbose_name=_("carrier") + verbose_name=_("Carrier") ) tracking_id = models.CharField( blank=True, max_length=128, - verbose_name=_("tracking ID") + verbose_name=_("Tracking ID") ) days_delivered = models.IntegerField( blank=True, default=1, - verbose_name=_("delivery Time") + verbose_name=_("Delivery Time") ) has_arrived = models.BooleanField(default=False) @@ -79,9 +79,14 @@ class PurchaseOrder(models.Model): ) def only_apple_parts(self): + """ + Returns True if PO contains only Apple parts + Useful for Stocking Orders + """ for p in self.purchaseorderitem_set.all(): if not p.product.is_apple_part: return False + return True @property @@ -98,6 +103,7 @@ class PurchaseOrder(models.Model): from django.core.urlresolvers import reverse if self.submitted_at: return reverse("purchases-view_po", args=[self.pk]) + return reverse("purchases-edit_po", args=[self.pk]) def sum(self): @@ -115,7 +121,9 @@ class PurchaseOrder(models.Model): return amount def submit(self, user): - "Submits this Purchase Order" + """ + Submits this Purchase Order + """ if self.submitted_at is not None: raise ValueError(_("Purchase Order %d has already been submitted") % self.pk) @@ -171,6 +179,7 @@ class PurchaseOrder(models.Model): def delete(self, *args, **kwargs): if self.submitted_at: raise ValueError(_('Submitted orders cannot be deleted')) + return super(PurchaseOrder, self).delete(*args, **kwargs) class Meta: diff --git a/servo/models/rules.py b/servo/models/rules.py index db54ec6..1e6ec2d 100644 --- a/servo/models/rules.py +++ b/servo/models/rules.py @@ -1,28 +1,4 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2013, First Party Software -# All rights reserved. - -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. from django.db import models from django.core.cache import cache diff --git a/servo/templates/orders/dispatch.html b/servo/templates/orders/dispatch.html index f7ea0fb..41126c7 100755 --- a/servo/templates/orders/dispatch.html +++ b/servo/templates/orders/dispatch.html @@ -89,12 +89,12 @@ - - -
-
- {% trans "Cancel" %} - +
+
+ {% trans "Cancel" %} + +
+
diff --git a/servo/templates/orders/notes.html b/servo/templates/orders/notes.html index 06cc61d..0e59e81 100755 --- a/servo/templates/orders/notes.html +++ b/servo/templates/orders/notes.html @@ -5,7 +5,7 @@ {% if not order.notes %}
-

{% trans "Order doesn't contain any notes." %}

+

{% trans "Order doesn't contain any notes" %}

{% endif %} diff --git a/servo/templates/orders/products.html b/servo/templates/orders/products.html index 72540ab..e8185af 100755 --- a/servo/templates/orders/products.html +++ b/servo/templates/orders/products.html @@ -83,7 +83,7 @@ {% endwith %} {% empty %}
-

{% trans "Order doesn't contain any products." %}

+

{% trans "Order doesn't contain any products" %}

{% endfor %} diff --git a/servo/templates/purchases/view_po.html b/servo/templates/purchases/view_po.html index c43a058..cd9fad5 100755 --- a/servo/templates/purchases/view_po.html +++ b/servo/templates/purchases/view_po.html @@ -9,48 +9,48 @@ {% endblock filter_bar %} {% block detail_view %} -
-
-
-
{% trans "Created By" %}
-
{{ po.created_by }}
-
{% trans "Created At" %}
-
{{ po.created_at|date:"SHORT_DATE_FORMAT" }}
-
{% trans "Sales Order" %}
-
{{ po.sales_order|default:"" }}
-
{% trans "Reference" %}
-
{{ po.reference }}
-
{% trans "Confirmation" %}
-
{{ po.confirmation }}
-
-
-
- - - - - - - - - - - - {% for i in po.purchaseorderitem_set.all %} - - - - - - - - {% endfor %} - -
{% trans "Product" %}{% trans "Reference" %}{% trans "Amount" %}{% trans "Purchase Price" %}{% trans "Received At" %}
{{ i.code }}
{{ i.title }}
{{ i.reference }}{{ i.amount }}{{ i.price|currency }}{{ i.received_at|date:"SHORT_DATE_FORMAT"|default:"-" }}
-
-
+
+
+
+
{% trans "Created By" %}
+
{{ po.created_by }}
+
{% trans "Created At" %}
+
{{ po.created_at|date:"SHORT_DATE_FORMAT" }}
+
{% trans "Sales Order" %}
+
{{ po.sales_order|default:"" }}
+
{% trans "Reference" %}
+
{{ po.reference }}
+
{% trans "Confirmation" %}
+
{{ po.confirmation }}
+
+
+
+ + + + + + + + + + + + {% for i in products %} + + + + + + + + {% endfor %} + +
{% trans "Product" %}{% trans "Reference" %}{% trans "Amount" %}{% trans "Purchase Price" %}{% trans "Received At" %}
{{ i.code }}
{{ i.title }}
{{ i.reference }}{{ i.amount }}{{ i.price|currency }}{{ i.received_at|date:"SHORT_DATE_FORMAT"|default:"-" }}
+
+
{% endblock detail_view %} {% block crumbs %} -
  • {% trans "Purchase Orders" %}
  • +
  • {% trans "Purchase Orders" %}
  • {% endblock crumbs %} diff --git a/servo/templates/shipments/list_bulk_returns.html b/servo/templates/shipments/list_bulk_returns.html index f2c4843..fd393bb 100755 --- a/servo/templates/shipments/list_bulk_returns.html +++ b/servo/templates/shipments/list_bulk_returns.html @@ -26,6 +26,10 @@ {{ i.num_parts }} {{ i.dispatched_by }}
    {{ i.dispatched_at|date:"SHORT_DATETIME_FORMAT" }} + {% empty %} + + {% trans "No bulk returns" %} + {% endfor %} @@ -33,5 +37,5 @@ {% endblock second_column %} {% block breadcrumb %} -
  • / {% trans "Browse Returns" %}
  • +
  • / {% trans "Browse Returns" %}
  • {% endblock breadcrumb %} diff --git a/servo/templates/shipments/list_incoming.html b/servo/templates/shipments/list_incoming.html index 5d2d784..3c9da41 100755 --- a/servo/templates/shipments/list_incoming.html +++ b/servo/templates/shipments/list_incoming.html @@ -17,7 +17,7 @@ {% trans "Part" %} {% trans "Service Order" %} {% trans "Confirmation" %} - {% trans "Ordered" %} + {% trans "Ordered By" %} @@ -57,5 +57,5 @@ {% endblock second_column %} {% block breadcrumb %} -
  • /{% trans "Incoming" %}
  • +
  • /{% trans "Incoming" %}
  • {% endblock breadcrumb %} diff --git a/servo/templates/shipments/list_returns.html b/servo/templates/shipments/list_returns.html index 7d57286..029d236 100755 --- a/servo/templates/shipments/list_returns.html +++ b/servo/templates/shipments/list_returns.html @@ -18,7 +18,7 @@ - {% for p in parts %} + {% for p in parts %} {{ p.partNumber }} @@ -28,11 +28,11 @@ {{ p.registeredForReturn }} {{ p.kbbSerialNumber }} - {% empty %} + {% empty %} {% trans "No parts pending return" %} - {% endfor %} + {% endfor %} diff --git a/servo/urls/admin.py b/servo/urls/admin.py index 8e4d4ca..1703da0 100644 --- a/servo/urls/admin.py +++ b/servo/urls/admin.py @@ -1,28 +1,4 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2013, First Party Software -# All rights reserved. - -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. from django.conf.urls import patterns, url, include from servo.views import admin @@ -91,10 +67,6 @@ urlpatterns = patterns( url(r'^checklists/(?P\d+)/edit/$', 'edit_checklist', name='admin-edit_checklist'), url(r'^checklists/(?P\d+)/delete/$', 'delete_checklist', name='admin-delete_checklist'), - url(r'^sites/$', 'list_sites', name="admin-list_sites"), - url(r'^sites/new/$', 'edit_site', name="admin-create_site"), - url(r'^sites/(\d+)/edit/$', 'edit_site', name="admin-edit_site"), - url(r'^rules/', include('servo.urls.rules')), url(r'^backups/$', 'backups', name="admin-backups"), diff --git a/servo/urls/invoices.py b/servo/urls/invoices.py index a26d464..fa957f1 100644 --- a/servo/urls/invoices.py +++ b/servo/urls/invoices.py @@ -1,28 +1,4 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2013, First Party Software -# All rights reserved. - -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. from django.conf.urls import patterns, url diff --git a/servo/views/admin.py b/servo/views/admin.py index c4e5aa8..6a54a4f 100644 --- a/servo/views/admin.py +++ b/servo/views/admin.py @@ -454,7 +454,7 @@ def delete_user(request, user_id): try: user.delete() messages.success(request, _("User deleted")) - except Exception, e: + except Exception as e: messages.error(request, e) return redirect(list_users) @@ -563,7 +563,7 @@ def delete_location(request, pk): try: location.delete() messages.success(request, _(u'%s deleted') % location.title) - except Exception, e: + except Exception as e: messages.error(request, e) return redirect(locations) @@ -654,47 +654,6 @@ def edit_notification(request, nid): return render(request, 'admin/notifications/form.html') -def list_sites(request): - if not request.user.is_superuser: - messages.error(request, _(u"Access denied")) - return redirect('/login/') - - data = {'sites': Site.objects.all()} - data['title'] = _(u"Manage Sites") - - return render(request, "admin/sites/index.html", data) - - -def edit_site(request, pk=None): - if not request.user.is_superuser: - messages.add_message(request, messages.ERROR, _(u"Access denied")) - return redirect('/login/') - - site = Site() - data = {'title': _(u"New Site")} - - if pk is not None: - site = Site.objects.get(pk=pk) - data['title'] = site.name - - SiteForm = modelform_factory(Site, exclude=[]) - form = SiteForm(instance=site) - - if request.method == "POST": - - form = SiteForm(request.POST, instance=site) - - if form.is_valid(): - form.save() - messages.add_message(request, messages.SUCCESS, _(u"Site saved")) - return redirect(list_sites) - - data['form'] = form - data['sites'] = Site.objects.all() - - return render(request, "admin/sites/edit_site.html", data) - - def upload_users(request): """ """ @@ -708,7 +667,7 @@ def upload_users(request): try: users = form.save() messages.success(request, _('%d users imported') % len(users)) - except Exception, e: + except Exception as e: messages.error(request, e) else: messages.error(request, form.errors) diff --git a/servo/views/customer.py b/servo/views/customer.py index 789121b..9adb3e5 100644 --- a/servo/views/customer.py +++ b/servo/views/customer.py @@ -296,7 +296,7 @@ def move(request, pk, new_parent=None): customer.move_to(new_parent) customer.save() # To update fullname messages.success(request, msg) - except Exception, e: + except Exception as e: messages.error(request, e) return redirect(customer) diff --git a/servo/views/device.py b/servo/views/device.py index 9babbd2..55895bc 100644 --- a/servo/views/device.py +++ b/servo/views/device.py @@ -302,7 +302,7 @@ def get_gsx_search_results(request, what, param, query): try: results = device.get_parts() data['device'] = device - except Exception, e: + except Exception as e: return render(request, error_template, {'message': e}) if param == "productName": @@ -532,7 +532,7 @@ def upload_devices(request): if gsx_account: try: device = Device.from_gsx(row[0]) - except Exception, e: + except Exception as e: messages.error(request, e) break else: @@ -569,7 +569,7 @@ def update_gsx_details(request, pk): GsxAccount.default(request.user) device.update_gsx_details() messages.success(request, _("Warranty status updated successfully")) - except Exception, e: + except Exception as e: messages.error(request, e) if request.session.get('return_to'): diff --git a/servo/views/gsx.py b/servo/views/gsx.py index bafdce5..ebd1952 100644 --- a/servo/views/gsx.py +++ b/servo/views/gsx.py @@ -160,7 +160,7 @@ def check_parts_warranty(request, repair): try: wty = repair.warranty_status() wty_parts = wty.parts - except Exception, e: + except Exception as e: return render(request, 'search/results/gsx_error.html', {'message': e}) try: @@ -349,7 +349,7 @@ def update_sn(request, pk, part): part.update_sn() msg = _(u'%s serial numbers updated') % part.part_number messages.success(request, msg) - except Exception, e: + except Exception as e: messages.error(request, e) return redirect(part.repair.order) diff --git a/servo/views/invoices.py b/servo/views/invoices.py index cc48c60..2fb7b26 100644 --- a/servo/views/invoices.py +++ b/servo/views/invoices.py @@ -1,28 +1,4 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2013, First Party Software -# All rights reserved. - -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. from django import forms from django.utils import timezone @@ -181,7 +157,7 @@ def create_invoice(request, order_id=None, numbers=None): try: order.dispatch(invoice=invoice, products=products) messages.success(request, _(u'Order %s dispatched') % order.code) - except Exception, e: + except Exception as e: messages.error(request, e) return redirect(order) else: diff --git a/servo/views/note.py b/servo/views/note.py index 0d7ae06..a68312a 100644 --- a/servo/views/note.py +++ b/servo/views/note.py @@ -153,7 +153,7 @@ def edit(request, pk=None, order_id=None, parent=None, recipient=None, customer= try: note.escalation = Escalation(created_by=request.user) - except Exception, e: + except Exception as e: messages.error(request, e) return redirect(request.META['HTTP_REFERER']) diff --git a/servo/views/order.py b/servo/views/order.py index 43277c4..3d9adad 100644 --- a/servo/views/order.py +++ b/servo/views/order.py @@ -457,7 +457,7 @@ def remove_user(request, pk, user_id): if user == order.user: order.set_user(None, request.user) order.notify("unset_user", _('User %s removed from followers') % user, request.user) - except Exception, e: + except Exception as e: messages.error(request, e) return redirect(order) @@ -632,7 +632,7 @@ def device_from_product(request, pk, item_id): device.save() event = order.add_device(device, request.user) messages.success(request, event) - except Exception, e: + except Exception as e: messages.error(request, e) return redirect(order) @@ -676,7 +676,7 @@ def edit_product(request, pk, item_id): if item.product.component_code: try: GsxAccount.default(request.user, order.queue) - except Exception, e: + except Exception as e: return render(request, "snippets/error_modal.html", {'error': e}) form = OrderItemForm(instance=item) diff --git a/servo/views/purchases.py b/servo/views/purchases.py index 5a32857..7233ceb 100644 --- a/servo/views/purchases.py +++ b/servo/views/purchases.py @@ -67,8 +67,8 @@ def list_pos(request): orders = paginator.page(paginator.num_pages) data['orders'] = orders - data['form'] = form - data['total'] = all_orders.aggregate(Sum('total')) + data['form'] = form + data['total'] = all_orders.aggregate(Sum('total')) return render(request, "purchases/list_pos.html", data) @@ -92,7 +92,8 @@ def add_to_po(request, pk, product_id): def view_po(request, pk): - po = PurchaseOrder.objects.get(pk=pk) + po = get_object_or_404(PurchaseOrder, pk=pk) + products = po.purchaseorderitem_set.all() title = _('Purchase Order %d' % po.pk) return render(request, "purchases/view_po.html", locals()) @@ -158,7 +159,8 @@ def order_stock(request, po_id): if request.method == "POST": if po.submitted_at: - messages.error(request, _(u'Purchase Order %s has already been submitted') % po.pk) + msg = _(u'Purchase Order %s has already been submitted') % po.pk + messages.error(request, msg) return list_pos(request) act = GsxAccount.default(request.user) @@ -201,12 +203,12 @@ def delete_po(request, po_id): @permission_required('servo.add_purchaseorder') def create_po(request, product_id=None, order_id=None): po = PurchaseOrder(created_by=request.user) - location = request.user.get_location() - po.location = location + po.location = request.user.get_location() po.save() if order_id is not None: po.sales_order_id = order_id + po.save() for i in ServiceOrderItem.objects.filter(order_id=order_id): po.add_product(i, amount=1, user=request.user) diff --git a/servo/views/shipments.py b/servo/views/shipments.py index 3d0a56e..ada3a07 100644 --- a/servo/views/shipments.py +++ b/servo/views/shipments.py @@ -145,7 +145,7 @@ def view_incoming(request, pk): if form.is_valid(): try: item = form.save() - except gsxws.GsxError, e: + except gsxws.GsxError as e: messages.error(request, e) return redirect(view_incoming, date, pk) @@ -176,7 +176,7 @@ def return_label(request, code, return_order): try: label = gsxws.Returns(return_order) return HttpResponse(label.returnLabelFileData, content_type="application/pdf") - except Exception, e: + except Exception as e: messages.add_message(request, messages.ERROR, e) return redirect('products-list') @@ -252,7 +252,7 @@ def edit_bulk_return(request, pk=None, ship_to=None): msg = _(u"Bulk return %s submitted") % shipment.return_id messages.success(request, msg) return redirect(view_bulk_return, shipment.pk) - except Exception, e: + except Exception as e: messages.error(request, e) return redirect(edit_bulk_return, ship_to=ship_to) messages.success(request, msg) -- cgit v1.2.3