loadUniversityEx.py 5.38 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
Florent Chehab's avatar
Florent Chehab committed
10
from backend_app.models.tag import Tag
11 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
from backend_app.models.universityTaggedItem import UniversityTaggedItem
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 31
        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
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 73 74 75 76

        univ_tag_1 = UniversityTaggedItem(
            university=EPFL,
            tag=ACCOMMODATION_TAG,
            title="C'est compliqué de trouver un logement",
            comment="Mon commentaire.",
77
            importance_level="++",
Florent Chehab's avatar
Florent Chehab committed
78
        )
79
        self.add_info_and_save(univ_tag_1, self.admin)
80 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 163 164 165 166 167

        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(
                comment="Trop bien",
                adequation=5,
                working_dose=4,
                language_following_ease=3,
            ),
        )