Refactor installation app to move code to model and display more information
This commit is contained in:
@@ -1,7 +1,38 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import uuid
|
||||
|
||||
from south.signals import post_migrate
|
||||
|
||||
from project_tools.api import register_tool
|
||||
|
||||
from django.dispatch import receiver
|
||||
from django.db.models.signals import post_save
|
||||
from django.db.utils import DatabaseError
|
||||
|
||||
from .links import installation_details
|
||||
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()
|
||||
|
||||
|
||||
def check_first_run():
|
||||
try:
|
||||
details = Installation.objects.get()
|
||||
except DatabaseError:
|
||||
pass
|
||||
else:
|
||||
if details.is_first_run:
|
||||
details.is_first_run = False
|
||||
#details.save()
|
||||
|
||||
|
||||
register_tool(installation_details)
|
||||
|
||||
check_first_run()
|
||||
|
||||
Reference in New Issue
Block a user