Commit 7cfe87b2 authored by Florent Chehab's avatar Florent Chehab
Browse files

Twaeks to make front work again

parent 0304b762
Pipeline #26540 passed with stages
in 2 minutes and 4 seconds
from rest_framework import viewsets, permissions from rest_framework import permissions
from .myModelSerializer import MyModelSerializer from .myModelSerializer import MyModelSerializer
from backend.models.tools import NoDeleteIfNotAdmin from backend.models.tools import NoDeleteIfNotAdmin
from backend.models.tools import DictModeViewSet
class MyModelViewSet(viewsets.ModelViewSet): # TODO switch to dict class MyModelViewSet(DictModeViewSet): # TODO switch to dict
serializer_class = MyModelSerializer serializer_class = MyModelSerializer
permission_classes = ( permission_classes = (
permissions.IsAuthenticated, permissions.IsAuthenticated,
......
from backend.models.university import University from backend.models.university import University
from rest_framework import viewsets, permissions from rest_framework import permissions
from backend.models.university.campus import CampusSerializer from backend.models.university.campus import CampusSerializer
from backend.models.tools import NoDeleteIfNotAdmin from backend.models.tools import NoDeleteIfNotAdmin
from backend.models.my_model import MyModelSerializer from backend.models.my_model import MyModelSerializer, MyModelViewSet
class UniversitySerializer(MyModelSerializer): class UniversitySerializer(MyModelSerializer):
...@@ -13,7 +13,7 @@ class UniversitySerializer(MyModelSerializer): ...@@ -13,7 +13,7 @@ class UniversitySerializer(MyModelSerializer):
fields = '__all__' fields = '__all__'
class UniversityViewSet(viewsets.ModelViewSet): # TODO switch to dict class UniversityViewSet(MyModelViewSet):
serializer_class = UniversitySerializer serializer_class = UniversitySerializer
permission_classes = ( permission_classes = (
......
...@@ -38,6 +38,17 @@ class UnivMap extends Component { ...@@ -38,6 +38,17 @@ class UnivMap extends Component {
if (this.props.isLoading || this.props.invalidated) { if (this.props.isLoading || this.props.invalidated) {
return <Loading />; return <Loading />;
} }
let universities = this.props.universities;
let univ_to_plot = [];
for (let univ_pk in universities) {
let univ = universities[univ_pk];
if (univ.univ_campus.length > 0) {
univ_to_plot.push({
name: univ.name,
main_campus: univ.univ_campus[0]
})
}
}
return ( return (
<Map center={[35, 0]} zoom={2} style={{ height: "800px" }}> <Map center={[35, 0]} zoom={2} style={{ height: "800px" }}>
...@@ -79,8 +90,8 @@ class UnivMap extends Component { ...@@ -79,8 +90,8 @@ class UnivMap extends Component {
</LayersControl> </LayersControl>
{ {
this.props.universities.map((el) => ( univ_to_plot.map((el) => (
<Marker position={[el.univ_campus[0].lat, el.univ_campus[0].lon]}> <Marker position={[el.main_campus.lat, el.main_campus.lon]}>
<Popup> <Popup>
{el.name} {el.name}
</Popup> </Popup>
......
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