loadUniversityEx.py 5.47 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
10
from backend_app.models.language import Language
Florent Chehab's avatar
Florent Chehab committed
11
from backend_app.models.tag import Tag
12 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
from backend_app.models.universityTaggedItem import UniversityTaggedItem
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 32
        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
33
        SWITZERLAND = Country.objects.get(pk="CH")
Florent Chehab's avatar
Florent Chehab committed
34 35

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

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

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

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

        univ_tag_1 = UniversityTaggedItem(
            university=EPFL,
            tag=ACCOMMODATION_TAG,
            title="C'est compliqué de trouver un logement",
            comment="Mon commentaire.",
78
            importance_level="++",
Florent Chehab's avatar
Florent Chehab committed
79
        )
80
        self.add_info_and_save(univ_tag_1, self.admin)
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162

        exchange1 = Exchange.objects.create(
            utc_univ_id=EPFL,
            utc_departure_id=1,
            user=self.admin,
            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,
        )

        ExchangeFeedback.objects.create(
            university=EPFL,
            exchange=exchange1,
            general_comment="Very good",
            academical_level_appreciation=5,
            foreign_student_welcome=5,
            cultural_interest=5,
        )

        exchange2 = Exchange.objects.create(
            utc_univ_id=EPFL,
            utc_departure_id=2,
            user=self.admin,
            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,
        )

        ExchangeFeedback.objects.create(
            university=EPFL,
            exchange=exchange2,
            general_comment="Very good trop bien",
            academical_level_appreciation=4,
            foreign_student_welcome=3,
            cultural_interest=4,
        )

        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="",
            student_login="chehabfl",
        )

        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="",
            student_login="chehabfl",
        )

        CourseFeedback.objects.update_or_create(
            course=course1,
            defaults=dict(
163
                language=Language.objects.first(),
164 165 166 167 168 169
                comment="Trop bien",
                adequation=5,
                working_dose=4,
                language_following_ease=3,
            ),
        )