aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--servo/models/account.py5
-rw-r--r--servo/models/customer.py3
-rw-r--r--servo/models/device.py2
-rw-r--r--servo/models/product.py20
-rw-r--r--servo/models/queue.py24
-rw-r--r--settings.py1
6 files changed, 23 insertions, 32 deletions
diff --git a/servo/models/account.py b/servo/models/account.py
index d4549c6..b86c877 100644
--- a/servo/models/account.py
+++ b/servo/models/account.py
@@ -7,7 +7,7 @@ from django.conf import settings
from pytz import common_timezones
from django.core.cache import cache
-from django.core.urlresolvers import reverse
+from django.urls import reverse
from rest_framework.authtoken.models import Token
from mptt.fields import TreeForeignKey
@@ -39,6 +39,7 @@ class User(AbstractUser):
Customer,
null=True,
blank=True,
+ on_delete=models.SET_NULL,
limit_choices_to={'is_company': True}
)
@@ -55,7 +56,7 @@ class User(AbstractUser):
Location,
null=True,
related_name='+',
- on_delete=models.PROTECT,
+ on_delete=models.SET_NULL,
verbose_name=_('Current Location'),
help_text=_('Orders you create will be registered to this location.')
)
diff --git a/servo/models/customer.py b/servo/models/customer.py
index a6609d0..f83515d 100644
--- a/servo/models/customer.py
+++ b/servo/models/customer.py
@@ -45,6 +45,7 @@ class Customer(MPTTModel):
'self',
null=True,
blank=True,
+ on_delete=models.CASCADE,
related_name='contacts',
verbose_name=_('company'),
limit_choices_to={'is_company': True}
@@ -289,7 +290,7 @@ class Customer(MPTTModel):
class ContactInfo(models.Model):
- customer = models.ForeignKey(Customer)
+ customer = models.ForeignKey(Customer, on_delete=models.CASCADE)
key = models.CharField(max_length=255)
value = models.CharField(max_length=255)
diff --git a/servo/models/device.py b/servo/models/device.py
index df28671..6487179 100644
--- a/servo/models/device.py
+++ b/servo/models/device.py
@@ -13,7 +13,7 @@ from django.core.files import File
from django.core.cache import cache
from django.dispatch import receiver
from django.utils.text import slugify
-from django.core.urlresolvers import reverse
+from django.urls import reverse
from django.db.models.signals import post_save
from django.contrib.contenttypes.fields import GenericRelation
diff --git a/servo/models/product.py b/servo/models/product.py
index 189ca8a..7ec2b30 100644
--- a/servo/models/product.py
+++ b/servo/models/product.py
@@ -10,7 +10,6 @@ from django.core.files import File
from django.core.cache import cache
from decimal import Decimal, ROUND_CEILING
from django.urls import reverse
-from django.contrib.sites.models import Site
from django.contrib.contenttypes.fields import GenericRelation
@@ -547,11 +546,7 @@ class Product(AbstractBaseProduct):
class ProductCategory(MPTTModel):
- site = models.ForeignKey(
- Site,
- editable=False,
- default=defaults.site_id
- )
+
title = models.CharField(
max_length=255,
unique=True,
@@ -562,7 +557,8 @@ class ProductCategory(MPTTModel):
'self',
null=True,
blank=True,
- related_name='children'
+ related_name='children',
+ on_delete=models.CASCADE,
)
objects = TreeManager()
@@ -596,15 +592,14 @@ class ProductCategory(MPTTModel):
app_label = "servo"
get_latest_by = "id"
ordering = ("-title",)
- unique_together = ("title", "site",)
class Inventory(models.Model):
"""
Inventory tracks how much of Product X is in Location Y
"""
- product = models.ForeignKey(Product)
- location = models.ForeignKey(Location)
+ product = models.ForeignKey(Product, on_delete=models.CASCADE)
+ location = models.ForeignKey(Location, on_delete=models.CASCADE)
amount_minimum = models.PositiveIntegerField(
default=0,
@@ -630,8 +625,9 @@ class Inventory(models.Model):
if new_location == self.location:
raise ValueError(_('Cannot move products to the same location'))
- target, created = Inventory.objects.get_or_create(location=new_location,
- product=self.product)
+ target, created = Inventory.objects.get_or_create(
+ location=new_location,
+ product=self.product)
self.amount_stocked = self.amount_stocked - amount
self.save()
target.amount_stocked = target.amount_stocked + amount
diff --git a/servo/models/queue.py b/servo/models/queue.py
index 79fcb87..3e74783 100644
--- a/servo/models/queue.py
+++ b/servo/models/queue.py
@@ -6,18 +6,12 @@ from django.db import models
from django.utils import timezone
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
-from django.contrib.sites.models import Site
from servo import defaults
from servo.models.common import Location
class Queue(models.Model):
- site = models.ForeignKey(
- Site,
- editable=False,
- default=defaults.site_id
- )
title = models.CharField(
max_length=255,
@@ -64,6 +58,7 @@ class Queue(models.Model):
null=True,
blank=True,
related_name='+',
+ on_delete=models.SET_NULL,
verbose_name=_(u'Order Created'),
help_text=_("Order has ben placed to a queue")
)
@@ -73,6 +68,7 @@ class Queue(models.Model):
null=True,
blank=True,
related_name='+',
+ on_delete=models.SET_NULL,
verbose_name=_(u'Order Assigned'),
help_text=_("Order has ben assigned to a user")
)
@@ -82,6 +78,7 @@ class Queue(models.Model):
null=True,
blank=True,
related_name='+',
+ on_delete=models.SET_NULL,
verbose_name=_("Products Ordered"),
help_text=_("Purchase Order for this Service Order has been submitted")
)
@@ -90,6 +87,7 @@ class Queue(models.Model):
null=True,
blank=True,
related_name='+',
+ on_delete=models.SET_NULL,
verbose_name=_("Products Received"),
help_text=_("Products have been received")
)
@@ -98,6 +96,7 @@ class Queue(models.Model):
null=True,
blank=True,
related_name='+',
+ on_delete=models.SET_NULL,
verbose_name=_("Repair Completed"),
help_text=_("GSX repair completed")
)
@@ -107,6 +106,7 @@ class Queue(models.Model):
null=True,
blank=True,
related_name='+',
+ on_delete=models.SET_NULL,
verbose_name=_("Order Dispatched")
)
@@ -115,6 +115,7 @@ class Queue(models.Model):
null=True,
blank=True,
related_name='+',
+ on_delete=models.SET_NULL,
verbose_name=_("Order Closed")
)
@@ -174,15 +175,9 @@ class Queue(models.Model):
app_label = "servo"
verbose_name = _("Queue")
verbose_name_plural = _("Queues")
- unique_together = ('title', 'site',)
class Status(models.Model):
- site = models.ForeignKey(
- Site,
- editable=False,
- default=defaults.site_id
- )
FACTOR_CHOICES = (
(60, _('Minutes')),
@@ -235,7 +230,6 @@ class Status(models.Model):
ordering = ('title',)
verbose_name = _('Status')
verbose_name_plural = _('Statuses')
- unique_together = ('title', 'site',)
class QueueStatus(models.Model):
@@ -243,8 +237,8 @@ class QueueStatus(models.Model):
A status bound to a queue.
This allows us to set time limits for each status per indiviudal queue
"""
- queue = models.ForeignKey(Queue)
- status = models.ForeignKey(Status)
+ queue = models.ForeignKey(Queue, on_delete=models.CASCADE)
+ status = models.ForeignKey(Status, on_delete=models.CASCADE)
limit_green = models.IntegerField(default=1, verbose_name=_(u'Green limit'))
limit_yellow = models.IntegerField(default=15, verbose_name=_(u'Yellow limit'))
diff --git a/settings.py b/settings.py
index 7a9d450..c53a3c7 100644
--- a/settings.py
+++ b/settings.py
@@ -100,7 +100,6 @@ INSTALLED_APPS = (
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
- 'django.contrib.sites',
'django.contrib.sessions',
#'debug_toolbar',
'rest_framework', 'wkhtmltopdf',