loadUniversityEx.py 2.52 KB
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
2
from datetime import datetime

3
from base_app.models import User
Florent Chehab's avatar
Florent Chehab committed
4

Florent Chehab's avatar
Florent Chehab committed
5
from backend_app.models.country import Country, CountryScholarship
Florent Chehab's avatar
Florent Chehab committed
6
7
from backend_app.models.currency import Currency
from backend_app.models.tag import Tag
Florent Chehab's avatar
Florent Chehab committed
8
9
10
11
12
13
14
from backend_app.models.university import (
    University,
    UniversityDri,
    UniversityInfo,
    UniversitySemestersDates,
    UniversityTaggedItem,
)
Florent Chehab's avatar
Florent Chehab committed
15

Florent Chehab's avatar
Florent Chehab committed
16
from .loadGeneric import LoadGeneric
Florent Chehab's avatar
Florent Chehab committed
17
18
19


class LoadUniversityEx(LoadGeneric):
Florent Chehab's avatar
Florent Chehab committed
20
21
22
23
24
    """
    Load some exemple data for the EPFL
    """

    def __init__(self, admin: User):
Florent Chehab's avatar
Florent Chehab committed
25
26
27
        self.admin = admin

    def load(self):
28
29
30
        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
31
        SWITZERLAND = Country.objects.get(pk="CH")
Florent Chehab's avatar
Florent Chehab committed
32
33

        univ_dri_1 = UniversityDri(
Florent Chehab's avatar
Florent Chehab committed
34
            title="Cours en anglais",
35
            importance_level="+",
Florent Chehab's avatar
Florent Chehab committed
36
37
            comment="Les cours de master en computer science sont 100% en anglais",
        )
Florent Chehab's avatar
Florent Chehab committed
38
        univ_dri_1.save()
39
        univ_dri_1.universities.add(EPFL)
40
        self.add_info_and_save(univ_dri_1, self.admin)
Florent Chehab's avatar
Florent Chehab committed
41

42
43
44
45
        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
46

47
48
49
        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
50
        usd.useful_links = [
51
52
53
54
            {
                "url": "https://memento.epfl.ch/academic-calendar",
                "description": "Site de l'EPFL",
            }
Florent Chehab's avatar
Florent Chehab committed
55
        ]
56
        self.add_info_and_save(usd, self.admin)
Florent Chehab's avatar
Florent Chehab committed
57

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

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