aboutsummaryrefslogtreecommitdiffstats
path: root/servo/models
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2015-09-30 02:08:19 +0300
committerFilipp Lepalaan <filipp@mac.com>2015-09-30 02:08:19 +0300
commit4194e8ee556f3109057fab0afb7894927b52713e (patch)
tree996cb5de38706b07bb24f519d868b29da54c0b67 /servo/models
parent03326a06e12de1af575c8e4b2de7e3824f6eaace (diff)
downloadServo-4194e8ee556f3109057fab0afb7894927b52713e.tar.gz
Servo-4194e8ee556f3109057fab0afb7894927b52713e.tar.bz2
Servo-4194e8ee556f3109057fab0afb7894927b52713e.zip
Cleanup
Diffstat (limited to 'servo/models')
-rw-r--r--servo/models/__init__.py24
-rw-r--r--servo/models/account.py12
-rw-r--r--servo/models/customer.py24
-rw-r--r--servo/models/purchases.py23
-rw-r--r--servo/models/rules.py24
5 files changed, 24 insertions, 83 deletions
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