def on_project_save(sender, instance, created, **kwargs): """ Make sure all required classes and relations are set up. """ if created and sender == Project: from control.project import validate_project_setup from catmaid import get_system_user user = get_system_user() validate_project_setup(instance.id, user.id)
def validate_projects(app, **kwargs): """Make sure all projects have the relations and classes available they expect.""" has_users = User.objects.all().exists() has_projects = Project.objects.exclude( pk=catmaid_settings.ONTOLOGY_DUMMY_PROJECT_ID).exists() if not (has_users and has_projects): # In case there is no user and only no project except thei ontology # dummy project, don't do the check. Otherwise, getting a system user # will fail. return user = get_system_user() for p in Project.objects.all(): project.validate_project_setup(p.id, user.id)