Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Julien Jerphanion
Rex Dri
Commits
1926238c
Commit
1926238c
authored
Aug 21, 2018
by
Florent Chehab
Browse files
Tweaks and new modules for userData
parent
34b53036
Changes
18
Hide whitespace changes
Inline
Side-by-side
docs/UML/Architecture.pu
View file @
1926238c
...
...
@@ -2,9 +2,9 @@
!include AbstractModules.pu
!include Core.pu
!include CountryModules.pu
!include CityModules.pu
!include UniversityModules.pu
!include CountryModules.pu
!include CampusAndModules.pu
!include UserFunctions.pu
...
...
docs/UML/CampusAndModules.pu
View file @
1926238c
...
...
@@ -21,17 +21,17 @@ package Campus {
class
CultureAndStudentLife
class
Accomodation
class
Transport
class
OtherStuff
class
Campus
OtherStuff
CultureAndStudentLife
-
up
-|>
BasicModuleCopyCampusExtra
Accomodation
-
up
-|>
BasicModuleCopyCampusExtra
Transport
-
up
-|>
BasicModuleCopyCampusExtra
OtherStuff
-
up
-|>
BasicModuleCopyCampusExtra
Campus
OtherStuff
-
up
-|>
BasicModuleCopyCampusExtra
CultureAndStudentLife
"1"
-
down
[
bold
,#
green
]-
"1"
Campus
Accomodation
"1"
-
down
[
bold
,#
green
]-
"1"
Campus
Transport
"1"
-
down
[
bold
,#
green
]-
"1"
Campus
OtherStuff
"1"
-
down
[
bold
,#
green
]-
"1"
Campus
Campus
OtherStuff
"1"
-
down
[
bold
,#
green
]-
"1"
Campus
}
Campus
"1..n"
--
"1"
University
...
...
docs/UML/CountryModules.pu
View file @
1926238c
...
...
@@ -25,9 +25,11 @@ package CountryModule{
CountryTransport
-
up
-|>
BasicModuleCopyCountry
CountryTourism
-
up
-|>
BasicModuleCopyCountry
CountryPhoto
-
up
-|>
PhotoCopyCountry
CountryPhoto
-
left
-|>
PhotoCopyCountry
CountryPhoto
"*"
-
right
-
"1"
CountryVirtualCopy
ScholarshipCountry
-
up
-|>
ScholarShipCopyCountry
ScholarshipCountry
-
right
-|>
ScholarShipCopyCountry
ScholarshipCountry
"*"
-
left
-
"*"
CountryVirtualCopy
class
CountryVirtualCopy
as
"Country"
<
copy
for
\
n
cleaner
UML
>
#
lightgrey
...
...
@@ -39,9 +41,7 @@ package CountryModule{
CountryOtherStuff
"1"
-
down
[
bold
,#
green
]-
"1"
CountryVirtualCopy
CountryTransport
"1"
-
down
[
bold
,#
green
]-
"1"
CountryVirtualCopy
CountryTourism
"1"
-
down
[
bold
,#
green
]-
"1"
CountryVirtualCopy
CountryPhoto
"1"
-
down
[
bold
,#
green
]-
"1"
CountryVirtualCopy
ScholarshipCountry
"*"
-
down
-
"*"
CountryVirtualCopy
}
CountryVirtualCopy
-
down
[
bold
,#
green
]-
Country
...
...
docs/UML/UniversityModules.pu
View file @
1926238c
...
...
@@ -13,7 +13,7 @@ package UniversityModule{
class
UniversityPhoto
class
Courses
class
SpecialOffer
class
OtherStuff
class
University
OtherStuff
class
Insurances
class
SemestersDates
{
...
...
@@ -31,7 +31,7 @@ package UniversityModule{
CultureUniversity
-
up
-|>
BasicModuleCopyUniversity
Courses
-
up
-|>
BasicModuleCopyUniversity
SpecialOffer
-
up
-|>
BasicModuleCopyUniversity
OtherStuff
-
up
-|>
BasicModuleCopyUniversity
University
OtherStuff
-
up
-|>
BasicModuleCopyUniversity
Insurances
-
up
-|>
BasicModuleCopyUniversity
SemestersDates
-
up
-|>
BasicModuleCopyUniversity
UniversityInfo
-
up
-|>
BasicModuleCopyUniversity
...
...
@@ -46,7 +46,7 @@ package UniversityModule{
CultureUniversity
"1"
-
down
[
bold
,#
green
]-
"1"
UniversityVirtualCopy
UniversityPhoto
"*"
-
right
-
"1"
UniversityVirtualCopy
Courses
"1"
-
down
[
bold
,#
green
]-
"1"
UniversityVirtualCopy
OtherStuff
"1"
-
down
[
bold
,#
green
]-
"1"
UniversityVirtualCopy
University
OtherStuff
"1"
-
down
[
bold
,#
green
]-
"1"
UniversityVirtualCopy
Insurances
"1"
-
down
[
bold
,#
green
]-
"1"
UniversityVirtualCopy
SpecialOffer
"1"
-
down
[
bold
,#
green
]-
"1"
UniversityVirtualCopy
UniversityInfo
"1"
-
down
[
bold
,#
green
]-
"1"
UniversityVirtualCopy
...
...
docs/UML/UserFunctions.pu
View file @
1926238c
...
...
@@ -30,16 +30,34 @@ package UserFunctionalities #lightblue{
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
rex/admin.py
View file @
1926238c
...
...
@@ -44,6 +44,8 @@ from rex.models.otherCore import Specialty
from
rex.models.user
import
Recommendation
from
rex.models.user
import
RecommendationList
from
rex.models.user
import
PreviousDeparture
from
rex.models.user
import
PreviousDepartureFeedback
from
rex.models.user
import
UserData
CLASSIC_MODELS
=
[
Country
,
...
...
@@ -56,6 +58,8 @@ CLASSIC_MODELS = [
Recommendation
,
RecommendationList
,
PreviousDeparture
,
PreviousDepartureFeedback
,
UserData
]
VERSIONNED_MODELS
=
[
...
...
rex/migrations/0028_auto_20180821_2104.py
0 → 100644
View file @
1926238c
# Generated by Django 2.0.3 on 2018-08-21 19:04
from
django.conf
import
settings
import
django.core.validators
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
migrations
.
swappable_dependency
(
settings
.
AUTH_USER_MODEL
),
(
'rex'
,
'0027_auto_20180821_1748'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'PreviousDepartureFeedback'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'adequation_comment'
,
models
.
TextField
()),
(
'integration_comment'
,
models
.
TextField
()),
(
'adequation_grate'
,
models
.
PositiveIntegerField
(
validators
=
[
django
.
core
.
validators
.
MaxValueValidator
(
20
)])),
(
'integration_grade'
,
models
.
PositiveIntegerField
(
validators
=
[
django
.
core
.
validators
.
MaxValueValidator
(
20
)])),
],
options
=
{
'abstract'
:
False
,
},
),
migrations
.
RemoveField
(
model_name
=
'previousdeparture'
,
name
=
'adequation_comment'
,
),
migrations
.
RemoveField
(
model_name
=
'previousdeparture'
,
name
=
'adequation_grate'
,
),
migrations
.
RemoveField
(
model_name
=
'previousdeparture'
,
name
=
'integration_comment'
,
),
migrations
.
RemoveField
(
model_name
=
'previousdeparture'
,
name
=
'integration_grade'
,
),
migrations
.
AddField
(
model_name
=
'offer'
,
name
=
'nb_seats_offered_double_degree'
,
field
=
models
.
PositiveIntegerField
(
null
=
True
),
),
migrations
.
AddField
(
model_name
=
'offer'
,
name
=
'nb_seats_offered_exchange'
,
field
=
models
.
PositiveIntegerField
(
null
=
True
),
),
migrations
.
AddField
(
model_name
=
'previousdeparture'
,
name
=
'Utc_departure_id'
,
field
=
models
.
IntegerField
(
default
=
1
),
preserve_default
=
False
,
),
migrations
.
AddField
(
model_name
=
'previousdeparture'
,
name
=
'courses'
,
field
=
models
.
TextField
(
blank
=
True
,
null
=
True
),
),
migrations
.
AddField
(
model_name
=
'previousdeparture'
,
name
=
'is_anonymous'
,
field
=
models
.
BooleanField
(
default
=
True
),
preserve_default
=
False
,
),
migrations
.
AlterField
(
model_name
=
'offer'
,
name
=
'nb_seats_offered'
,
field
=
models
.
PositiveIntegerField
(),
),
migrations
.
AlterField
(
model_name
=
'previousdeparture'
,
name
=
'user'
,
field
=
models
.
ForeignKey
(
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
settings
.
AUTH_USER_MODEL
),
),
migrations
.
AddField
(
model_name
=
'previousdeparturefeedback'
,
name
=
'departure'
,
field
=
models
.
OneToOneField
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'rex.PreviousDeparture'
),
),
migrations
.
AddField
(
model_name
=
'previousdeparturefeedback'
,
name
=
'user'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
settings
.
AUTH_USER_MODEL
),
),
]
rex/migrations/0029_auto_20180821_2110.py
0 → 100644
View file @
1926238c
# Generated by Django 2.0.3 on 2018-08-21 19:10
import
django.contrib.postgres.fields.jsonb
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'rex'
,
'0028_auto_20180821_2104'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'previousdeparturefeedback'
,
name
=
'courses_and_courses_feedback'
,
field
=
django
.
contrib
.
postgres
.
fields
.
jsonb
.
JSONField
(
null
=
True
),
),
migrations
.
AlterField
(
model_name
=
'previousdeparture'
,
name
=
'courses'
,
field
=
django
.
contrib
.
postgres
.
fields
.
jsonb
.
JSONField
(
null
=
True
),
),
]
rex/migrations/0030_auto_20180821_2138.py
0 → 100644
View file @
1926238c
# Generated by Django 2.0.3 on 2018-08-21 19:38
from
django.conf
import
settings
import
django.contrib.postgres.fields.jsonb
from
django.db
import
migrations
,
models
import
django.db.models.deletion
import
rex.models.tools.usefullLinksField
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
migrations
.
swappable_dependency
(
settings
.
AUTH_USER_MODEL
),
(
'rex'
,
'0029_auto_20180821_2110'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'UserData'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'is_anonymous'
,
models
.
BooleanField
(
default
=
True
)),
(
'is_public'
,
models
.
BooleanField
(
default
=
False
)),
(
'contact_info'
,
rex
.
models
.
tools
.
usefullLinksField
.
UsefullLinksField
(
default
=
[],
null
=
True
,
validators
=
[
rex
.
models
.
tools
.
usefullLinksField
.
validate_usefull_links
])),
(
'contact_info_is_public'
,
models
.
BooleanField
(
default
=
False
)),
(
'config'
,
django
.
contrib
.
postgres
.
fields
.
jsonb
.
JSONField
(
default
=
{},
null
=
True
)),
(
'other_data'
,
django
.
contrib
.
postgres
.
fields
.
jsonb
.
JSONField
(
default
=
{},
null
=
True
)),
(
'user'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
settings
.
AUTH_USER_MODEL
)),
],
options
=
{
'abstract'
:
False
,
},
),
migrations
.
AddField
(
model_name
=
'previousdeparturefeedback'
,
name
=
'is_anonymous'
,
field
=
models
.
BooleanField
(
default
=
True
),
),
migrations
.
AddField
(
model_name
=
'previousdeparturefeedback'
,
name
=
'is_public'
,
field
=
models
.
BooleanField
(
default
=
False
),
),
migrations
.
AddField
(
model_name
=
'recommendation'
,
name
=
'is_anonymous'
,
field
=
models
.
BooleanField
(
default
=
True
),
),
migrations
.
AddField
(
model_name
=
'recommendation'
,
name
=
'is_public'
,
field
=
models
.
BooleanField
(
default
=
False
),
),
migrations
.
AddField
(
model_name
=
'recommendationlist'
,
name
=
'is_anonymous'
,
field
=
models
.
BooleanField
(
default
=
True
),
),
migrations
.
AddField
(
model_name
=
'recommendationlist'
,
name
=
'is_public'
,
field
=
models
.
BooleanField
(
default
=
False
),
),
migrations
.
AlterField
(
model_name
=
'countryphoto'
,
name
=
'country'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'country_photos'
,
to
=
'rex.Country'
),
),
migrations
.
AlterField
(
model_name
=
'universityphoto'
,
name
=
'university'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'university_photos'
,
to
=
'rex.University'
),
),
]
rex/models/location/countryPhoto.py
View file @
1926238c
...
...
@@ -7,7 +7,7 @@ from rest_framework import viewsets, permissions
class
CountryPhoto
(
Photo
):
country
=
models
.
OneToOneField
(
country
=
models
.
ForeignKey
(
Country
,
on_delete
=
models
.
CASCADE
,
related_name
=
'country_photos'
)
...
...
rex/models/otherCore/offer.py
View file @
1926238c
...
...
@@ -7,7 +7,12 @@ from rex.models.otherCore import Semester, Specialty
class
Offer
(
models
.
Model
):
semester
=
models
.
ForeignKey
(
Semester
,
on_delete
=
models
.
PROTECT
)
university
=
models
.
ForeignKey
(
University
,
on_delete
=
models
.
PROTECT
)
nb_seats_offered
=
models
.
IntegerField
()
nb_seats_offered
=
models
.
PositiveIntegerField
()
# null => exchange not possible
nb_seats_offered_exchange
=
models
.
PositiveIntegerField
(
null
=
True
)
nb_seats_offered_double_degree
=
models
.
PositiveIntegerField
(
null
=
True
)
specialty
=
models
.
ManyToManyField
(
Specialty
,
related_name
=
"has_seats_at_univ"
)
...
...
rex/models/university/universityPhoto.py
View file @
1926238c
...
...
@@ -7,7 +7,7 @@ from rest_framework import viewsets, permissions
class
UniversityPhoto
(
Photo
):
university
=
models
.
OneToOneField
(
university
=
models
.
ForeignKey
(
University
,
on_delete
=
models
.
CASCADE
,
related_name
=
'university_photos'
)
...
...
rex/models/user/__init__.py
View file @
1926238c
from
.userRestrictedModule
import
UserRestrictedModule
,
UserRestrictedModuleSerializer
# noqa: F401
from
.previousDeparture
import
PreviousDeparture
,
PreviousDepartureViewSet
# noqa: F401
from
.previousDepartureFeedback
import
PreviousDepartureFeedback
,
PreviousDepartureFeedbackViewSet
# noqa: F401
from
.recommendationList
import
RecommendationList
,
RecommendationListSerializer
,
RecommendationListViewSet
# noqa: F401
from
.recommendation
import
Recommendation
,
RecommendationSerializer
,
RecommendationViewSet
# noqa: F401
from
.userData
import
UserData
,
UserDataViewSet
# noqa: F401
rex/models/user/previousDeparture.py
View file @
1926238c
from
django.db
import
models
from
rest_framework
import
viewsets
,
permissions
from
django.core.validators
import
MaxValueValidator
from
rest_framework
import
viewsets
,
permissions
,
serializers
from
rex.models.otherCore.specialty
import
Specialty
from
rex.models.otherCore.semester
import
Semester
from
rex.models.university
import
University
from
django.contrib.auth.models
import
User
from
django.contrib.postgres.fields
import
JSONField
from
rex.models.user
import
UserRestrictedModule
,
UserRestrictedModuleSerializer
class
PreviousDeparture
(
UserRestrictedModule
):
class
PreviousDeparture
(
models
.
Model
):
# This model should be filled with data from the ENT
semester
=
models
.
ForeignKey
(
Semester
,
on_delete
=
models
.
PROTECT
)
university
=
models
.
ForeignKey
(
University
,
on_delete
=
models
.
PROTECT
)
specialty
=
models
.
ForeignKey
(
Specialty
,
on_delete
=
models
.
PROTECT
)
# TODO check where we store specialty or at least check that it is coherent with user
user
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
CASCADE
,
null
=
True
)
# Usefull to relink a departure with a user
Utc_departure_id
=
models
.
IntegerField
()
adequation_comment
=
models
.
TextField
()
integration_comment
=
models
.
TextField
()
adequation_grate
=
models
.
PositiveIntegerField
(
validators
=
[
MaxValueValidator
(
20
)])
integration_grade
=
models
.
PositiveIntegerField
(
validators
=
[
MaxValueValidator
(
20
)])
is_anonymous
=
models
.
BooleanField
()
courses
=
JSONField
(
null
=
True
)
# Store data from ENT
# TODO ask the DSI to return an anonymous ID with data so
# when someone delete the link and relink we can rematch the data
class
PreviousDepartureSerializer
(
U
ser
RestrictedModule
Serializer
):
class
PreviousDepartureSerializer
(
ser
ializers
.
Model
Serializer
):
class
Meta
:
model
=
PreviousDeparture
...
...
@@ -31,6 +31,7 @@ class PreviousDepartureSerializer(UserRestrictedModuleSerializer):
class
PreviousDepartureViewSet
(
viewsets
.
ModelViewSet
):
permission_classes
=
(
permissions
.
DjangoModelPermissions
,)
permission_classes
=
(
permissions
.
IsAdminUser
,)
queryset
=
PreviousDeparture
.
objects
.
all
()
# pylint: disable=E1101
serializer_class
=
PreviousDepartureSerializer
# todo if is_anonymous set user to null
rex/models/user/previousDepartureFeedback.py
0 → 100644
View file @
1926238c
from
django.db
import
models
from
rest_framework
import
viewsets
,
permissions
from
django.core.validators
import
MaxValueValidator
from
rex.models.user
import
UserRestrictedModule
,
UserRestrictedModuleSerializer
from
rex.models.user
import
PreviousDeparture
from
django.contrib.postgres.fields
import
JSONField
class
PreviousDepartureFeedback
(
UserRestrictedModule
):
departure
=
models
.
OneToOneField
(
PreviousDeparture
,
on_delete
=
models
.
CASCADE
)
courses_and_courses_feedback
=
JSONField
(
null
=
True
)
adequation_comment
=
models
.
TextField
()
integration_comment
=
models
.
TextField
()
adequation_grate
=
models
.
PositiveIntegerField
(
validators
=
[
MaxValueValidator
(
20
)])
integration_grade
=
models
.
PositiveIntegerField
(
validators
=
[
MaxValueValidator
(
20
)])
# TODO check on save that courses are coherent with Previous Departure
class
PreviousDepartureFeedbackSerializer
(
UserRestrictedModuleSerializer
):
class
Meta
:
model
=
PreviousDepartureFeedback
fields
=
'__all__'
class
PreviousDepartureFeedbackViewSet
(
viewsets
.
ModelViewSet
):
permission_classes
=
(
permissions
.
DjangoModelPermissions
,)
queryset
=
PreviousDepartureFeedback
.
objects
.
all
()
# pylint: disable=E1101
serializer_class
=
PreviousDepartureFeedbackSerializer
rex/models/user/userData.py
0 → 100644
View file @
1926238c
from
django.db
import
models
from
rest_framework
import
viewsets
,
permissions
from
rex.models.tools
import
UsefullLinksField
from
django.contrib.postgres.fields
import
JSONField
from
rex.models.user
import
UserRestrictedModule
,
UserRestrictedModuleSerializer
class
UserData
(
UserRestrictedModule
):
contact_info
=
UsefullLinksField
(
null
=
True
)
contact_info_is_public
=
models
.
BooleanField
(
default
=
False
)
config
=
JSONField
(
null
=
True
,
default
=
{})
other_data
=
JSONField
(
null
=
True
,
default
=
{})
class
UserDataSerializer
(
UserRestrictedModuleSerializer
):
class
Meta
:
model
=
UserData
fields
=
'__all__'
class
UserDataViewSet
(
viewsets
.
ModelViewSet
):
permission_classes
=
(
permissions
.
IsAdminUser
,)
# TODO change
queryset
=
UserData
.
objects
.
all
()
# pylint: disable=E1101
serializer_class
=
UserDataSerializer
# TODO change to require a login not display all
rex/models/user/userRestrictedModule.py
View file @
1926238c
...
...
@@ -7,6 +7,12 @@ class UserRestrictedModule(models.Model):
# RGPD made easy with CASCADE
user
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
CASCADE
)
# User is anonymised
is_anonymous
=
models
.
BooleanField
(
default
=
True
)
# To be seen by others than the user, is public needs to be set to True
is_public
=
models
.
BooleanField
(
default
=
False
)
class
Meta
:
abstract
=
True
...
...
rex/urls.py
View file @
1926238c
...
...
@@ -47,6 +47,8 @@ from rex.models.university import CampusOtherStuffViewSet
from
rex.models.user
import
RecommendationViewSet
from
rex.models.user
import
RecommendationListViewSet
from
rex.models.user
import
PreviousDepartureViewSet
from
rex.models.user
import
PreviousDepartureFeedbackViewSet
from
rex.models.user
import
UserDataViewSet
from
rest_framework.documentation
import
include_docs_urls
...
...
@@ -110,7 +112,9 @@ router.register(r'other/specialty', SpecialtyViewSet)
router
.
register
(
r
'other/offer'
,
OfferViewSet
)
router
.
register
(
r
'university_more/previous_departure'
,
PreviousDepartureViewSet
)
router
.
register
(
r
'university_more/previous_departure_feedback'
,
PreviousDepartureFeedbackViewSet
)
router
.
register
(
r
'user/recommendation'
,
RecommendationViewSet
)
router
.
register
(
r
'user/recommendations_list'
,
RecommendationListViewSet
)
router
.
register
(
r
'user/data'
,
UserDataViewSet
)
urlpatterns
+=
[
url
(
r
'^api/'
,
include
(
router
.
urls
))]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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