admin.tpl 1.14 KB
Newer Older
1
2
3
{% autoescape off %}
# WARNING
# THIS FILE HAS BEEN AUTOMATICALLY GENERATED
Florent Chehab's avatar
Florent Chehab committed
4
# WITH /backend/generate/generate_backend_files.py
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# MODIFY THE FILE ABOVE IF YOUR NOT SATISFIED 
# THIS WARNING DOESN'T APPLY TO .tpl FILES...

from django.contrib import admin
from reversion_compare.admin import CompareVersionAdmin

{% spaceless %}
{% for model in data %}
from backend.models.{{model.import_location}} import {{model.model}}
{% endfor %}
{% endspaceless %}



CLASSIC_MODELS = [
{% for model in data %}{% if not model.versionned %}
    {{model.model}},
{% endif %}{% endfor %}
]

VERSIONNED_MODELS = [
{% for model in data %}{% if model.versionned %}
    {{model.model}},
{% endif %}{% endfor %}
]

for model in CLASSIC_MODELS:
    admin.site.register(model)
    try:
        model.get_serializer()
        raise Exception("CLASSIX MODEL SHOULDN'T have this method")
    except AttributeError:
        pass
        
for model in VERSIONNED_MODELS:
    admin.site.register(model, CompareVersionAdmin)
    if (model.get_serializer().Meta.model != model):
        raise Exception(
            "Get_serializer configuration incorrect in", str(model))

{% endautoescape %}