admin.py 3 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
12
13
14
from backend_app.models.abstract.versionedEssentialModule import (
    VersionedEssentialModule,
)
from backend_app.models.campus import Campus
from backend_app.models.campusTaggedItem import CampusTaggedItem
from backend_app.models.city import City
from backend_app.models.cityTaggedItem import CityTaggedItem
from backend_app.models.country import Country
from backend_app.models.countryDri import CountryDri
from backend_app.models.countryScholarship import CountryScholarship
from backend_app.models.countryTaggedItem import CountryTaggedItem
15
16
from backend_app.models.course import Course
from backend_app.models.courseFeedback import CourseFeedback
17
18
from backend_app.models.currency import Currency
from backend_app.models.department import Department
19
20
from backend_app.models.exchange import Exchange
from backend_app.models.exchangeFeedback import ExchangeFeedback
21
22
23
24
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
25
from backend_app.models.recommendationList import RecommendationList
26
27
28
29
30
31
32
33
34
35
from backend_app.models.specialty import Specialty
from backend_app.models.tag import Tag
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.universityTaggedItem import UniversityTaggedItem
from backend_app.models.userData import UserData
from backend_app.models.version import Version
36
from base_app.models import SiteInformation
37
38

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

#######
# Register the models
Florent Chehab's avatar
Florent Chehab committed
80
#######
81

Florent Chehab's avatar
Florent Chehab committed
82
83
84
for Model in CLASSIC_MODELS:
    # Register the model in the admin in a standard way
    admin.site.register(Model)
85

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