admin.py 783 Bytes
Newer Older
1 2
from django.contrib import admin

3
from reversion_compare.admin import CompareVersionAdmin
4 5
from backend_app.config.models import get_models
from backend_app.checks import check_classic_models, check_versionned_models
6

7 8
VERSIONNED_MODELS = get_models(versionned=True, requires_testing=False)
CLASSIC_MODELS = get_models(versionned=False, requires_testing=False)
9

Florent Chehab's avatar
Florent Chehab committed
10
#######
11 12 13 14 15 16 17 18
# Perform some dynamic checks
#######

check_classic_models(CLASSIC_MODELS)
check_versionned_models(VERSIONNED_MODELS)

#######
# Register the models
Florent Chehab's avatar
Florent Chehab committed
19
#######
20

Florent Chehab's avatar
Florent Chehab committed
21 22 23
for Model in CLASSIC_MODELS:
    # Register the model in the admin in a standard way
    admin.site.register(Model)
24

25

Florent Chehab's avatar
Florent Chehab committed
26 27 28
for Model in VERSIONNED_MODELS:
    # Register the model in the admin with versioning
    admin.site.register(Model, CompareVersionAdmin)