loadUniversityEx.py 5.73 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.partner import Partner
12
from backend_app.models.taggedItems import UniversityTaggedItem
13 14 15 16
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
17
from base_app.models import User
Florent Chehab's avatar
Florent Chehab committed
18
from .loadGeneric import LoadGeneric
Florent Chehab's avatar
Florent Chehab committed
19 20 21


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

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

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

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

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

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

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

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

77
        EPFL_as_partner = Partner.objects.filter(university__pk=EPFL.pk)[0]
78
        exchange1 = Exchange.objects.create(
79 80 81
            partner=EPFL_as_partner,
            utc_id=1,
            utc_partner_id=EPFL_as_partner.pk,
82
            student=self.admin,
83 84 85
            year=2019,
            semester="a",
            duration=1,
86
            double_degree=False,
87 88 89 90
            master_obtained=False,
            student_major="GI",
            student_minor="FDD",
            student_option="No",
91 92
            utc_allow_courses=True,
            utc_allow_login=True,
93 94
        )

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

        exchange2 = Exchange.objects.create(
106 107
            utc_partner_id=EPFL_as_partner.pk,
            utc_id=2,
108
            student=self.admin,
109 110 111
            year=2018,
            semester="a",
            duration=1,
112
            double_degree=False,
113 114 115 116 117
            master_obtained=False,
            student_major="GI",
            student_minor="FDD",
            student_option="No",
            utc_allow_courses=False,
118
            utc_allow_login=False,
119 120
        )

121
        ef = ExchangeFeedback.objects.create(
122 123 124 125 126 127 128
            university=EPFL,
            exchange=exchange2,
            general_comment="Very good trop bien",
            academical_level_appreciation=4,
            foreign_student_welcome=3,
            cultural_interest=4,
        )
129
        self.add_info_and_save(ef, self.admin)
130

131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
        course1 = Course.objects.update_or_create(
            utc_id=1,
            defaults=dict(
                exchange=exchange1,
                utc_exchange_id=1,
                code="COM-401",
                title="Applied data science",
                link="",
                ects=5,
                category="TM",
                profile="PSF",
                tsh_profile="",
                student_login="admin",
            ),
        )[0]
146

147 148 149 150 151 152 153 154 155 156 157 158 159 160
        Course.objects.update_or_create(
            utc_id=2,
            defaults=dict(
                exchange=exchange1,
                utc_exchange_id=1,
                code="COM-480",
                title="Data vizualization",
                link="",
                ects=5,
                category="TM",
                profile="PSF",
                tsh_profile="",
                student_login="admin",
            ),
161 162
        )

163
        cf = CourseFeedback.objects.update_or_create(
164 165
            course=course1,
            defaults=dict(
Segolene Brisemeur's avatar
Segolene Brisemeur committed
166
                language=Language.objects.first(),
167 168 169
                comment="Trop bien",
                adequation=5,
                working_dose=4,
170
                following_ease=3,
171
            ),
172 173
        )[0]
        self.add_info_and_save(cf, self.admin)