admin.py 2.6 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 20
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
21
from backend_app.models.recommendationList import RecommendationList
22 23 24 25 26
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
27
from backend_app.models.taggedItems import UniversityTaggedItem, CountryTaggedItem
28 29
from backend_app.models.userData import UserData
from backend_app.models.version import Version
30
from base_app.models import SiteInformation
31 32

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

#######
# Register the models
Florent Chehab's avatar
Florent Chehab committed
69
#######
70

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

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