loadUniversityEx.py 2.6 KB
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from .loadGeneric import LoadGeneric
Florent Chehab's avatar
Florent Chehab committed
2 3 4 5 6 7 8
from backend_app.models.university import University
from backend_app.models.university import UniversityDri
from backend_app.models.university import UniversityInfo
from backend_app.models.university import UniversitySemestersDates
from backend_app.models.country import CountryScholarship
from backend_app.models.country import Country
from backend_app.models.university import UniversityTaggedItem
Florent Chehab's avatar
Florent Chehab committed
9

Florent Chehab's avatar
Florent Chehab committed
10 11
from backend_app.models.currency import Currency
from backend_app.models.tag import Tag
Florent Chehab's avatar
Florent Chehab committed
12 13 14 15 16 17 18 19 20

from datetime import datetime


class LoadUniversityEx(LoadGeneric):
    def __init__(self, admin):
        self.admin = admin

    def load(self):
21 22 23
        EPFL = University.objects.get(acronym="EPFL")
        CHF = Currency.objects.get(pk="CHF")
        ACCOMMODATION_TAG = Tag.objects.get(name="accommodation")
Florent Chehab's avatar
Florent Chehab committed
24
        SWITZERLAND = Country.objects.get(pk="CH")
Florent Chehab's avatar
Florent Chehab committed
25 26

        univ_dri_1 = UniversityDri(
Florent Chehab's avatar
Florent Chehab committed
27
            title="Cours en anglais",
28
            importance_level="+",
Florent Chehab's avatar
Florent Chehab committed
29 30
            comment="Les cours de master en computer science sont 100% en anglais",
        )
Florent Chehab's avatar
Florent Chehab committed
31
        univ_dri_1.save()
32
        univ_dri_1.universities.add(EPFL)
33
        self.add_info_and_save(univ_dri_1, self.admin)
Florent Chehab's avatar
Florent Chehab committed
34

35 36 37 38
        univ_info = UniversityInfo.objects.get(university=EPFL)
        univ_info.cost_exchange = 0
        univ_info.costs_currency = CHF
        self.add_info_and_save(univ_info, self.admin)
Florent Chehab's avatar
Florent Chehab committed
39

40 41 42
        usd = UniversitySemestersDates.objects.get(university=EPFL)
        usd.autumn_begin = datetime.strptime("17/09/2018", "%d/%m/%Y")
        usd.autumn_end = datetime.strptime("29/01/2019", "%d/%m/%Y")
Florent Chehab's avatar
Florent Chehab committed
43
        usd.useful_links = [
44 45 46 47
            {
                "url": "https://memento.epfl.ch/academic-calendar",
                "description": "Site de l'EPFL",
            }
Florent Chehab's avatar
Florent Chehab committed
48
        ]
49
        self.add_info_and_save(usd, self.admin)
Florent Chehab's avatar
Florent Chehab committed
50

Florent Chehab's avatar
Florent Chehab committed
51 52 53
        country_scholarship = CountryScholarship(
            title="Swiss European Mobility Programme",
            type="Bourse du gouvernement suisse",
Florent Chehab's avatar
Florent Chehab committed
54
            currency=CHF,
55
            frequency="s",
Florent Chehab's avatar
Florent Chehab committed
56 57
            amount_min=2200,
            amount_max=2200,
58
            comment="Bourse attribuée de manière automatique.",
Florent Chehab's avatar
Florent Chehab committed
59
        )
Florent Chehab's avatar
Florent Chehab committed
60 61 62
        country_scholarship.save()
        country_scholarship.countries.add(SWITZERLAND)
        self.add_info_and_save(country_scholarship, self.admin)
Florent Chehab's avatar
Florent Chehab committed
63 64 65 66 67 68

        univ_tag_1 = UniversityTaggedItem(
            university=EPFL,
            tag=ACCOMMODATION_TAG,
            title="C'est compliqué de trouver un logement",
            comment="Mon commentaire.",
69
            importance_level="++",
Florent Chehab's avatar
Florent Chehab committed
70
        )
71
        self.add_info_and_save(univ_tag_1, self.admin)