Commit 34b53036 authored by Florent Chehab's avatar Florent Chehab

User Modules ready

All modules should be close to ready
parent c852a598
Pipeline #26395 passed with stages
in 1 minute and 29 seconds
......@@ -6,6 +6,6 @@
!include CityModules.pu
!include UniversityModules.pu
!include CampusAndModules.pu
!include IndiFunctions.pu
!include UserFunctions.pu
@enduml
......@@ -6,7 +6,7 @@ TARGET=\
generated/CityModules.svg \
generated/AbstractModules.svg \
generated/CampusAndModules.svg \
generated/IndiFunctions.svg
generated/UserFunctions.svg
all: $(TARGET)
......
@startuml
package IndividualizedFunctionalities #lightblue{
package UserFunctionalities #lightblue{
class UniversityCopy1 as "University" #red
class SpecialtyCopy1 as "Specialty" #red
class UserCopy1 as "User" #red
class SemesterCopy1 as "Semester" #red
class RecommendationList{
+ name : string
class RecommendationsList{
+ title : string
+ public : bool
+ content : JSON array \n \t University : FK \n \t comment : MD \n \t adequation_grate : integer
}
UniversityCopy1 "*" -up- "*" RecommendationList
SpecialtyCopy1 "1..n" -up- "*" RecommendationList
UserCopy1 "1" -left- "*" RecommendationList
class Recommendation{
+ order_in_list : integer
+ comment : MD
+ grade : int in [0,20]
}
note as N4
Adequation_grade null or [1,6]
tags for custom list
List can be copied by other user if public.
Presentation like ipython notebook.
endnote
N4 .right. RecommendationList
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{
+ adequation_comment : MD
......@@ -32,12 +35,11 @@ package IndividualizedFunctionalities #lightblue{
+ adequation_grade : integer
+ adequation_grade : integer
}
PreviousDeparture "*" -left- "1" UserCopy1
PreviousDeparture "*" -up- "1" SpecialtyCopy1
PreviousDeparture "*" -up- "1" UniversityCopy1
PreviousDeparture "*" -up- "1..n" SemesterCopy1
}
' End of IndividualiedFunctionalities packages
@enduml
\ No newline at end of file
......@@ -13,4 +13,4 @@ Vue plus précise :
![Architecture](UML/generated/CountryModules.svg)
![Architecture](UML/generated/CityModules.svg)
![Architecture](UML/generated/AbstractModules.svg)
![Architecture](UML/generated/IndiFunctions.svg)
\ No newline at end of file
![Architecture](UML/generated/UserFunctions.svg)
\ No newline at end of file
......@@ -41,6 +41,9 @@ from rex.models.otherCore import Offer
from rex.models.otherCore import Semester
from rex.models.otherCore import Specialty
from rex.models.user import Recommendation
from rex.models.user import RecommendationList
from rex.models.user import PreviousDeparture
CLASSIC_MODELS = [
Country,
......@@ -50,6 +53,9 @@ CLASSIC_MODELS = [
Offer,
Semester,
Specialty,
Recommendation,
RecommendationList,
PreviousDeparture,
]
VERSIONNED_MODELS = [
......
# Generated by Django 2.0.3 on 2018-08-21 15:39
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', '0025_auto_20180821_1647'),
]
operations = [
migrations.CreateModel(
name='PreviousDeparture',
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)])),
('semester', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='rex.Semester')),
('specialty', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='rex.Specialty')),
('university', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='rex.University')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='Recommendation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('order_in_list', models.PositiveIntegerField()),
('comment', models.TextField(blank=True, null=True)),
('grade', models.PositiveIntegerField(null=True, validators=[django.core.validators.MaxValueValidator(20)])),
],
),
migrations.CreateModel(
name='RecommendationList',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('public', models.BooleanField()),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
),
migrations.AddField(
model_name='recommendation',
name='parent_list',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='recommendations', to='rex.RecommendationList'),
),
migrations.AddField(
model_name='recommendation',
name='specialty',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='rex.Specialty'),
),
migrations.AddField(
model_name='recommendation',
name='university',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='rex.University'),
),
migrations.AddField(
model_name='recommendation',
name='user',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
migrations.AlterUniqueTogether(
name='recommendation',
unique_together={('order_in_list', 'parent_list')},
),
]
# Generated by Django 2.0.3 on 2018-08-21 15:48
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('rex', '0026_auto_20180821_1739'),
]
operations = [
migrations.AddField(
model_name='recommendationlist',
name='title',
field=models.CharField(default='2', max_length=200),
preserve_default=False,
),
migrations.AlterUniqueTogether(
name='recommendationlist',
unique_together={('title', 'user')},
),
]
from .userRestrictedModule import UserRestrictedModule, UserRestrictedModuleSerializer # noqa: F401
from .previousDeparture import PreviousDeparture, PreviousDepartureViewSet # noqa: F401
from .recommendationList import RecommendationList, RecommendationListSerializer, RecommendationListViewSet # noqa: F401
from .recommendation import Recommendation, RecommendationSerializer, RecommendationViewSet # noqa: F401
from django.db import models
from rest_framework import viewsets, permissions
from django.core.validators import MaxValueValidator
from rex.models.otherCore.specialty import Specialty
from rex.models.otherCore.semester import Semester
from rex.models.university import University
from rex.models.user import UserRestrictedModule, UserRestrictedModuleSerializer
class PreviousDeparture(UserRestrictedModule):
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
adequation_comment = models.TextField()
integration_comment = models.TextField()
adequation_grate = models.PositiveIntegerField(
validators=[MaxValueValidator(20)])
integration_grade = models.PositiveIntegerField(
validators=[MaxValueValidator(20)])
class PreviousDepartureSerializer(UserRestrictedModuleSerializer):
class Meta:
model = PreviousDeparture
fields = '__all__'
class PreviousDepartureViewSet(viewsets.ModelViewSet):
permission_classes = (permissions.DjangoModelPermissions,)
queryset = PreviousDeparture.objects.all() # pylint: disable=E1101
serializer_class = PreviousDepartureSerializer
from django.db import models
from rest_framework import viewsets, permissions
from django.core.validators import MaxValueValidator
from rex.models.university import University
from rex.models.user import UserRestrictedModule, UserRestrictedModuleSerializer
from rex.models.otherCore import Specialty
from rex.models.user import RecommendationList
class Recommendation(UserRestrictedModule):
university = models.ForeignKey(University, on_delete=models.PROTECT)
parent_list = models.ForeignKey(
RecommendationList, on_delete=models.PROTECT, related_name='recommendations')
specialty = models.ForeignKey(Specialty, on_delete=models.PROTECT)
order_in_list = models.PositiveIntegerField()
comment = models.TextField(null=True, blank=True)
grade = models.PositiveIntegerField(
null=True, validators=[MaxValueValidator(20)])
class Meta:
unique_together = ('order_in_list', 'parent_list')
class RecommendationSerializer(UserRestrictedModuleSerializer):
class Meta:
model = Recommendation
fields = '__all__'
class RecommendationViewSet(viewsets.ModelViewSet):
permission_classes = (permissions.DjangoObjectPermissions,)
queryset = Recommendation.objects.all() # pylint: disable=E1101
serializer_class = RecommendationSerializer
# TODO PERMISSIOIN
from django.db import models
from rest_framework import viewsets, permissions
from rex.models.user import UserRestrictedModule, UserRestrictedModuleSerializer
class RecommendationList(UserRestrictedModule):
public = models.BooleanField()
title = models.CharField(max_length=200)
class Meta:
unique_together = ('title', 'user')
class RecommendationListSerializer(UserRestrictedModuleSerializer):
class Meta:
model = RecommendationList
fields = '__all__'
class RecommendationListViewSet(viewsets.ModelViewSet):
permission_classes = (permissions.DjangoModelPermissions,)
queryset = RecommendationList.objects.all() # pylint: disable=E1101
serializer_class = RecommendationListSerializer
# TODO add public support to check access rights
from django.db import models
from rest_framework import serializers
from django.contrib.auth.models import User
class UserRestrictedModule(models.Model):
# RGPD made easy with CASCADE
user = models.ForeignKey(User, on_delete=models.CASCADE)
class Meta:
abstract = True
class UserRestrictedModuleSerializer(serializers.ModelSerializer):
user = serializers.HiddenField(
default=serializers.CurrentUserDefault(),
) # TODO check that this works
class Meta:
model = UserRestrictedModule
fields = '__all__'
......@@ -44,6 +44,10 @@ from rex.models.university import CampusAccommodationViewSet
from rex.models.university import CampusCultureAndStudentLifeViewSet
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 rest_framework.documentation import include_docs_urls
......@@ -105,5 +109,8 @@ router.register(r'other/department', DepartmentViewSet)
router.register(r'other/specialty', SpecialtyViewSet)
router.register(r'other/offer', OfferViewSet)
router.register(r'university_more/previous_departure', PreviousDepartureViewSet)
router.register(r'user/recommendation', RecommendationViewSet)
router.register(r'user/recommendations_list', RecommendationListViewSet)
urlpatterns += [url(r'^api/', include(router.urls))]
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