loadUniversityEx.py 2.14 KB
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
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
from backend.models.university import UniversityScholarship
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')

        univ_dri_1 = UniversityDri(
            comment="Attention les cours de master sont 100% en anglais")
        univ_dri_1.save()
28
        univ_dri_1.universities.add(EPFL)
29
        self.add_info_and_save(univ_dri_1, self.admin)
Florent Chehab's avatar
Florent Chehab committed
30

31 32 33 34
        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
35

36 37 38 39 40
        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')
        self.add_info_and_save(usd, self.admin)
Florent Chehab's avatar
Florent Chehab committed
41 42 43 44 45 46 47 48 49 50

        univ_scholarship_1 = UniversityScholarship(
            type="Swiss European...",
            currency=CHF,
            frequency='s',
            amount_min=2200,
            amount_max=2200,
            comment="Il n'y a rien à faire pour l'obtenir"
        )
        univ_scholarship_1.save()
51
        univ_scholarship_1.universities.add(EPFL)
52
        self.add_info_and_save(univ_scholarship_1, self.admin)
Florent Chehab's avatar
Florent Chehab committed
53 54 55 56 57 58 59 60

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