loadUniversityEx.py 2.58 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
21
22
23
24

from datetime import datetime


class LoadUniversityEx(LoadGeneric):

    def __init__(self, admin):
        self.admin = admin

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

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

36
37
38
39
        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
40

41
42
43
44
        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
45
46
47
48
        usd.useful_links = [
            {"url": "https://memento.epfl.ch/academic-calendar",
                "description": "Site de l'EPFL"}
        ]
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
55
56
57
            currency=CHF,
            frequency='s',
            amount_min=2200,
            amount_max=2200,
Florent Chehab's avatar
Florent Chehab committed
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
69
70

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