Skip to content
Snippets Groups Projects
Verified Commit 61b860f8 authored by Jonathan Weth's avatar Jonathan Weth :keyboard: Committed by Nik | Klampfradler
Browse files

Use Django apps registry to detect if Chronos is installed

parent e6d3056f
No related branches found
No related tags found
No related merge requests found
from typing import Callable, Optional, Sequence, Tuple, Type from typing import Callable, Optional, Sequence, Tuple, Type
from uuid import uuid4 from uuid import uuid4
from django.apps import apps
from django.db.models import Model from django.db.models import Model
from django.utils.functional import classproperty from django.utils.functional import classproperty
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
...@@ -282,12 +283,9 @@ class DepartmentsFieldType(ProcessFieldType): ...@@ -282,12 +283,9 @@ class DepartmentsFieldType(ProcessFieldType):
converter = parse_comma_separated_data converter = parse_comma_separated_data
def process(self, instance: Model, value): def process(self, instance: Model, value):
try: with_chronos = apps.is_installed("aleksis.apps.chronos")
from aleksis.apps.chronos.models import Subject # noqa if with_chronos:
Subject = apps.get_model("chronos", "Subject")
with_chronos = True
except ModuleNotFoundError:
with_chronos = False
group_type = get_site_preferences()["csv_import__group_type_departments"] group_type = get_site_preferences()["csv_import__group_type_departments"]
group_prefix = get_site_preferences()["csv_import__group_prefix_departments"] group_prefix = get_site_preferences()["csv_import__group_prefix_departments"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment