Commit 407d37e3 authored by Florent Chehab's avatar Florent Chehab

Fix(sharedFeedback): request in front & quick prod loading script

parent f4549210
Pipeline #42774 passed with stages
in 4 minutes and 40 seconds
id_etab,ville,code_iso,name,acronym,logo,website,lat,lon
52,Göteborg,SE,Chalmers University of Technology,,https://cloud.floflo.ch/index.php/s/beLpNajWs9WmPmr/download,https://www.chalmers.se/en,57.6897091,11.9719714
59,Gent,BE,Universiteit Gent,UGent,https://upload.wikimedia.org/wikipedia/fr/5/5c/Universit%C3%A9_de_Gand_%28logo%29.svg,https://www.ugent.be/en,51.0450413,3.7255573
74,Hamilton,CA,McMaster University,,https://upload.wikimedia.org/wikipedia/en/5/53/McMaster_University_logo.svg,https://www.mcmaster.ca/,43.2608829,-79.9214194
89,Urbana,US,University of Illinois Urbana-Champaign,,https://upload.wikimedia.org/wikipedia/commons/9/9c/University_of_Illinois_at_Urbana%E2%80%93Champaign_logo.svg,https://illinois.edu/,40.1019564,-88.2293555
92,Sherbrooke,CA,Université de Sherbrooke,,https://upload.wikimedia.org/wikipedia/fr/6/63/Universit%C3%A9_de_Sherbrooke_%28logo%29.svg,https://www.usherbrooke.ca/,45.3796391,-71.9325824
94,Kingston,US,University of Rhode Island,URI,https://upload.wikimedia.org/wikipedia/en/e/e0/University_of_Rhode_Island_seal.svg,https://www.uri.edu/,41.8227726,-71.4157738
102,Milan,IT,Politecnico di Milano,,https://cloud.floflo.ch/index.php/s/bjBMcJwfjs6TAm5/download,https://www.polimi.it/en/,45.4782722,9.2263196
112,Luleå,SE,Luleå University of Technology,,https://upload.wikimedia.org/wikipedia/commons/d/d3/LTU_logo.svg,https://www.ltu.se/?l=en,65.6170445,22.13706063
203,Lausanne,CH,École Polytechnique Fédérale de Lausanne,,https://upload.wikimedia.org/wikipedia/commons/f/f4/Logo_EPFL.svg,https://www.epfl.ch/fr/,46.5186594,6.566561505
171,Singapore,SG,National University of Singapore,NUS,https://upload.wikimedia.org/wikipedia/en/9/9b/NationalUniversityofSingapore.svg,http://nus.edu.sg/,1.3186413,103.8144945
195,Victoria,AU,Swinburne University of Technology,Swinburne,https://cloud.floflo.ch/index.php/s/YjmirFoT3TB8R9j/download,https://www.swinburne.edu.au/,-37.85240845,144.9918226
301,Shanghaï,CN,Université de technologie sino-européenne de l'université de Shanghai,Utseus,https://upload.wikimedia.org/wikipedia/fr/1/11/Utseus_logo.png,utseus.com/fr/,31.3888642,121.2722844
\ No newline at end of file
......@@ -12,6 +12,9 @@ from backend_app.load_data.loading_scripts.loadSiteInformation import (
LoadSiteInformation,
)
from backend_app.load_data.loading_scripts.loadUniversities import LoadUniversities
from backend_app.load_data.loading_scripts.loadUniversitiesProd import (
LoadUniversitiesProd,
)
from backend_app.load_data.loading_scripts.loadUniversityEx import LoadUniversityEx
......@@ -45,6 +48,6 @@ def load_prod():
LoadCountries(admin).load()
LoadLanguages().load()
LoadSiteInformation(admin).load()
# LoadUniversities(admin).load()
LoadUniversitiesProd(admin).load()
# LoadUniversityEx(admin).load()
# LoadRecommendationLists(admin).load()
from os.path import abspath, join
from backend_app.load_data.utils import ASSETS_PATH, csv_2_dict_list
from backend_app.models.campus import Campus
from backend_app.models.city import City
from backend_app.models.country import Country
from backend_app.models.partner import Partner
from backend_app.models.university import University
from base_app.models import User
from .loadGeneric import LoadGeneric
class LoadUniversitiesProd(LoadGeneric):
"""
Load the universities in the app
"""
def __init__(self, admin: User):
self.admin = admin
@staticmethod
def get_destination_data():
destinations_path = abspath(join(ASSETS_PATH, "beta-univs.csv"))
return csv_2_dict_list(destinations_path)
def load(self):
for row in self.get_destination_data():
lat = round(float(row["lat"]), 6)
lon = round(float(row["lon"]), 6)
country = Country.objects.get(pk=row["code_iso"])
city = City.objects.update_or_create(name=row["ville"], country=country)[0]
self.add_info_and_save(city, self.admin)
partner_id = row["id_etab"]
univ = University.objects.update_or_create(
pk=partner_id, # Not perfect but should do the trick
defaults={
"name": row["name"],
"acronym": row["acronym"],
"website": row["website"],
# "logo": row["logo"], # WARNING FIX BETA not ok
},
)[0]
self.add_info_and_save(univ, self.admin)
main_campus = Campus.objects.update_or_create(
is_main_campus=True,
university=univ,
defaults=dict(
name="Campus - " + univ.name, city=city, lat=lat, lon=lon
),
)[0]
self.add_info_and_save(main_campus, self.admin)
partner = Partner.objects.get(utc_id=partner_id)
partner.university = univ
partner.save()
def run():
admin = User.objects.get(username="admin")
LoadUniversitiesProd(admin).load()
......@@ -42,11 +42,11 @@ function renderCore(rawModelData, classes) {
class SharedUnivFeedback extends Module {
apiParams = {
univSharedFeedback: ({props}) => RequestParams.Builder.withId(props.univId).build(),
univSharedFeedback: ({props}) => RequestParams.Builder.withQueryParam("university", props.univId).build(),
};
customRender() {
const univSharedFeedback = this.getLatestReadData("univSharedFeedback");
const univSharedFeedback = this.getLatestReadData("univSharedFeedback")[0];
const {classes} = this.props;
return (
<ModuleWrapper
......@@ -69,14 +69,14 @@ SharedUnivFeedback.propTypes = {
const mapStateToProps = (state) => {
return {
univSharedFeedback: state.api.sharedUnivFeedbacksOne,
univSharedFeedback: state.api.sharedUnivFeedbacksAll,
};
};
const mapDispatchToProps = (dispatch) => {
return {
api: {
univSharedFeedback: (params) => dispatch(getActions("sharedUnivFeedbacks").readOne(params)),
univSharedFeedback: (params) => dispatch(getActions("sharedUnivFeedbacks").readAll(params)),
},
invalidateData: () => dispatch(getActions("sharedUnivFeedbacks").invalidateOne())
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment