loadUniversityEx.py 5.39 KB
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
2
from datetime import datetime

3
4
from backend_app.models.country import Country
from backend_app.models.countryScholarship import CountryScholarship
5
6
from backend_app.models.course import Course
from backend_app.models.courseFeedback import CourseFeedback
Florent Chehab's avatar
Florent Chehab committed
7
from backend_app.models.currency import Currency
8
9
from backend_app.models.exchange import Exchange
from backend_app.models.exchangeFeedback import ExchangeFeedback
Segolene Brisemeur's avatar
Segolene Brisemeur committed
10
from backend_app.models.language import Language
11
from backend_app.models.taggedItems import UniversityTaggedItem
12
13
14
15
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
16
from base_app.models import User
Florent Chehab's avatar
Florent Chehab committed
17
from .loadGeneric import LoadGeneric
Florent Chehab's avatar
Florent Chehab committed
18
19
20


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

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

    def load(self):
29
30
        EPFL = University.objects.get(acronym="EPFL")
        CHF = Currency.objects.get(pk="CHF")
Florent Chehab's avatar
Florent Chehab committed
31
        SWITZERLAND = Country.objects.get(pk="CH")
Florent Chehab's avatar
Florent Chehab committed
32
33

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

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

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

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

        univ_tag_1 = UniversityTaggedItem(
72
            university=EPFL, comment="C'est compliqué de trouver un logement"
Florent Chehab's avatar
Florent Chehab committed
73
        )
74
        self.add_info_and_save(univ_tag_1, self.admin)
75
76

        exchange1 = Exchange.objects.create(
77
            university=EPFL,
78
            utc_departure_id=1,
79
            student=self.admin,
80
81
82
83
84
85
86
87
88
89
90
91
            year=2019,
            semester="a",
            duration=1,
            dual_degree=False,
            master_obtained=False,
            student_major="GI",
            student_minor="FDD",
            student_option="No",
            utc_allow_courses=False,
            utc_allow_login=False,
        )

92
        ef = ExchangeFeedback.objects.create(
93
94
95
96
97
98
99
            university=EPFL,
            exchange=exchange1,
            general_comment="Very good",
            academical_level_appreciation=5,
            foreign_student_welcome=5,
            cultural_interest=5,
        )
100
        self.add_info_and_save(ef, self.admin)
101
102

        exchange2 = Exchange.objects.create(
103
            university=EPFL,
104
            utc_departure_id=2,
105
            student=self.admin,
106
107
108
109
110
111
112
113
114
115
116
117
            year=2018,
            semester="a",
            duration=1,
            dual_degree=False,
            master_obtained=False,
            student_major="GI",
            student_minor="FDD",
            student_option="No",
            utc_allow_courses=False,
            utc_allow_login=True,
        )

118
        ef = ExchangeFeedback.objects.create(
119
120
121
122
123
124
125
            university=EPFL,
            exchange=exchange2,
            general_comment="Very good trop bien",
            academical_level_appreciation=4,
            foreign_student_welcome=3,
            cultural_interest=4,
        )
126
        self.add_info_and_save(ef, self.admin)
127
128
129
130
131
132
133
134
135
136
137
138

        course1 = Course.objects.create(
            exchange=exchange1,
            utc_exchange_id=1,
            course_id=1,
            code="COM-401",
            title="Applied data science",
            link="",
            nb_credit=5,
            category="TM",
            profile="PSF",
            tsh_profile="",
139
            student_login="admin",
140
141
142
143
144
145
146
147
148
149
150
151
152
        )

        Course.objects.create(
            exchange=exchange1,
            utc_exchange_id=1,
            course_id=2,
            code="COM-480",
            title="Data vizualization",
            link="",
            nb_credit=5,
            category="TM",
            profile="PSF",
            tsh_profile="",
153
            student_login="admin",
154
155
        )

156
        cf = CourseFeedback.objects.update_or_create(
157
158
            course=course1,
            defaults=dict(
Segolene Brisemeur's avatar
Segolene Brisemeur committed
159
                language=Language.objects.first(),
160
161
162
                comment="Trop bien",
                adequation=5,
                working_dose=4,
163
                following_ease=3,
164
            ),
165
166
        )[0]
        self.add_info_and_save(cf, self.admin)