aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--servo/migrations/0039_auto_20151016_1307.py69
-rw-r--r--servo/models/order.py53
2 files changed, 94 insertions, 28 deletions
diff --git a/servo/migrations/0039_auto_20151016_1307.py b/servo/migrations/0039_auto_20151016_1307.py
new file mode 100644
index 0000000..617eaaf
--- /dev/null
+++ b/servo/migrations/0039_auto_20151016_1307.py
@@ -0,0 +1,69 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('servo', '0038_auto_20151013_2302'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='device',
+ name='configuration',
+ field=models.CharField(default=b'', max_length=256, verbose_name='Configuration', blank=True),
+ ),
+ migrations.AlterField(
+ model_name='device',
+ name='description',
+ field=models.CharField(default='New Device', max_length=128, verbose_name='Description'),
+ ),
+ migrations.AlterField(
+ model_name='device',
+ name='is_vintage',
+ field=models.BooleanField(default=False, help_text='Device is considered vintage in GSX', verbose_name='Vintage'),
+ ),
+ migrations.AlterField(
+ model_name='device',
+ name='password',
+ field=models.CharField(default=b'', max_length=32, verbose_name='Password', blank=True),
+ ),
+ migrations.AlterField(
+ model_name='device',
+ name='photo',
+ field=models.ImageField(upload_to=b'devices', null=True, verbose_name='Photo', blank=True),
+ ),
+ migrations.AlterField(
+ model_name='device',
+ name='username',
+ field=models.CharField(default=b'', max_length=32, verbose_name='Username', blank=True),
+ ),
+ migrations.AlterField(
+ model_name='location',
+ name='address',
+ field=models.CharField(default=b'', max_length=32, verbose_name='Address', blank=True),
+ ),
+ migrations.AlterField(
+ model_name='location',
+ name='city',
+ field=models.CharField(default=b'', max_length=16, verbose_name='City', blank=True),
+ ),
+ migrations.AlterField(
+ model_name='location',
+ name='email',
+ field=models.EmailField(default=b'', max_length=254, verbose_name='Email', blank=True),
+ ),
+ migrations.AlterField(
+ model_name='location',
+ name='phone',
+ field=models.CharField(default=b'', max_length=32, verbose_name='Phone', blank=True),
+ ),
+ migrations.AlterField(
+ model_name='location',
+ name='title',
+ field=models.CharField(default='New Location', max_length=255, verbose_name='Name'),
+ ),
+ ]
diff --git a/servo/models/order.py b/servo/models/order.py
index b389053..ba4fed5 100644
--- a/servo/models/order.py
+++ b/servo/models/order.py
@@ -772,6 +772,31 @@ class Order(models.Model):
("batch_process", _("Can batch process")),
)
+ def save(self, *args, **kwargs):
+
+ location = self.created_by.location
+
+ if self.location_id is None:
+ self.location = location
+
+ if self.checkin_location is None:
+ self.checkin_location = location
+
+ if self.checkout_location is None:
+ self.checkout_location = location
+
+ if self.customer and self.customer_name == '':
+ self.customer_name = self.customer.fullname
+
+ super(Order, self).save(*args, **kwargs)
+
+ if self.code is None:
+ self.url_code = encode_url(self.id).upper()
+ self.code = settings.INSTALL_ID + str(self.id).rjust(6, '0')
+ event = _('Order %s created') % self.code
+ self.notify('created', event, self.created_by)
+ self.save()
+
def get_absolute_url(self):
return reverse("orders-edit", args=[self.pk])
@@ -1101,34 +1126,6 @@ class Accessory(models.Model):
app_label = "servo"
-@receiver(pre_save, sender=Order)
-def trigger_order_presave(sender, instance, **kwargs):
- instance.customer_name = ''
- if instance.customer is not None:
- instance.customer_name = instance.customer.fullname
-
- location = instance.created_by.location
-
- if instance.checkin_location is None:
- instance.checkin_location = location
-
- if instance.location_id is None:
- instance.location = location
-
- if instance.checkout_location is None:
- instance.checkout_location = location
-
-
-@receiver(post_save, sender=Order)
-def trigger_order_created(sender, instance, created, **kwargs):
- if created:
- instance.url_code = encode_url(instance.id).upper()
- instance.code = settings.INSTALL_ID + str(instance.id).rjust(6, '0')
- description = _('Order %s created') % instance.code
- instance.notify('created', description, instance.created_by)
- instance.save()
-
-
@receiver(post_save, sender=OrderDevice)
def trigger_orderdevice_saved(sender, instance, created, **kwargs):
order = instance.order