Commit a01ff1ca authored by Segolene Brisemeur's avatar Segolene Brisemeur Committed by Florent Chehab

feat(Feedback on courses): backend and frontend WIP

* Add new models in backend : Course, CourseFeedback, Exchange, ExchangeFeedback
* Begin front end for previous departure tab

#29 in progress
parent 357cece1
Pipeline #37997 passed with stages
in 4 minutes and 38 seconds
......@@ -12,14 +12,16 @@ from backend_app.models.country import Country
from backend_app.models.countryDri import CountryDri
from backend_app.models.countryScholarship import CountryScholarship
from backend_app.models.countryTaggedItem import CountryTaggedItem
from backend_app.models.course import Course
from backend_app.models.courseFeedback import CourseFeedback
from backend_app.models.currency import Currency
from backend_app.models.department import Department
from backend_app.models.for_testing.moderation import ForTestingModeration
from backend_app.models.for_testing.versioning import ForTestingVersioning
from backend_app.models.offer import Offer
from backend_app.models.pendingModeration import PendingModeration
from backend_app.models.previousDeparture import PreviousDeparture
from backend_app.models.previousDepartureFeedback import PreviousDepartureFeedback
from backend_app.models.exchange import Exchange
from backend_app.models.exchangeFeedback import ExchangeFeedback
from backend_app.models.recommendation import Recommendation
from backend_app.models.recommendationList import RecommendationList
from backend_app.models.specialty import Specialty
......@@ -42,12 +44,14 @@ ALL_MODELS = [
CountryDri,
CountryScholarship,
CountryTaggedItem,
Course,
CourseFeedback,
Currency,
Department,
Offer,
PendingModeration,
PreviousDeparture,
PreviousDepartureFeedback,
Exchange,
ExchangeFeedback,
Recommendation,
RecommendationList,
Specialty,
......
# Generated by Django 2.1.7 on 2019-03-24 20:23
import backend_app.fields
import backend_app.models.abstract.essentialModule
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),
("backend_app", "0001_initial"),
]
operations = [
migrations.CreateModel(
name="Course",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
(
"obj_moderation_level",
models.SmallIntegerField(
default=0,
validators=[
django.core.validators.MinValueValidator(0),
backend_app.models.abstract.essentialModule.validate_obj_model_lv,
],
),
),
("has_pending_moderation", models.BooleanField(default=False)),
("course_id", models.IntegerField()),
("code", models.CharField(max_length=10)),
(
"title",
models.CharField(blank=True, default="", max_length=200, null=True),
),
("link", models.CharField(blank=True, max_length=500, null=True)),
("nb_credit", models.PositiveIntegerField()),
(
"description",
models.TextField(blank=True, max_length=2000, null=True),
),
("profile", models.CharField(blank=True, max_length=10, null=True)),
("tsh_profile", models.CharField(blank=True, max_length=21, null=True)),
(
"student_login",
models.CharField(blank=True, max_length=8, null=True),
),
(
"moderated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to=settings.AUTH_USER_MODEL,
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to=settings.AUTH_USER_MODEL,
),
),
],
options={"abstract": False},
),
migrations.CreateModel(
name="CourseFeedback",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
(
"obj_moderation_level",
models.SmallIntegerField(
default=0,
validators=[
django.core.validators.MinValueValidator(0),
backend_app.models.abstract.essentialModule.validate_obj_model_lv,
],
),
),
("has_pending_moderation", models.BooleanField(default=False)),
("comment", models.TextField(max_length=1500, null=True)),
(
"adequation",
models.IntegerField(
validators=[
django.core.validators.MaxValueValidator(5),
django.core.validators.MinValueValidator(-5),
]
),
),
(
"work_dose",
models.IntegerField(
validators=[
django.core.validators.MaxValueValidator(5),
django.core.validators.MinValueValidator(-5),
]
),
),
(
"language_following_ease",
models.IntegerField(
validators=[
django.core.validators.MaxValueValidator(5),
django.core.validators.MinValueValidator(-5),
]
),
),
("is_psf_credit", models.BooleanField()),
],
options={"abstract": False},
),
migrations.CreateModel(
name="Exchange",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
(
"obj_moderation_level",
models.SmallIntegerField(
default=0,
validators=[
django.core.validators.MinValueValidator(0),
backend_app.models.abstract.essentialModule.validate_obj_model_lv,
],
),
),
("has_pending_moderation", models.BooleanField(default=False)),
("utc_departure_id", models.IntegerField()),
("year", models.PositiveIntegerField(default=2018)),
(
"semester",
models.CharField(
choices=[("a", "autumn"), ("p", "spring")],
default="a",
max_length=2,
),
),
("duration", models.PositiveIntegerField()),
("dual_degree", models.BooleanField()),
("master_obtained", models.BooleanField()),
("student_major", models.CharField(max_length=40)),
("student_minor", models.CharField(max_length=40)),
("student_option", models.CharField(max_length=40)),
("utc_allow_courses", models.BooleanField()),
("utc_allow_login", models.BooleanField()),
("is_anonymous", models.BooleanField()),
("courses", backend_app.fields.JSONField(null=True)),
(
"moderated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to=settings.AUTH_USER_MODEL,
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to=settings.AUTH_USER_MODEL,
),
),
(
"user",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
(
"utc_univ_id",
models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
to="backend_app.University",
),
),
],
options={"abstract": False},
),
migrations.CreateModel(
name="ExchangeFeedback",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("updated_on", models.DateTimeField(null=True)),
("moderated_on", models.DateTimeField(null=True)),
(
"obj_moderation_level",
models.SmallIntegerField(
default=0,
validators=[
django.core.validators.MinValueValidator(0),
backend_app.models.abstract.essentialModule.validate_obj_model_lv,
],
),
),
("has_pending_moderation", models.BooleanField(default=False)),
("general_comment", models.TextField(max_length=1500, null=True)),
(
"academical_level_appreciation",
models.IntegerField(
validators=[
django.core.validators.MaxValueValidator(5),
django.core.validators.MinValueValidator(-5),
]
),
),
(
"foreign_student_welcome",
models.PositiveIntegerField(
validators=[django.core.validators.MaxValueValidator(10)]
),
),
(
"cultural_interest",
models.PositiveIntegerField(
validators=[django.core.validators.MaxValueValidator(10)]
),
),
(
"departure",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
to="backend_app.Exchange",
),
),
(
"moderated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to=settings.AUTH_USER_MODEL,
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to=settings.AUTH_USER_MODEL,
),
),
],
options={"abstract": False},
),
migrations.RemoveField(model_name="previousdeparture", name="moderated_by"),
migrations.RemoveField(model_name="previousdeparture", name="specialty"),
migrations.RemoveField(model_name="previousdeparture", name="university"),
migrations.RemoveField(model_name="previousdeparture", name="updated_by"),
migrations.RemoveField(model_name="previousdeparture", name="user"),
migrations.RemoveField(
model_name="previousdeparturefeedback", name="departure"
),
migrations.RemoveField(
model_name="previousdeparturefeedback", name="moderated_by"
),
migrations.RemoveField(model_name="previousdeparturefeedback", name="owner"),
migrations.RemoveField(
model_name="previousdeparturefeedback", name="updated_by"
),
migrations.DeleteModel(name="PreviousDeparture"),
migrations.DeleteModel(name="PreviousDepartureFeedback"),
migrations.AddField(
model_name="coursefeedback",
name="departure",
field=models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to="backend_app.Exchange"
),
),
migrations.AddField(
model_name="coursefeedback",
name="moderated_by",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AddField(
model_name="coursefeedback",
name="updated_by",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AddField(
model_name="course",
name="utc_exchange_id",
field=models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to="backend_app.Exchange"
),
),
]
# Generated by Django 2.1.7 on 2019-04-06 14:36
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("backend_app", "0002_auto_20190324_2123"),
("backend_app", "0002_auto_20190405_2131"),
]
operations = []
# Generated by Django 2.1.7 on 2019-04-07 08:10
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [("backend_app", "0003_merge_20190406_1636")]
operations = [
migrations.RenameField(
model_name="coursefeedback", old_name="work_dose", new_name="working_dose"
),
migrations.RemoveField(model_name="course", name="description"),
migrations.RemoveField(model_name="course", name="has_pending_moderation"),
migrations.RemoveField(model_name="course", name="moderated_by"),
migrations.RemoveField(model_name="course", name="moderated_on"),
migrations.RemoveField(model_name="course", name="obj_moderation_level"),
migrations.RemoveField(model_name="course", name="updated_by"),
migrations.RemoveField(model_name="course", name="updated_on"),
migrations.RemoveField(model_name="coursefeedback", name="departure"),
migrations.RemoveField(model_name="exchange", name="has_pending_moderation"),
migrations.RemoveField(model_name="exchange", name="is_anonymous"),
migrations.RemoveField(model_name="exchange", name="moderated_by"),
migrations.RemoveField(model_name="exchange", name="moderated_on"),
migrations.RemoveField(model_name="exchange", name="obj_moderation_level"),
migrations.RemoveField(model_name="exchange", name="updated_by"),
migrations.RemoveField(model_name="exchange", name="updated_on"),
migrations.RemoveField(model_name="exchangefeedback", name="departure"),
migrations.RemoveField(model_name="exchangefeedback", name="id"),
migrations.AddField(
model_name="course",
name="category",
field=models.CharField(blank=True, max_length=5, null=True),
),
migrations.AddField(
model_name="coursefeedback",
name="course",
field=models.ForeignKey(
default=0,
on_delete=django.db.models.deletion.CASCADE,
to="backend_app.Course",
),
),
migrations.AddField(
model_name="coursefeedback",
name="university",
field=models.ForeignKey(
default=0,
on_delete=django.db.models.deletion.PROTECT,
to="backend_app.University",
),
),
migrations.AddField(
model_name="exchangefeedback",
name="exchange",
field=models.OneToOneField(
default=0,
on_delete=django.db.models.deletion.CASCADE,
primary_key=True,
related_name="feedbacks",
serialize=False,
to="backend_app.Exchange",
),
),
migrations.AddField(
model_name="exchangefeedback",
name="university",
field=models.ForeignKey(
default=0,
on_delete=django.db.models.deletion.PROTECT,
to="backend_app.University",
),
),
migrations.AlterField(
model_name="exchange",
name="semester",
field=models.CharField(
choices=[("a", "autumn"), ("p", "spring")], default="a", max_length=5
),
),
migrations.AlterField(
model_name="exchange",
name="student_major",
field=models.CharField(max_length=20),
),
migrations.AlterField(
model_name="exchange",
name="student_minor",
field=models.CharField(max_length=7),
),
migrations.AlterField(
model_name="exchange",
name="student_option",
field=models.CharField(max_length=7),
),
migrations.AlterField(
model_name="exchange",
name="user",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to=settings.AUTH_USER_MODEL,
),
),
]
from django.db import models
from backend_app.models.abstract.base import BaseModel, BaseModelSerializer
from backend_app.models.exchange import Exchange
class Course(BaseModel):
utc_exchange_id = models.OneToOneField(Exchange, on_delete=models.CASCADE)
course_id = models.IntegerField()
code = models.CharField(max_length=10)
title = models.CharField(default="", null=True, blank=True, max_length=200)
link = models.CharField(null=True, blank=True, max_length=500)
nb_credit = models.PositiveIntegerField()
category = models.CharField(null=True, blank=True, max_length=5)
profile = models.CharField(null=True, blank=True, max_length=10)
tsh_profile = models.CharField(null=True, blank=True, max_length=21)
student_login = models.CharField(null=True, blank=True, max_length=8)
class CourseSerializer(BaseModelSerializer):
class Meta:
model = Course
fields = "__all__"
from django.db import models
from django.core.validators import MaxValueValidator, MinValueValidator
from backend_app.models.abstract.essentialModule import (
EssentialModule,
EssentialModuleSerializer,
EssentialModuleViewSet,
)
from backend_app.models.course import Course, CourseSerializer
from backend_app.models.university import University
class CourseFeedback(EssentialModule):
university = models.ForeignKey(University, on_delete=models.PROTECT, default=0)
course = models.ForeignKey(Course, on_delete=models.CASCADE, default=0)
comment = models.TextField(null=True, max_length=1500)
adequation = models.IntegerField(
validators=[MaxValueValidator(5), MinValueValidator(-5)]
)
working_dose = models.IntegerField(
validators=[MaxValueValidator(5), MinValueValidator(-5)]
)
language_following_ease = models.IntegerField(
validators=[MaxValueValidator(5), MinValueValidator(-5)]
)
is_psf_credit = models.BooleanField()
class CourseFeedbackSerializer(EssentialModuleSerializer):
course = CourseSerializer(many=True)
class Meta:
model = CourseFeedback
fields = "__all__"
class CourseFeedbackViewSet(EssentialModuleViewSet):
queryset = CourseFeedback.objects.all().prefetch_related() # pylint: disable=E1101
serializer_class = CourseFeedbackSerializer
end_point_route = "courseFeedbacks"
from django.db import models
from backend_app.models.university import University
from base_app.models import User
from backend_app.fields import JSONField
from backend_app.models.abstract.base import BaseModel, BaseModelSerializer
from backend_app.models.shared import SEMESTER_OPTIONS
class Exchange(BaseModel):
# This model should be filled with data from the ENT
utc_univ_id = models.ForeignKey(University, on_delete=models.PROTECT)
utc_departure_id = models.IntegerField()
user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
year = models.PositiveIntegerField(default=2018)
semester = models.CharField(max_length=5, choices=SEMESTER_OPTIONS, default="a")
duration = models.PositiveIntegerField()
dual_degree = models.BooleanField()
master_obtained = models.BooleanField()
student_major = models.CharField(max_length=20)
student_minor = models.CharField(max_length=7)
student_option = models.CharField(max_length=7)
utc_allow_courses = models.BooleanField()
utc_allow_login = models.BooleanField()
courses = JSONField(null=True) # Store data from ENT
class ExchangeSerializer(BaseModelSerializer):
class Meta:
model = Exchange
fields = BaseModelSerializer.Meta.fields + (
"year",
"semester",
"duration",
"dual_degree",
"master_obtained",
"student_major",
"studentminor",
"student_option",
)
from django.db import models
from django.core.validators import MaxValueValidator, MinValueValidator
from backend_app.models.abstract.essentialModule import (
EssentialModule,
EssentialModuleSerializer,
EssentialModuleViewSet,
)
from backend_app.models.exchange import Exchange
from backend_app.models.university import University
class ExchangeFeedback(EssentialModule):
university = models.ForeignKey(University, on_delete=models.PROTECT, default=0)
exchange = models.OneToOneField(
Exchange,
on_delete=models.CASCADE,
related_name="feedbacks",
primary_key=True,
null=False,
default=0,
)
general_comment = models.TextField(null=True, max_length=1500)
academical_level_appreciation = models.IntegerField(
validators=[MaxValueValidator(5), MinValueValidator(-5)]
)
foreign_student_welcome = models.PositiveIntegerField(
validators=[MaxValueValidator(10)]
)
cultural_interest = models.PositiveIntegerField(validators=[MaxValueValidator(10)])
class ExchangeFeedbackSerializer(EssentialModuleSerializer):
class Meta:
model = ExchangeFeedback
fields = "__all__"
class ExchangeFeedbackViewSet(EssentialModuleViewSet):
queryset = ExchangeFeedback.objects.all() # pylint: disable=E1101
serializer_class = ExchangeFeedbackSerializer
end_point_route = "exchangeFeedbacks"
from django.db import models
from backend_app.models.specialty import Specialty
from backend_app.models.university import University
from backend_app.permissions.app_permissions import ReadOnly
from base_app.models import User
from backend_app.fields import JSONField
from backend_app.models.abstract.essentialModule import (
EssentialModule,
EssentialModuleSerializer,
EssentialModuleViewSet,
)
from backend_app.models.shared import SEMESTER_OPTIONS
class PreviousDeparture(EssentialModule):
# This model should be filled with data from the ENT
university = models.ForeignKey(University, on_delete=models.PROTECT)
specialty = models.ForeignKey(Specialty, on_delete=models.PROTECT)
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True)
# Useful to relink a departure with a user
Utc_departure_id = models.IntegerField()
year = models.PositiveIntegerField(default=2018)
semester = models.CharField(max_length=2, choices=SEMESTER_OPTIONS, default="a")