loadUniversityEx.py 2.75 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

5
6
from backend_app.models.country import Country
from backend_app.models.countryScholarship import CountryScholarship
Florent Chehab's avatar
Florent Chehab committed
7
8
from backend_app.models.currency import Currency
from backend_app.models.tag import Tag
9
10
11
12
13
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.universitySemestersDates import UniversitySemestersDates
from backend_app.models.universityTaggedItem import UniversityTaggedItem
Florent Chehab's avatar
Florent Chehab committed
14

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


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

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

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

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

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

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

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

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