loadUniversityEx.py 2.54 KB
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1 2 3 4 5
from .loadGeneric import LoadGeneric
from backend.models.university import University
from backend.models.university import UniversityDri
from backend.models.university import UniversityInfo
from backend.models.university import UniversitySemestersDates
Florent Chehab's avatar
Florent Chehab committed
6 7
from backend.models.country import CountryScholarship
from backend.models.country import Country
Florent Chehab's avatar
Florent Chehab committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
from backend.models.university import UniversityTaggedItem

from backend.models.currency import Currency
from backend.models.tag import Tag

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)