Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rex Dri
Rex Dri
Commits
c947cc1e
Unverified
Commit
c947cc1e
authored
May 03, 2020
by
Maxime Emschwiller
Committed by
Florent Chehab
May 03, 2020
Browse files
refacto(backend) : delete old campus and city models
parent
a023e005
Changes
9
Hide whitespace changes
Inline
Side-by-side
backend/backend_app/admin.py
View file @
c947cc1e
...
...
@@ -4,8 +4,6 @@ from reversion_compare.admin import CompareVersionAdmin
from
backend_app.models.abstract.versionedEssentialModule
import
(
VersionedEssentialModule
,
)
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.countryDri
import
CountryDri
from
backend_app.models.countryScholarship
import
CountryScholarship
...
...
@@ -33,8 +31,6 @@ from base_app.models import SiteInformation
ALL_MODELS
=
[
SiteInformation
,
Campus
,
City
,
Country
,
CountryDri
,
CountryScholarship
,
...
...
backend/backend_app/migrations/0003_auto_20200503_1514.py
0 → 100644
View file @
c947cc1e
# Generated by Django 2.1.7 on 2020-05-03 13:14
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[(
"backend_app"
,
"0002_auto_20200417_1430"
)]
operations
=
[
migrations
.
AlterUniqueTogether
(
name
=
"campus"
,
unique_together
=
set
()),
migrations
.
RemoveField
(
model_name
=
"campus"
,
name
=
"city"
),
migrations
.
RemoveField
(
model_name
=
"campus"
,
name
=
"university"
),
migrations
.
RemoveField
(
model_name
=
"city"
,
name
=
"country"
),
migrations
.
DeleteModel
(
name
=
"Campus"
),
migrations
.
DeleteModel
(
name
=
"City"
),
]
backend/backend_app/models/campus.py
deleted
100644 → 0
View file @
a023e005
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
from
django.db
import
models
from
backend_app.models.abstract.base
import
(
BaseModel
,
BaseModelSerializer
,
BaseModelViewSet
,
)
from
backend_app.models.city
import
City
from
backend_app.models.university
import
University
from
backend_app.permissions.app_permissions
import
ReadOnly
class
Campus
(
BaseModel
):
is_main_campus
=
models
.
BooleanField
(
null
=
False
)
name
=
models
.
CharField
(
max_length
=
200
,
default
=
""
,
blank
=
True
)
city
=
models
.
ForeignKey
(
City
,
on_delete
=
models
.
PROTECT
,
null
=
False
)
university
=
models
.
ForeignKey
(
University
,
on_delete
=
models
.
PROTECT
,
null
=
False
,
related_name
=
"university_campuses"
,
)
lat
=
models
.
DecimalField
(
max_digits
=
10
,
decimal_places
=
6
,
validators
=
[
MinValueValidator
(
-
85.05112878
),
MaxValueValidator
(
85.05112878
)],
)
lon
=
models
.
DecimalField
(
max_digits
=
10
,
decimal_places
=
6
,
validators
=
[
MinValueValidator
(
-
180
),
MaxValueValidator
(
180
)],
)
def
location
(
self
):
return
{
"lat"
:
self
.
lat
,
"lon"
:
self
.
lon
}
class
Meta
:
unique_together
=
(
"is_main_campus"
,
"university"
)
def
save
(
self
,
*
args
,
**
kwargs
):
raise
Exception
(
"Can't edit model anymore"
)
def
delete
(
self
,
*
args
,
**
kwargs
):
raise
Exception
(
"Can't edit model anymore"
)
class
CampusSerializer
(
BaseModelSerializer
):
class
Meta
:
model
=
Campus
fields
=
BaseModelSerializer
.
Meta
.
fields
+
(
"is_main_campus"
,
"name"
,
"city"
,
"university"
,
"lat"
,
"lon"
,
)
class
CampusViewSet
(
BaseModelViewSet
):
permission_classes
=
(
ReadOnly
,)
queryset
=
Campus
.
objects
.
all
()
# pylint: disable=E1101
serializer_class
=
CampusSerializer
end_point_route
=
"campuses-deprecated"
class
MainCampusViewSet
(
BaseModelViewSet
):
queryset
=
Campus
.
objects
.
filter
(
is_main_campus
=
True
)
serializer_class
=
CampusSerializer
permission_classes
=
(
ReadOnly
,)
end_point_route
=
"mainCampuses"
backend/backend_app/models/city.py
deleted
100644 → 0
View file @
a023e005
from
django.db
import
models
from
backend_app.models.abstract.base
import
(
BaseModel
,
BaseModelSerializer
,
BaseModelViewSet
,
)
from
backend_app.models.country
import
Country
from
backend_app.permissions.app_permissions
import
ReadOnly
class
City
(
BaseModel
):
name
=
models
.
CharField
(
max_length
=
200
)
local_name
=
models
.
CharField
(
max_length
=
200
,
default
=
""
,
blank
=
True
)
# We add an area to distinguish similarly named cities
# in a country
area
=
models
.
CharField
(
max_length
=
200
,
default
=
""
,
blank
=
True
)
country
=
models
.
ForeignKey
(
Country
,
on_delete
=
models
.
PROTECT
)
def
save
(
self
,
*
args
,
**
kwargs
):
raise
Exception
(
"Can't edit model anymore"
)
def
delete
(
self
,
*
args
,
**
kwargs
):
raise
Exception
(
"Can't edit model anymore"
)
class
CitySerializer
(
BaseModelSerializer
):
class
Meta
:
model
=
City
fields
=
BaseModelSerializer
.
Meta
.
fields
+
(
"name"
,
"local_name"
,
"area"
,
"country"
,
)
class
CityViewSet
(
BaseModelViewSet
):
queryset
=
City
.
objects
.
all
()
# pylint: disable=E1101
serializer_class
=
CitySerializer
permission_classes
=
(
ReadOnly
,)
end_point_route
=
"cities-deprecated"
backend/backend_app/viewsets.py
View file @
c947cc1e
...
...
@@ -8,8 +8,6 @@ from rest_framework.viewsets import ViewSet
from
backend_app.checks
import
check_viewsets
from
backend_app.models.abstract.base
import
BaseModelViewSet
from
backend_app.models.abstract.essentialModule
import
EssentialModuleViewSet
from
backend_app.models.campus
import
CampusViewSet
,
MainCampusViewSet
from
backend_app.models.city
import
CityViewSet
from
backend_app.models.country
import
CountryViewSet
from
backend_app.models.countryDri
import
CountryDriViewSet
from
backend_app.models.countryScholarship
import
CountryScholarshipViewSet
...
...
@@ -121,9 +119,6 @@ class ExchangeViewSet(BaseModelViewSet):
ALL_API_VIEWSETS
=
[
SiteInformationViewSet
,
UserViewset
,
CampusViewSet
,
MainCampusViewSet
,
CityViewSet
,
CountryViewSet
,
CountryDriViewSet
,
CountryScholarshipViewSet
,
...
...
frontend/src/components/app/App.jsx
View file @
c947cc1e
...
...
@@ -25,7 +25,6 @@ import PageAboutUnlinkedPartners from "../pages/PageAboutUnlinkedPartners";
import
PageLogout
from
"
../pages/PageLogout
"
;
import
withNetworkWrapper
,
{
NetWrapParam
}
from
"
../../hoc/withNetworkWrapper
"
;
import
UniversityService
from
"
../../services/data/UniversityService
"
;
// import CityService from "../../services/data/CityService";
import
CountryService
from
"
../../services/data/CountryService
"
;
import
CurrencyService
from
"
../../services/data/CurrencyService
"
;
import
LanguageService
from
"
../../services/data/LanguageService
"
;
...
...
@@ -34,15 +33,12 @@ import useOnBeforeComponentMount from "../../hooks/useOnBeforeComponentMount";
const
SERVICES_TO_INITIALIZE
=
[
UniversityService
,
// CityService,
CountryService
,
CurrencyService
,
LanguageService
,
FilterService
];
// import PageFiles from "../pages/PageFiles";
/**
* Main entry
*/
...
...
@@ -104,9 +100,7 @@ App.propTypes = {};
export
default
compose
(
withNetworkWrapper
([
new
NetWrapParam
(
"
countries
"
,
"
all
"
),
//new NetWrapParam("cities", "all"),
new
NetWrapParam
(
"
universities
"
,
"
all
"
),
//new NetWrapParam("mainCampuses", "all"),
new
NetWrapParam
(
"
currencies
"
,
"
all
"
),
new
NetWrapParam
(
"
languages
"
,
"
all
"
),
new
NetWrapParam
(
"
serverModerationStatus
"
,
"
all
"
)
// not needed for server moderation status
...
...
frontend/src/components/university/UnivInfoProvider.jsx
View file @
c947cc1e
...
...
@@ -11,12 +11,12 @@ function UnivInfoProvider({ univId, children }) {
const
univIdParsed
=
parseInt
(
univId
,
10
);
const
univ
=
UniversityService
.
getUniversityById
(
univIdParsed
);
const
country
=
CountryService
.
getCountryForCountryId
(
univ
.
country
)
const
city
=
univ
.
city
const
{
city
}
=
univ
.
city
const
countryId
=
country
.
id
;
return
(
<
UnivContext
.
Provider
value
=
{
{
value
=
{
{
univId
:
univIdParsed
,
countryId
,
univ
,
...
...
frontend/src/services/data/CityService.js
deleted
100644 → 0
View file @
a023e005
// import arrayOfInstancesToMap from "../../utils/arrayOfInstancesToMap";
// import { getLatestApiReadData } from "../../hooks/useGlobalState";
// class CityService {
// /**
// * Stores the cities by its id
// * @type {Map<number, object>}
// * @private
// */
// _citiesById = new Map();
// /**
// * Must be called once before accessing other methods.
// */
// initialize() {
// const cities = this.getCities();
// this._citiesById = arrayOfInstancesToMap(cities);
// }
// /**
// * Get the city object for a city id
// *
// * @param {number} cityId
// * @returns {Object}
// */
// getCityForCityId(cityId) {
// return this._citiesById.get(cityId);
// }
// getCities() {
// return getLatestApiReadData("cities-all");
// }
// }
// export default new CityService();
frontend/src/services/data/UniversityService.js
View file @
c947cc1e
// import CityService from "./CityService";
// import CountryService from "./CountryService";
import
arrayOfInstancesToMap
from
"
../../utils/arrayOfInstancesToMap
"
;
import
{
getLatestApiReadData
}
from
"
../../hooks/useGlobalState
"
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment