2015-05-04 14:19:58 +00:00
|
|
|
from django import db
|
2014-07-08 16:37:38 +00:00
|
|
|
from django.apps import AppConfig
|
|
|
|
|
2015-05-07 14:09:37 +00:00
|
|
|
from orchestra.core import administration
|
2015-05-06 19:30:13 +00:00
|
|
|
from orchestra.utils.db import database_ready
|
2014-07-09 16:17:43 +00:00
|
|
|
|
2014-07-08 16:37:38 +00:00
|
|
|
|
|
|
|
class ResourcesConfig(AppConfig):
|
2015-04-05 10:46:24 +00:00
|
|
|
name = 'orchestra.contrib.resources'
|
2014-07-08 16:37:38 +00:00
|
|
|
verbose_name = 'Resources'
|
|
|
|
|
|
|
|
def ready(self):
|
2014-10-04 14:19:29 +00:00
|
|
|
if database_ready():
|
2014-07-10 10:03:22 +00:00
|
|
|
from .models import create_resource_relation
|
2015-05-04 14:19:58 +00:00
|
|
|
try:
|
|
|
|
create_resource_relation()
|
|
|
|
except db.utils.OperationalError:
|
|
|
|
# Not ready afterall
|
|
|
|
pass
|
2015-05-07 14:09:37 +00:00
|
|
|
from .models import Resource, ResourceData, MonitorData
|
|
|
|
administration.register(Resource, icon='gauge.png')
|
|
|
|
administration.register(ResourceData, parent=Resource, icon='monitor.png')
|
|
|
|
administration.register(MonitorData, parent=Resource, dashboard=False)
|
2014-10-06 14:57:02 +00:00
|
|
|
|
|
|
|
def reload_relations(self):
|
|
|
|
from .admin import insert_resource_inlines
|
|
|
|
from .models import create_resource_relation
|
|
|
|
from .serializers import insert_resource_serializers
|
|
|
|
insert_resource_inlines()
|
|
|
|
insert_resource_serializers()
|
2014-10-07 13:08:59 +00:00
|
|
|
create_resource_relation()
|