loadUniversityEx.py 2.27 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)
Florent Chehab's avatar
Florent Chehab committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
        univ_dri_1.save()
        self.add_info(univ_dri_1, self.admin)

        univ_info = UniversityInfo(
            university=EPFL,
            cost_exchange=0,
            costs_currency=CHF
        )
        univ_info.save()
        self.add_info(univ_info, self.admin)

        univ_semesters_dates = UniversitySemestersDates(
            university=EPFL,
            autumn_begin=datetime.strptime("17/09/2018", '%d/%m/%Y'),
            autumn_end=datetime.strptime("29/01/2019", '%d/%m/%Y')
        )
        univ_semesters_dates.save()
        self.add_info(univ_semesters_dates, self.admin)

        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()
57
        univ_scholarship_1.universities.add(EPFL)
Florent Chehab's avatar
Florent Chehab committed
58
59
60
61
62
63
64
65
66
67
68
69
        univ_scholarship_1.save()
        self.add_info(univ_scholarship_1, self.admin)

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