aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--servo/migrations/0028_auto_20150907_0938.py174
-rw-r--r--servo/models/account.py4
-rw-r--r--servo/models/common.py53
-rw-r--r--servo/models/customer.py8
-rw-r--r--servo/models/device.py6
-rw-r--r--servo/models/invoices.py10
-rw-r--r--servo/models/note.py11
-rw-r--r--servo/models/order.py13
-rw-r--r--servo/models/product.py15
-rw-r--r--servo/models/purchases.py6
-rw-r--r--servo/models/queue.py27
11 files changed, 207 insertions, 120 deletions
diff --git a/servo/migrations/0028_auto_20150907_0938.py b/servo/migrations/0028_auto_20150907_0938.py
new file mode 100644
index 0000000..321952e
--- /dev/null
+++ b/servo/migrations/0028_auto_20150907_0938.py
@@ -0,0 +1,174 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('servo', '0027_remove_location_logo'),
+ ]
+
+ operations = [
+ migrations.AlterModelManagers(
+ name='attachment',
+ managers=[
+ ],
+ ),
+ migrations.AlterModelManagers(
+ name='checklist',
+ managers=[
+ ],
+ ),
+ migrations.AlterModelManagers(
+ name='customer',
+ managers=[
+ ],
+ ),
+ migrations.AlterModelManagers(
+ name='device',
+ managers=[
+ ],
+ ),
+ migrations.AlterModelManagers(
+ name='event',
+ managers=[
+ ],
+ ),
+ migrations.AlterModelManagers(
+ name='flaggeditem',
+ managers=[
+ ],
+ ),
+ migrations.AlterModelManagers(
+ name='invoice',
+ managers=[
+ ],
+ ),
+ migrations.AlterModelManagers(
+ name='note',
+ managers=[
+ ],
+ ),
+ migrations.AlterModelManagers(
+ name='order',
+ managers=[
+ ],
+ ),
+ migrations.AlterModelManagers(
+ name='productcategory',
+ managers=[
+ ],
+ ),
+ migrations.AlterModelManagers(
+ name='queue',
+ managers=[
+ ],
+ ),
+ migrations.AlterModelManagers(
+ name='rateditem',
+ managers=[
+ ],
+ ),
+ migrations.AlterModelManagers(
+ name='tag',
+ managers=[
+ ],
+ ),
+ migrations.AlterModelManagers(
+ name='taggeditem',
+ managers=[
+ ],
+ ),
+ migrations.AlterModelManagers(
+ name='timeditem',
+ managers=[
+ ],
+ ),
+ migrations.RemoveField(
+ model_name='attachment',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='checklist',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='customer',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='device',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='event',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='flaggeditem',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='invoice',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='note',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='order',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='product',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='property',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='purchaseorder',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='rateditem',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='search',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='tag',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='taggeditem',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='template',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='timeditem',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='user',
+ name='site',
+ ),
+ migrations.RemoveField(
+ model_name='usergroup',
+ name='site',
+ ),
+ migrations.AlterField(
+ model_name='queue',
+ name='title',
+ field=models.CharField(default='New Queue', unique=True, max_length=255, verbose_name='Title'),
+ ),
+ ]
diff --git a/servo/models/account.py b/servo/models/account.py
index a51a340..f78518c 100644
--- a/servo/models/account.py
+++ b/servo/models/account.py
@@ -35,7 +35,6 @@ from django.core.urlresolvers import reverse
from rest_framework.authtoken.models import Token
from mptt.fields import TreeForeignKey
-from django.contrib.sites.models import Site
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import AbstractUser, Group, UserManager
@@ -60,7 +59,7 @@ class TechieManager(UserManager):
class User(AbstractUser):
- site = models.ForeignKey(Site, editable=False, default=defaults.site_id)
+
customer = TreeForeignKey(
Customer,
null=True,
@@ -298,7 +297,6 @@ class User(AbstractUser):
class UserGroup(Group):
- site = models.ForeignKey(Site, editable=False, default=defaults.site_id)
def members_as_list(self):
pass
diff --git a/servo/models/common.py b/servo/models/common.py
index df23a86..db59cc2 100644
--- a/servo/models/common.py
+++ b/servo/models/common.py
@@ -33,12 +33,12 @@ from django.core.urlresolvers import reverse
from django.template.defaultfilters import slugify
from pytz import common_timezones, country_timezones
+from django.contrib.sites.models import Site
+
from django.db import models
from django.conf import settings
-from django.contrib.sites.models import Site
from mptt.managers import TreeManager
-from django.contrib.sites.managers import CurrentSiteManager
from mptt.models import MPTTModel, TreeForeignKey
from django.utils.translation import ugettext_lazy as _
@@ -103,14 +103,10 @@ class BaseItem(models.Model):
"""
Base class for a few generic relationships
"""
- site = models.ForeignKey(Site, editable=False, default=defaults.site_id)
-
object_id = models.PositiveIntegerField()
content_type = models.ForeignKey(ContentType)
content_object = GenericForeignKey("content_type", "object_id")
- objects = CurrentSiteManager()
-
class Meta:
abstract = True
app_label = "servo"
@@ -197,6 +193,7 @@ class Event(BaseItem):
class GsxAccount(models.Model):
+
site = models.ForeignKey(
Site,
editable=False,
@@ -324,12 +321,6 @@ class Tag(MPTTModel):
The type attribute is used to group tags to make them easier
to associate with different elements
"""
- site = models.ForeignKey(
- Site,
- editable=False,
- default=defaults.site_id
- )
-
title = models.CharField(
unique=True,
max_length=255,
@@ -386,7 +377,6 @@ class Tag(MPTTModel):
return self.title
objects = TreeManager()
- on_site = CurrentSiteManager()
class Meta:
app_label = 'servo'
@@ -418,7 +408,11 @@ class Location(models.Model):
max_length=32,
verbose_name=_('phone')
)
- email = models.EmailField(blank=True, default='', verbose_name=_('email'))
+ email = models.EmailField(
+ blank=True,
+ default='',
+ verbose_name=_('email')
+ )
address = models.CharField(
blank=True,
default='',
@@ -555,11 +549,11 @@ class Configuration(models.Model):
@classmethod
def track_inventory(cls):
- return cls.conf('track_inventory') == 'True'
+ return cls.true('track_inventory')
@classmethod
def notify_location(cls):
- return cls.conf('notify_location') == 'True'
+ return cls.true('notify_location')
@classmethod
def notify_email_address(cls):
@@ -576,11 +570,11 @@ class Configuration(models.Model):
@classmethod
def autocomplete_repairs(cls):
- return cls.conf('autocomplete_repairs') == 'True'
+ return cls.true('autocomplete_repairs')
@classmethod
def smtp_ssl(cls):
- return cls.conf('smtp_ssl') == 'True'
+ return cls.true('smtp_ssl')
@classmethod
def get_imap_server(cls):
@@ -626,16 +620,10 @@ class Configuration(models.Model):
class Property(models.Model):
- site = models.ForeignKey(
- Site,
- editable=False,
- default=defaults.site_id
- )
-
TYPES = (
- ('customer', _('Customer')),
- ('order', _('Order')),
- ('product', _('Product'))
+ ('customer', _('Customer')),
+ ('order', _('Order')),
+ ('product', _('Product'))
)
title = models.CharField(
@@ -678,11 +666,6 @@ class Property(models.Model):
class Search(models.Model):
- site = models.ForeignKey(
- Site,
- editable=False,
- default=defaults.site_id
- )
query = models.TextField()
model = models.CharField(max_length=32)
title = models.CharField(max_length=128)
@@ -708,12 +691,6 @@ class Notification(models.Model):
class Template(models.Model):
- site = models.ForeignKey(
- Site,
- editable=False,
- default=defaults.site_id
- )
-
title = models.CharField(
blank=False,
unique=True,
diff --git a/servo/models/customer.py b/servo/models/customer.py
index e89c3dd..2d1aec8 100644
--- a/servo/models/customer.py
+++ b/servo/models/customer.py
@@ -29,11 +29,9 @@ from django.db import models
from django.conf import settings
from mptt.managers import TreeManager
-from django.contrib.sites.models import Site
from django.template.defaultfilters import slugify
from mptt.models import MPTTModel, TreeForeignKey
from django.utils.translation import ugettext_lazy as _
-from django.contrib.sites.managers import CurrentSiteManager
from pytz import country_names
@@ -66,11 +64,6 @@ class CustomerGroup(models.Model):
class Customer(MPTTModel):
- site = models.ForeignKey(
- Site,
- editable=False,
- default=defaults.site_id
- )
parent = TreeForeignKey(
'self',
null=True,
@@ -167,7 +160,6 @@ class Customer(MPTTModel):
)
objects = TreeManager()
- on_site = CurrentSiteManager()
def get_contacts(self):
return self.get_descendants(include_self=False)
diff --git a/servo/models/device.py b/servo/models/device.py
index 993b96b..fa71146 100644
--- a/servo/models/device.py
+++ b/servo/models/device.py
@@ -36,7 +36,6 @@ 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.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from django.db.models.signals import post_save
@@ -44,7 +43,6 @@ from django.contrib.contenttypes.fields import GenericRelation
from django.utils.translation import ugettext_lazy as _
from django.contrib.contenttypes.models import ContentType
-from django.contrib.sites.managers import CurrentSiteManager
from servo import defaults
from servo.validators import sn_validator
@@ -55,8 +53,6 @@ class Device(models.Model):
"""
The serviceable device
"""
- site = models.ForeignKey(Site, editable=False, default=defaults.site_id)
-
# @TODO: unique=True would be nice, but complicated...
sn = models.CharField(
blank=True,
@@ -218,8 +214,6 @@ class Device(models.Model):
)
fmip_active = models.BooleanField(default=False, editable=False)
- objects = CurrentSiteManager()
-
def is_apple_device(self):
"""
Checks if this is a valid Apple device SN
diff --git a/servo/models/invoices.py b/servo/models/invoices.py
index 301753a..d30b442 100644
--- a/servo/models/invoices.py
+++ b/servo/models/invoices.py
@@ -27,24 +27,16 @@
from django.db import models
from django.conf import settings
from django.utils import timezone
-from django.contrib.sites.models import Site
from django.utils.translation import ugettext_lazy as _
from django.dispatch import receiver
from django.db.models.signals import post_save
-from django.contrib.sites.managers import CurrentSiteManager
-
from servo import defaults
from servo.models import User, Customer, Order, ServiceOrderItem, AbstractOrderItem
class Invoice(models.Model):
- site = models.ForeignKey(
- Site,
- editable=False,
- default=defaults.site_id
- )
created_at = models.DateTimeField(editable=False, auto_now_add=True)
created_by = models.ForeignKey(settings.AUTH_USER_MODEL, editable=False)
@@ -116,8 +108,6 @@ class Invoice(models.Model):
editable=False
)
- objects = CurrentSiteManager()
-
def get_payment_total(self):
from django.db.models import Sum
result = self.payment_set.all().aggregate(Sum('amount'))
diff --git a/servo/models/note.py b/servo/models/note.py
index cbdea2f..2e8e1bb 100644
--- a/servo/models/note.py
+++ b/servo/models/note.py
@@ -42,17 +42,12 @@ from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
from django.core.mail import send_mail, EmailMessage
-
-from django.contrib.sites.models import Site
-
from django.contrib.contenttypes.fields import GenericRelation
from django.template.defaultfilters import truncatechars
from django.db.models.signals import pre_delete, post_save
from mptt.managers import TreeManager
-from django.contrib.sites.managers import CurrentSiteManager
-
from mptt.models import MPTTModel, TreeForeignKey
from servo import defaults
@@ -87,11 +82,6 @@ def validate_phone_number(number):
class Note(MPTTModel):
- site = models.ForeignKey(
- Site,
- editable=False,
- default=defaults.site_id
- )
subject = models.CharField(
blank=True,
max_length=255,
@@ -149,7 +139,6 @@ class Note(MPTTModel):
)
objects = TreeManager()
- on_site = CurrentSiteManager()
def __render__(self, tpl, ctx):
from django import template
diff --git a/servo/models/order.py b/servo/models/order.py
index d4f1fe3..62333b5 100644
--- a/servo/models/order.py
+++ b/servo/models/order.py
@@ -31,8 +31,6 @@ from django.conf import settings
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
-from django.contrib.sites.managers import CurrentSiteManager
-
from django.contrib.contenttypes.fields import GenericRelation
from django.dispatch import receiver
@@ -50,11 +48,7 @@ from servo.models.queue import Queue, Status, QueueStatus
class Order(models.Model):
- site = models.ForeignKey(
- Site,
- editable=False,
- default=defaults.site_id
- )
+
code = models.CharField(max_length=8, unique=True, null=True)
url_code = models.CharField(max_length=8, unique=True, null=True)
# Device description or something else
@@ -161,13 +155,12 @@ class Order(models.Model):
)
state = models.IntegerField(default=0, choices=STATES)
-
+
status_name = models.CharField(max_length=128, default="")
status_started_at = models.DateTimeField(null=True)
status_limit_green = models.DateTimeField(null=True) # turn yellow after this
status_limit_yellow = models.DateTimeField(null=True) # turn red after this
-
- objects = CurrentSiteManager()
+
api_fields = ('status_name', 'status_description',)
def apply_rules(self):
diff --git a/servo/models/product.py b/servo/models/product.py
index f7cd418..5cd7f8b 100644
--- a/servo/models/product.py
+++ b/servo/models/product.py
@@ -34,12 +34,10 @@ from django.core.files import File
from django.core.cache import cache
from decimal import Decimal, ROUND_CEILING
from django.core.urlresolvers import reverse
+from django.contrib.sites.models import Site
from django.contrib.contenttypes.fields import GenericRelation
-from django.contrib.sites.managers import CurrentSiteManager
-
-from django.contrib.sites.models import Site
from django.utils.translation import ugettext_lazy as _
from mptt.models import MPTTModel, TreeForeignKey
@@ -207,12 +205,6 @@ class AbstractBaseProduct(models.Model):
class Product(AbstractBaseProduct):
-
- site = models.ForeignKey(
- Site,
- editable=False,
- default=defaults.site_id
- )
warranty_period = models.PositiveIntegerField(
default=0,
verbose_name=_("Warranty (months)")
@@ -557,13 +549,11 @@ class Product(AbstractBaseProduct):
class ProductCategory(MPTTModel):
-
site = models.ForeignKey(
Site,
editable=False,
default=defaults.site_id
)
-
title = models.CharField(
max_length=255,
unique=True,
@@ -578,7 +568,6 @@ class ProductCategory(MPTTModel):
)
objects = TreeManager()
- on_site = CurrentSiteManager()
def get_products(self):
return Product.objects.filter(
@@ -606,7 +595,7 @@ class ProductCategory(MPTTModel):
app_label = "servo"
get_latest_by = "id"
ordering = ("-title",)
- unique_together = ("title", "site", )
+ unique_together = ("title", "site",)
class Inventory(models.Model):
diff --git a/servo/models/purchases.py b/servo/models/purchases.py
index 4b9a886..c7a31d2 100644
--- a/servo/models/purchases.py
+++ b/servo/models/purchases.py
@@ -27,7 +27,6 @@
from django.db import models
from django.conf import settings
from django.utils import timezone
-from django.contrib.sites.models import Site
from django.utils.translation import ugettext_lazy as _
from django.dispatch import receiver
@@ -49,11 +48,6 @@ class PurchaseOrder(models.Model):
Creating a PO from an SO only creates the PO, it does not submit it.
"""
- site = models.ForeignKey(
- Site,
- editable=False,
- default=defaults.site_id
- )
location = models.ForeignKey(
Location,
editable=False,
diff --git a/servo/models/queue.py b/servo/models/queue.py
index d3eb0f6..25716d8 100644
--- a/servo/models/queue.py
+++ b/servo/models/queue.py
@@ -29,17 +29,15 @@ from django.conf import settings
from django.db import models
from django.utils import timezone
+from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from django.contrib.sites.models import Site
-from django.contrib.sites.managers import CurrentSiteManager
-from django.core.urlresolvers import reverse
from servo import defaults
from servo.models.common import Location
class Queue(models.Model):
-
site = models.ForeignKey(
Site,
editable=False,
@@ -48,6 +46,7 @@ class Queue(models.Model):
title = models.CharField(
max_length=255,
+ unique=True,
default=_('New Queue'),
verbose_name=_('Title')
)
@@ -181,8 +180,6 @@ class Queue(models.Model):
help_text=_("HTML template for dispatched order")
)
- objects = CurrentSiteManager()
-
def get_admin_url(self):
return reverse('admin-edit_queue', args=[self.pk])
@@ -208,12 +205,12 @@ class Status(models.Model):
default=defaults.site_id
)
- FACTORS = (
- (60, _('Minutes')),
- (3600, _('Hours')),
- (86400, _('Days')),
- (604800, _('Weeks')),
- (2419200, _('Months')),
+ FACTOR_CHOICES = (
+ (60, _('Minutes')),
+ (3600, _('Hours')),
+ (86400, _('Days')),
+ (604800, _('Weeks')),
+ (2419200, _('Months')),
)
title = models.CharField(
@@ -235,8 +232,8 @@ class Status(models.Model):
verbose_name=_(u'yellow limit')
)
limit_factor = models.IntegerField(
- choices=FACTORS,
- default=FACTORS[0],
+ choices=FACTOR_CHOICES,
+ default=FACTOR_CHOICES[0],
verbose_name=_(u'time unit')
)
queue = models.ManyToManyField(
@@ -273,9 +270,9 @@ class QueueStatus(models.Model):
limit_green = models.IntegerField(default=1, verbose_name=_(u'green limit'))
limit_yellow = models.IntegerField(default=15, verbose_name=_(u'yellow limit'))
limit_factor = models.IntegerField(
- choices=Status().FACTORS,
+ choices=Status.FACTOR_CHOICES,
verbose_name=_(u'time unit'),
- default=Status().FACTORS[0][0]
+ default=Status.FACTOR_CHOICES[0][0]
)
def get_green_limit(self):