Move uuid setting from __init__ to model
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import uuid
|
||||
|
||||
from south.signals import post_migrate
|
||||
|
||||
from project_tools.api import register_tool
|
||||
@@ -16,10 +14,10 @@ from .models import Installation
|
||||
|
||||
@receiver(post_migrate, dispatch_uid='trigger_first_time')
|
||||
def trigger_first_time(sender, **kwargs):
|
||||
details = Installation.objects.get()
|
||||
details.is_first_run = True
|
||||
details.uuid = unicode(uuid.uuid4())
|
||||
details.save()
|
||||
if kwargs['app'] == 'installation':
|
||||
details = Installation.objects.get()
|
||||
details.is_first_run = True
|
||||
details.save()
|
||||
|
||||
|
||||
def check_first_run():
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
import platform
|
||||
import uuid
|
||||
|
||||
import pbs
|
||||
import psutil
|
||||
@@ -43,7 +44,7 @@ class Installation(Singleton):
|
||||
_properties = SortedDict()
|
||||
|
||||
is_first_run = models.BooleanField(default=False)
|
||||
uuid = models.CharField(max_length=48, blank=True)
|
||||
uuid = models.CharField(max_length=48, blank=True, default=lambda: unicode(uuid.uuid4()))
|
||||
|
||||
def add_property(self, property_instance):
|
||||
self._properties[property_instance.name] = property_instance
|
||||
|
||||
Reference in New Issue
Block a user