Commit 9e62f092 authored by Florent Chehab's avatar Florent Chehab
Browse files

Merge branch 'work_on_backend' into 'master'

Work on backend

See merge request chehabfl/outgoing_rex!34
parents 9c099cdf 2303c5bd
Pipeline #27075 passed with stages
in 2 minutes and 42 seconds
from .checks import check_required
from .validators import validate_url, validate_text
from .url import validate_url
from .text import validate_text
from rest_framework.validators import ValidationError
from .tags_config import PHOTOS_TAG_GONFIG
from .tags_config import PHOTOS_TAG_CONFIG
from .tags_config import USEFULL_LINKS_CONFIG
......@@ -29,7 +30,7 @@ def validate_content_against_config(config, content):
elif field_type == 'text':
validate_text(field_config, field_submitted)
elif field_type == 'photos':
validate_content_against_config({"photos": PHOTOS_TAG_GONFIG}, {
validate_content_against_config({"photos": PHOTOS_TAG_CONFIG}, {
"photos": field_submitted})
elif field_type == 'usefull_links':
validate_content_against_config({"ul": USEFULL_LINKS_CONFIG}, {
......
from .photos import PHOTOS_TAG_GONFIG # noqa: F401
from .photos import PHOTOS_TAG_CONFIG # noqa: F401
from .usefull_links import USEFULL_LINKS_CONFIG # noqa: F401
from django.conf import settings
PHOTOS_TAG_GONFIG = {
PHOTOS_TAG_CONFIG = {
"type": "array",
"required": True,
"content": {
......
all:
mkdir -p generated
../manage.py graph_models backend --disable-fields -g \
| tail -n +2 > generated/architecture.dot
dot -Tsvg generated/architecture.dot -o generated/architecture.svg
../manage.py graph_models backend --disable-abstract-fields -g -I \
MyModel,MyModelVersionned,BasicModule,Scholarship,UserRestrictedModule \
| tail -n +2 > generated/abstract.dot
dot -Tsvg generated/abstract.dot -o generated/abstract.svg
../manage.py graph_models backend --disable-abstract-fields -g -I \
Specialty,Offer,Semester,Department,University \
| tail -n +2 > generated/core.dot
dot -Tsvg generated/core.dot -o generated/core.svg
../manage.py graph_models backend --disable-abstract-fields -g -I \
University,UniversityScholarship,UniversityInfo,UniversitySemestersDates,UniversityTaggedItems,UniversityDri,Campus,CampusTaggedItems \
| tail -n +2 > generated/university.dot
dot -Tsvg generated/university.dot -o generated/university.svg
../manage.py graph_models backend --disable-abstract-fields -g -I \
Country,City,CountryTaggedItems,CityTaggedItems,CountryScholarship,CountryDri\
| tail -n +2 > generated/location.dot
dot -Tsvg generated/location.dot -o generated/location.svg
../manage.py graph_models backend --disable-abstract-fields -g -I \
RecommendationsList,Recommendation,UserData,PreviousDeparture,PreviousDepartureFeedback,Semester,University,Sepcialty\
| tail -n +2 > generated/user.dot
dot -Tsvg generated/user.dot -o generated/user.svg
.PHONY: clean
clean:
rm -rf generated/
@startuml
!include my_model__module.pu
!include other_core.pu
!include location.pu
!include university.pu
!include UserFunctions.pu
@enduml
TARGET=\
generated/Architecture.svg \
generated/other_core.svg \
generated/university.svg \
generated/my_model__module.svg \
generated/location.svg \
generated/UserFunctions.svg
all: $(TARGET)
generated/%.svg: %.pu
mkdir -p generated/
plantuml -tsvg -o $(abspath generated/) $<
.PHONY: clean
clean:
rm -rf generated/
@startuml
package UserFunctionalities #lightblue{
class UniversityCopy1 as "University" #red
class SpecialtyCopy1 as "Specialty" #red
class UserCopy1 as "User" #red
class SemesterCopy1 as "Semester" #red
class RecommendationsList{
+ title : string
+ public : bool
}
class Recommendation{
+ order_in_list : integer
+ comment : MD
+ grade : int in [0,20]
}
RecommendationsList "1"-right-"*" Recommendation
UniversityCopy1 "*" -up- "*" RecommendationsList
SpecialtyCopy1 "1..n" -up- "*" RecommendationsList
UserCopy1 "1" -left- "*" RecommendationsList
UserCopy1 "1" -right- "*" Recommendation
note on link #white
User <-> Recommendation
Required to controll access
end note
class PreviousDeparture{
+ is_anonymous : bool
+ courses : JSON
+ Utc_departure_id : int
}
class PreviousDepartureFeedback{
+ adequation_comment : MD
+ integration_comment : MD
+ adequation_grade : integer
+ adequation_grade : integer
+ courses_and_courses_feedback : JSON
}
PreviousDeparture "1" -right- "1" PreviousDepartureFeedback
PreviousDeparture "*" -left- "1" UserCopy1
PreviousDeparture "*" -up- "1" SpecialtyCopy1
PreviousDeparture "*" -up- "1" UniversityCopy1
PreviousDeparture "*" -up- "1..n" SemesterCopy1
class UserData{
+ contact_info : JSON
+ contact_info_is_public : bool
+ config : JSON
+ other_data : JSON
}
UserData "1"-up-"1" UserCopy1
}
@enduml
\ No newline at end of file
@startuml
package location{
class City #white {
+ name : string
+ local_name : string
+ area : string
}
class Country #white {
# iso_alpha2_code : string{2}
+ name : string
+ region_code : string{3}
+ region_name : string
+ sub_region_code : string{3}
+ sub_region_name : string
+ intermediate_region_code : string{3}
+ intermediate_region_name : string
}
City "*" -left-* Country
note "Countries are intially \n hardcoded in the db." as N2
N2 .up. Country
abstract class BasicModuleCopyLocation as "BasicModule" #red
class CountryDri
CountryDri -down-|> BasicModuleCopyLocation
Country "*"-down-"*" CountryDri
abstract class CountryTaggedItem
abstract class ScholarShipCopyCountry as "Scholarship" #red
class ScholarshipCountry
ScholarshipCountry -right-|> ScholarShipCopyCountry
ScholarshipCountry "*" -- "*" Country
CountryTaggedItem "*" -- "*" Country
CityTaggedItem "*" -- "*" City
class CityTaggedItem
}
@enduml
\ No newline at end of file
@startuml
package my_model #lightgrey{
abstract class MyModel{
+ moderated_by : user
+ moderated_on : date
+ updated_by : user
+ updated_on : date
}
abstract class MyModelVersionned <Will be versionned\n in the app>{
----
get_serializer()
}
MyModelVersionned -up-|> MyModel
}
package module #lightgrey{
abstract class BasicModule{
+ comment : string
+ usefull_links : JSON \n array of {url,description}
}
abstract class ScholarShip{
+ type : string
+ amount_min : float {currency}
+ amount_max : float {currency}
}
BasicModule -up-|> MyModelVersionned
ScholarShip -up-|> BasicModule
}
@enduml
\ No newline at end of file
@startuml
package Core {
Class Offer {
+ nb_seats_offered : int
}
Class Semester{
+ code : string {key}
}
Class Department{
+ code : string
+ name : string
+ active : bool
}
Class Specialty {
+ code : string
+ name : string
+ active : bool
}
Offer "*" -down- "1" Semester
Offer "*" -left- "1..n" Specialty
Specialty "1..n" -left- "1" Department
note "Initial data inserted in db." as N3
Semester .. N3
N3 .. Specialty
N3 .. Department
class UsefullLinks #green{
+ content : MD
}
note right of UsefullLinks: It will be a dynamic page \n on the website
}
' End of Core block
Offer "*" -right- "1" University
@enduml
\ No newline at end of file
@startuml
skinparam defaultFontName Inconsolata
package universityP{
class University #wheat {
+ name : string
+ accronyme : string
+ logo : image
+ website : url
}
abstract class UniversityTaggedItem
abstract class ScholarShipCopyUniversity as "Scholarship" #red
class SemestersDates{
+ autumn_begin : date
+ autumn_end : date
+ spring_begin : date
+ spring_end : date
}
class UniversityInfo{
+ cost_exchange : float
+ cost_double_degree : float
}
abstract class Campus{
+ is_main_campus : bool
+ name : string
+ Comment : MD
+ longitude : float
+ latitude : float
}
class UniversityDri
UniversityDri -down-|> BasicModuleCopyCore
University "*"-down-"*" UniversityDri
class CampusTaggedItem
Campus -left- CampusTaggedItem
Campus "1..n" -- "1" University
UniversityScholarship -down-|> ScholarShipCopyUniversity
UniversityInfo "1" -down[bold,#green]- "1" University
SemestersDates "1" -down[bold,#green]- "1" University
UniversityTaggedItem "*" -down- "*" University
UniversityScholarship "*" -down- "1" University
}
University "*" .right. "1" City
@enduml
......@@ -4,11 +4,11 @@ Architecture
Présentation de l'architecture du backend.
Vue complète :
![Architecture](UML/generated/Architecture.svg)
![Architecture](generated/architecture.svg)
Vue plus précise :
![other_core](UML/generated/other_core.svg)
![AbstractModules](UML/generated/university.svg)
![Architecture](UML/generated/location.svg)
![Architecture](UML/generated/my_model__module.svg)
![Architecture](UML/generated/UserFunctions.svg)
\ No newline at end of file
![other_core](generated/abstract.svg)
![other_core](generated/core.svg)
![AbstractModules](generated/university.svg)
![Architecture](generated/location.svg)
![Architecture](generated/user.svg)
\ No newline at end of file
......@@ -38,13 +38,13 @@
- model: Country
viewset: CountryViewSet
import_location: location
import_location: country
api_end_point: countries
viewset_permission: IsStaffOrReadOnly
- model: City
viewset: CityViewSet
import_location: location
import_location: city
api_end_point: cities
moderation_level: 2
......@@ -56,7 +56,7 @@
- model: Campus
viewset: CampusViewSet
import_location: university
import_location: campus
api_end_point: campuses
versionned: true
moderation_level: 2
......@@ -80,7 +80,7 @@
- model: Currency
viewset: CurrencyViewSet
import_location: location
import_location: currency
api_end_point: currencies
moderation_level: 2
viewset_permission: IsStaffOrReadOnly
......@@ -116,19 +116,19 @@
- model: CountryTaggedItem
viewset: CountryTaggedItemViewSet
import_location: location
import_location: country
api_end_point: countriesTaggedItems
versionned: true
- model: CountryScholarship
viewset: CountryScholarshipViewSet
import_location: location
import_location: country
api_end_point: countriesScholarships
versionned: true
- model: CountryDri
viewset: CountryDriViewSet
import_location: location
import_location: country
api_end_point: countriesDri
viewset_permission: IsDriOrReadOnly
versionned: true
......@@ -137,7 +137,7 @@
- model: CityTaggedItem
viewset: CityTaggedItemViewSet
import_location: location
import_location: city
api_end_point: citiesTaggedItems
versionned: true
......@@ -185,13 +185,13 @@
- model: CampusTaggedItem
viewset: CampusTaggedItemViewSet
import_location: university
import_location: campus
api_end_point: campusesTaggedItems
versionned: true
- model: null
viewset: MainCampusViewSet
import_location: university
import_location: campus
api_end_point: mainCampuses
read_only: true
......
......@@ -34,6 +34,7 @@ INSTALLED_APPS = [
'rest_framework.authtoken',
'backend',
'frontend',
'django_extensions',
'debug_toolbar',
]
......
......@@ -20,3 +20,4 @@ flake8
django-debug-toolbar==1.9.1
pandas
pyyaml
git+https://github.com/FloChehab/django-extensions.git@30c1a807aeb985739358d70907496e98d1857abb#egg=django-extensions
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