Commit 86794957 authored by Florent Chehab's avatar Florent Chehab
Browse files

Updated names and generation of frontend

parent d569450d
# THIS FILE IS USED TO GENERATE OTHER VERY IMPORTANT FILES
# BOTH IN THE FRONTEND AND IN THE BACKEND !
# TAKE CARE WHEN MODYFING IT ;)
# model : the model name (may be null)
# viewset : the viewset name for the api
# api_end_pont : the main part of the url for making request to the api
# This string will also be used for naming variables in JS !!
# So no weird characters there please...
# versionned: boolean to specify wether this model is versionned or not
# api_attr : to specify some attributes that may be captured
# and used in the viewset
# requires_testing: boolean to tell if this viewset is only availble in
# a testing environment.
- model: Country - model: Country
viewset: CountryViewSet viewset: CountryViewSet
import_location: location import_location: location
...@@ -23,7 +39,7 @@ ...@@ -23,7 +39,7 @@
- model: UserData - model: UserData
viewset: UserDataViewSet viewset: UserDataViewSet
import_location: user import_location: user
api_end_point: user_data api_end_point: userData
api_name: user-data-detail api_name: user-data-detail
...@@ -62,19 +78,19 @@ ...@@ -62,19 +78,19 @@
- model: CountryTaggedItem - model: CountryTaggedItem
viewset: CountryTaggedItemViewSet viewset: CountryTaggedItemViewSet
import_location: location import_location: location
api_end_point: countries_tagged_items api_end_point: countriesTaggedItems
versionned: true versionned: true
- model: CountryScholarship - model: CountryScholarship
viewset: CountryScholarshipViewSet viewset: CountryScholarshipViewSet
import_location: location import_location: location
api_end_point: countries_scholarships api_end_point: countriesScholarships
versionned: true versionned: true
- model: CountryDri - model: CountryDri
viewset: CountryDriViewSet viewset: CountryDriViewSet
import_location: location import_location: location
api_end_point: countries_dri api_end_point: countriesDri
versionned: true versionned: true
...@@ -82,7 +98,7 @@ ...@@ -82,7 +98,7 @@
- model: CityTaggedItem - model: CityTaggedItem
viewset: CityTaggedItemViewSet viewset: CityTaggedItemViewSet
import_location: location import_location: location
api_end_point: cities_tagged_items api_end_point: citiesTaggedItems
versionned: true versionned: true
...@@ -90,37 +106,37 @@ ...@@ -90,37 +106,37 @@
- model: UniversityTaggedItem - model: UniversityTaggedItem
viewset: UniversityTaggedItemViewSet viewset: UniversityTaggedItemViewSet
import_location: university import_location: university
api_end_point: universities_tagged_items api_end_point: universitiesTaggedItems
versionned: true versionned: true
- model: UniversityScholarship - model: UniversityScholarship
viewset: UniversityScholarshipViewSet viewset: UniversityScholarshipViewSet
import_location: university import_location: university
api_end_point: universities_scholarships api_end_point: universitiesScholarships
versionned: true versionned: true
- model: UniversityInfo - model: UniversityInfo
viewset: UniversityInfoViewSet viewset: UniversityInfoViewSet
import_location: university import_location: university
api_end_point: universities_info api_end_point: universitiesInfo
versionned: true versionned: true
- model: UniversitySemestersDates - model: UniversitySemestersDates
viewset: UniversitySemestersDatesViewSet viewset: UniversitySemestersDatesViewSet
import_location: university import_location: university
api_end_point: universities_semesters_dates api_end_point: universitiesSemestersDates
versionned: true versionned: true
- model: UniversityDri - model: UniversityDri
viewset: UniversityDriViewSet viewset: UniversityDriViewSet
import_location: university import_location: university
api_end_point: universities_dri api_end_point: universitiesDri
versionned: true versionned: true
- model: null - model: null
viewset: UniversityModulesViewSet viewset: UniversityModulesViewSet
import_location: university import_location: university
api_end_point: university_all api_end_point: universitiesAll
api_attr: (?P<univ_id>[0-9]+) api_attr: (?P<univ_id>[0-9]+)
api_name: university_details api_name: university_details
...@@ -129,13 +145,13 @@ ...@@ -129,13 +145,13 @@
- model: CampusTaggedItem - model: CampusTaggedItem
viewset: CampusTaggedItemViewSet viewset: CampusTaggedItemViewSet
import_location: university import_location: university
api_end_point: campuses_tagged_items api_end_point: campusesTaggedItems
versionned: true versionned: true
- model: null - model: null
viewset: MainCampusViewSet viewset: MainCampusViewSet
import_location: university import_location: university
api_end_point: main_campuses api_end_point: mainCampuses
read_only: true read_only: true
...@@ -143,36 +159,36 @@ ...@@ -143,36 +159,36 @@
- model: Recommendation - model: Recommendation
viewset: RecommendationViewSet viewset: RecommendationViewSet
import_location: user import_location: user
api_end_point: user_recommendations api_end_point: userRecommendations
- model: RecommendationList - model: RecommendationList
viewset: RecommendationListViewSet viewset: RecommendationListViewSet
import_location: user import_location: user
api_end_point: user_recommendation_lists api_end_point: userRecommendationLists
- model: PreviousDeparture - model: PreviousDeparture
viewset: PreviousDepartureViewSet viewset: PreviousDepartureViewSet
import_location: user import_location: user
api_end_point: universities_previous_departures api_end_point: universitiesPreviousDepartures
- model: PreviousDepartureFeedback - model: PreviousDepartureFeedback
viewset: PreviousDepartureFeedbackViewSet viewset: PreviousDepartureFeedbackViewSet
import_location: user import_location: user
api_end_point: universities_previous_departure_feedback api_end_point: universitiesPreviousDepartureFeedback
- model: PendingModeration - model: PendingModeration
viewset: PendingModerationViewSet viewset: PendingModerationViewSet
import_location: my_model import_location: my_model
api_end_point: pending_moderation api_end_point: pendingModeration
- model: Version - model: Version
viewset: VersionViewSet viewset: VersionViewSet
import_location: my_model import_location: my_model
api_end_point: version api_end_point: versions
api_attr: (?P<content_type_id>[0-9]+)/(?P<object_pk>[0-9A-Za-z]+) api_attr: (?P<content_type_id>[0-9]+)/(?P<object_pk>[0-9A-Za-z]+)
api_name: versions-list api_name: versionsList
ignore_in_admin: true ignore_in_admin: true
- model: ForTestingModeration - model: ForTestingModeration
......
...@@ -44,11 +44,13 @@ with open(join(current_dir, '../../backend/generate/api_config.yml'), 'r') as f: ...@@ -44,11 +44,13 @@ with open(join(current_dir, '../../backend/generate/api_config.yml'), 'r') as f:
contexts = [] contexts = []
for api in api_config: for api in api_config:
if "requires_testing" in api and api["requires_testing"]:
continue
name = api['viewset'].split('ViewSet')[0] name = api['viewset'].split('ViewSet')[0]
name = name[0].lower() + name[1:] name = name[0].lower() + name[1:]
contexts.append({ contexts.append({
"name": name, "name": api["api_end_point"],
"api_end_point": API_BASE + api["api_end_point"] + '/' "api_end_point": API_BASE + api["api_end_point"] + '/',
}) })
......
...@@ -27,7 +27,7 @@ import { ...@@ -27,7 +27,7 @@ import {
} from 'react-router-dom'; } from 'react-router-dom';
import { import {
countryFetchData, countriesFetchData,
} from '../generated/actions'; } from '../generated/actions';
...@@ -181,7 +181,7 @@ const mapStateToProps = (state) => { ...@@ -181,7 +181,7 @@ const mapStateToProps = (state) => {
const mapDispatchToProps = (dispatch) => { const mapDispatchToProps = (dispatch) => {
return { return {
fetchData: { fetchData: {
countries: () => dispatch(countryFetchData()) countries: () => dispatch(countriesFetchData())
} }
}; };
}; };
......
...@@ -7,8 +7,8 @@ import { Map, TileLayer, Marker, Popup, LayersControl, FeatureGroup, Circle, Lay ...@@ -7,8 +7,8 @@ import { Map, TileLayer, Marker, Popup, LayersControl, FeatureGroup, Circle, Lay
import { import {
universitiesFetchData, universitiesFetchData,
universitiesInvalidated, universitiesInvalidated,
mainCampusFetchData, mainCampusesFetchData,
mainCampusInvalidated mainCampusesInvalidated
} from '../../generated/actions'; } from '../../generated/actions';
...@@ -18,11 +18,11 @@ class UnivMarkers extends Component { ...@@ -18,11 +18,11 @@ class UnivMarkers extends Component {
render() { render() {
let universities = this.props.universities.fetched.data; let universities = this.props.universities.fetched.data;
let mainCampus = this.props.mainCampus.fetched.data; let mainCampuses = this.props.mainCampuses.fetched.data;
let selected_main_campus = []; let selected_main_campus = [];
for (let main_campus_pk in mainCampus) { for (let main_campus_pk in mainCampuses) {
let campus = mainCampus[main_campus_pk] let campus = mainCampuses[main_campus_pk]
let univ = universities[campus.university] let univ = universities[campus.university]
if (univ && campus) { if (univ && campus) {
selected_main_campus.push({ selected_main_campus.push({
...@@ -51,7 +51,7 @@ class UnivMarkers extends Component { ...@@ -51,7 +51,7 @@ class UnivMarkers extends Component {
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return { return {
universities: state.universities, universities: state.universities,
mainCampus: state.mainCampus mainCampuses: state.mainCampuses
}; };
}; };
......
import React from 'react'; import React from 'react';
import MyComponent from '../MyComponent' import MyComponent from '../MyComponent'
import { connect } from "react-redux"; import { connect } from "react-redux";
import Loading from '../other/Loading'; import { Map, TileLayer, LayersControl, LayerGroup } from 'react-leaflet';
import { Map, TileLayer, Marker, Popup, LayersControl, FeatureGroup, Circle, LayerGroup } from 'react-leaflet';
// import MarkerClusterGroup from 'react-leaflet-markercluster';
import { import {
universityFetchData, universitiesFetchData,
mainCampusFetchData, mainCampusesFetchData,
} from '../../generated/actions'; } from '../../generated/actions';
import UnivMarkers from './UnivMakers'; import UnivMarkers from './UnivMakers';
...@@ -107,7 +106,7 @@ class UnivMap extends MyComponent { ...@@ -107,7 +106,7 @@ class UnivMap extends MyComponent {
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return { return {
universities: state.universities, universities: state.universities,
mainCampus: state.mainCampus, mainCampuses: state.mainCampuses,
map: state.app.mainMap map: state.app.mainMap
}; };
}; };
...@@ -115,8 +114,8 @@ const mapStateToProps = (state) => { ...@@ -115,8 +114,8 @@ const mapStateToProps = (state) => {
const mapDispatchToProps = (dispatch) => { const mapDispatchToProps = (dispatch) => {
return { return {
fetchData: { fetchData: {
universities: () => dispatch(universityFetchData()), universities: () => dispatch(universitiesFetchData()),
mainCampus: () => dispatch(mainCampusFetchData()) mainCampuses: () => dispatch(mainCampusesFetchData())
}, },
saveMainMap: (pos) => dispatch(saveMainMapPosition(pos)), saveMainMap: (pos) => dispatch(saveMainMapPosition(pos)),
}; };
......
import { combineReducers } from 'redux'; import { combineReducers } from 'redux';
import { import {
universityReducers, universitiesReducers,
mainCampusReducers, mainCampusesReducers,
countryReducers, countriesReducers,
countryElReducers, countriesElReducers,
universityElReducers universitiesElReducers
} from '../generated/combinedReducers'; } from '../generated/combinedReducers';
import { import {
...@@ -17,11 +17,11 @@ const appReducers = combineReducers({ ...@@ -17,11 +17,11 @@ const appReducers = combineReducers({
}) })
const rootReducer = combineReducers({ const rootReducer = combineReducers({
countries: countryReducers, countries: countriesReducers,
countryEl: countryElReducers, countriesEl: countriesElReducers,
universities: universityReducers, universities: universitiesReducers,
universityEl: universityElReducers, universitiesEl: universitiesElReducers,
mainCampus: mainCampusReducers, mainCampuses: mainCampusesReducers,
app: appReducers app: appReducers
}) })
......
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