admin.py 2.73 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
15
from backend_app.models.currency import Currency
from backend_app.models.department import Department
16
17
from backend_app.models.exchange import Exchange
from backend_app.models.exchangeFeedback import ExchangeFeedback
18
19
20
21
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
from backend_app.models.pendingModeration import PendingModeration
22
from backend_app.models.recommendationList import RecommendationList
23
24
25
26
27
28
from backend_app.models.specialty import Specialty
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
29
from backend_app.models.taggedItems import UniversityTaggedItem, CountryTaggedItem
30
31
from backend_app.models.userData import UserData
from backend_app.models.version import Version
32
from base_app.models import SiteInformation
33
34

ALL_MODELS = [
35
    SiteInformation,
36
37
38
39
40
41
    Campus,
    City,
    Country,
    CountryDri,
    CountryScholarship,
    CountryTaggedItem,
42
43
    Course,
    CourseFeedback,
44
45
46
47
    Currency,
    Department,
    Offer,
    PendingModeration,
48
49
    Exchange,
    ExchangeFeedback,
50
    RecommendationList,
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
    Specialty,
    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)
70
71
72

#######
# Register the models
Florent Chehab's avatar
Florent Chehab committed
73
#######
74

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

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