django-orchestra/orchestra/apps/resources/apps.py

16 lines
542 B
Python
Raw Normal View History

2014-07-08 16:37:38 +00:00
from django.apps import AppConfig
from django.contrib.contenttypes import generic
class ResourcesConfig(AppConfig):
name = 'orchestra.apps.resources'
verbose_name = 'Resources'
def ready(self):
from .models import Resource
# TODO execute on Resource.save()
relation = generic.GenericRelation('resources.ResourceAllocation')
for resources in Resource.group_by_content_type():
model = resources[0].content_type.model_class()
model.add_to_class('allocations', relation)