convert to print_function, and start adding unicode_literals future as well
[htsworkflow.git] / inventory / models.py
index 908adede7e2bc0a2ee2bf27b1a99c3721f84958f..1e8509600336bb38a8797fbf097e431b48f13ffc 100644 (file)
@@ -3,7 +3,7 @@ from __future__ import absolute_import, print_function
 import logging
 
 from django.db import models
-from django.db.models.signals import pre_save
+from django.db.models.signals import pre_save, post_init
 
 from samples.models import Library
 from experiments.models import FlowCell
@@ -13,7 +13,7 @@ LOGGER = logging.getLogger(__name__)
 
 try:
     import uuid
-except ImportError, e:
+except ImportError as e:
     # Some systems are using python 2.4, which doesn't have uuid
     # this is a stub
     LOGGER.warning('Real uuid is not available, initializing fake uuid module')
@@ -28,7 +28,6 @@ def _assign_uuid(sender, instance, **kwargs):
     """
     Assigns a UUID to model on save
     """
-    #print 'Entered _assign_uuid'
     if instance.uuid is None or len(instance.uuid) != 32:
         instance.uuid = uuid.uuid1().hex
 
@@ -71,7 +70,7 @@ class Location(models.Model):
         else:
             return u"%s: %s" % (self.name, self.location_description)
 
-pre_save.connect(_assign_uuid, sender=Location)
+post_init.connect(_assign_uuid, sender=Location)
 
 
 class ItemInfo(models.Model):
@@ -159,7 +158,7 @@ class Item(models.Model):
     def get_absolute_url(self):
         return '/inventory/%s/' % (self.uuid)
 
-pre_save.connect(_assign_uuid, sender=Item)
+post_init.connect(_assign_uuid, sender=Item)
 
 
 class PrinterTemplate(models.Model):