admin.py 2.78 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
from backend_app.models.exchange import Exchange, UnivMajorMinors
16
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.sharedUnivFeedback import SharedUnivFeedback
24
from backend_app.models.taggedItems import UniversityTaggedItem, CountryTaggedItem
25
26
27
28
29
30
31
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
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
    Currency,
    Offer,
    PendingModeration,
47
48
    Exchange,
    ExchangeFeedback,
49
    UnivMajorMinors,
50
    RecommendationList,
51
    Partner,
52
    University,
53
    SharedUnivFeedback,
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
    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)
71
72
73

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

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

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