admin.py 2.66 KB
Newer Older
1
from django.contrib import admin
2
from reversion_compare.admin import CompareVersionAdmin
3

4
5
6
7
8
9
10
11
from backend_app.models.abstract.versionedEssentialModule import (
    VersionedEssentialModule,
)
from backend_app.models.campus import Campus
from backend_app.models.city import City
from backend_app.models.country import Country
from backend_app.models.countryDri import CountryDri
from backend_app.models.countryScholarship import CountryScholarship
12
13
from backend_app.models.course import Course
from backend_app.models.courseFeedback import CourseFeedback
14
from backend_app.models.currency import Currency
15
16
from backend_app.models.exchange import Exchange
from backend_app.models.exchangeFeedback import ExchangeFeedback
17
18
19
from backend_app.models.for_testing.moderation import ForTestingModeration
from backend_app.models.for_testing.versioning import ForTestingVersioning
from backend_app.models.offer import Offer
20
from backend_app.models.partner import Partner
21
from backend_app.models.pendingModeration import PendingModeration
22
from backend_app.models.recommendationList import RecommendationList
23
from backend_app.models.taggedItems import UniversityTaggedItem, CountryTaggedItem
24
25
26
27
28
29
30
from backend_app.models.university import University
from backend_app.models.universityDri import UniversityDri
from backend_app.models.universityInfo import UniversityInfo
from backend_app.models.universityScholarship import UniversityScholarship
from backend_app.models.universitySemestersDates import UniversitySemestersDates
from backend_app.models.userData import UserData
from backend_app.models.version import Version
31
from base_app.models import SiteInformation
32
33

ALL_MODELS = [
34
    SiteInformation,
35
36
37
38
39
40
    Campus,
    City,
    Country,
    CountryDri,
    CountryScholarship,
    CountryTaggedItem,
41
42
    Course,
    CourseFeedback,
43
44
45
    Currency,
    Offer,
    PendingModeration,
46
47
    Exchange,
    ExchangeFeedback,
48
    RecommendationList,
49
    Partner,
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
    University,
    UniversityDri,
    UniversityInfo,
    UniversityScholarship,
    UniversitySemestersDates,
    UniversityTaggedItem,
    UserData,
    Version,
]

# We also register testing to models to make sure migrations are created for them

ALL_MODELS += [ForTestingModeration, ForTestingVersioning]

CLASSIC_MODELS = filter(
    lambda m: not issubclass(m, VersionedEssentialModule), ALL_MODELS
)
VERSIONED_MODELS = filter(lambda m: issubclass(m, VersionedEssentialModule), ALL_MODELS)
68
69
70

#######
# Register the models
Florent Chehab's avatar
Florent Chehab committed
71
#######
72

Florent Chehab's avatar
Florent Chehab committed
73
74
75
for Model in CLASSIC_MODELS:
    # Register the model in the admin in a standard way
    admin.site.register(Model)
76

77
for Model in VERSIONED_MODELS:
Florent Chehab's avatar
Florent Chehab committed
78
79
    # Register the model in the admin with versioning
    admin.site.register(Model, CompareVersionAdmin)