Commit b740f2dd authored by Florent Chehab's avatar Florent Chehab

Merge branch 'quick_fix_to_models' into 'master'

Fixes #60 Fixes #61

Closes #60 and #61

See merge request !64
parents 02a08975 c1cccf3e
Pipeline #36184 passed with stages
in 5 minutes and 5 seconds
# Generated by Django 2.1.7 on 2019-03-10 10:51
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("backend_app", "0003_auto_20180916_1624")]
operations = [
migrations.RemoveField(model_name="semester", name="moderated_by"),
migrations.RemoveField(model_name="semester", name="updated_by"),
migrations.RemoveField(model_name="userdata", name="black_list"),
migrations.AddField(
model_name="offer",
name="year",
field=models.PositiveIntegerField(default=2018),
),
migrations.AddField(
model_name="previousdeparture",
name="year",
field=models.PositiveIntegerField(default=2018),
),
migrations.AlterField(
model_name="offer",
name="semester",
field=models.CharField(
choices=[("a", "autumn"), ("p", "spring")], default="a", max_length=2
),
),
migrations.AlterField(
model_name="previousdeparture",
name="semester",
field=models.CharField(
choices=[("a", "autumn"), ("p", "spring")], default="a", max_length=2
),
),
migrations.AlterUniqueTogether(name="offer", unique_together=set()),
migrations.DeleteModel(name="Semester"),
]
SEMESTER_OPTIONS = (("a", "autumn"), ("p", "spring"))
__all__ = ["SEMESTER_OPTION"]
from .semester import Semester, SemesterViewSet
from .department import Department, DepartmentViewSet
from .specialty import Specialty, SpecialtyViewSet
from .offer import Offer, OfferViewSet
__all__ = [
"Semester",
"SemesterViewSet",
"Department",
"DepartmentViewSet",
"Specialty",
......
from django.db import models
from backend_app.models.university import University
from backend_app.models.other_core import Semester, Specialty
from backend_app.models.other_core import Specialty
from backend_app.models.abstract.my_model import (
MyModel,
MyModelSerializer,
MyModelViewSet,
)
from backend_app.utils import get_model_config, get_viewset_permissions
from backend_app.models import SEMESTER_OPTIONS
class Offer(MyModel):
model_config = get_model_config("Offer")
semester = models.ForeignKey(Semester, on_delete=models.PROTECT)
university = models.ForeignKey(University, on_delete=models.PROTECT)
year = models.PositiveIntegerField(default=2018)
semester = models.CharField(max_length=2, choices=SEMESTER_OPTIONS, default="a")
nb_seats_offered = models.PositiveIntegerField()
# null => exchange not possible
......@@ -21,9 +23,6 @@ class Offer(MyModel):
specialties = models.ManyToManyField(Specialty, related_name="has_seats_at_univ")
class Meta:
unique_together = ("semester", "university")
class OfferSerializer(MyModelSerializer):
class Meta:
......
from django.db import models
from backend_app.models.abstract.my_model import (
MyModel,
MyModelSerializer,
MyModelViewSet,
)
from backend_app.utils import get_model_config, get_viewset_permissions
class Semester(MyModel):
model_config = get_model_config("Semester")
code = models.CharField(primary_key=True, max_length=6)
class SemesterSerializer(MyModelSerializer):
class Meta:
model = Semester
fields = "__all__"
class SemesterViewSet(MyModelViewSet):
permission_classes = get_viewset_permissions("SemesterViewSet")
queryset = Semester.objects.all() # pylint: disable=E1101
serializer_class = SemesterSerializer
from django.db import models
from backend_app.models.other_core.specialty import Specialty
from backend_app.models.other_core.semester import Semester
from backend_app.models.university import University
from django.contrib.auth.models import User
from backend_app.fields import JSONField
......@@ -10,17 +9,19 @@ from backend_app.models.abstract.my_model import (
MyModelViewSet,
)
from backend_app.utils import get_model_config, get_viewset_permissions
from backend_app.models import SEMESTER_OPTIONS
class PreviousDeparture(MyModel):
model_config = get_model_config("PreviousDeparture")
# 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)
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")
is_anonymous = models.BooleanField()
courses = JSONField(null=True) # Store data from ENT
......
from django.contrib.auth.models import User
from django.db import models
from backend_app.fields import JSONField
from backend_app.models.abstract.my_model import (
MyModel,
MyModelSerializer,
MyModelViewSet,
)
from backend_app.models.university import University
from backend_app.permissions.__list_user_post_permission import (
list_user_post_permission,
)
......@@ -22,7 +20,6 @@ class UserData(MyModel):
contact_info = JSONField(default=dict)
contact_info_is_public = models.BooleanField(default=False)
config = JSONField(default=dict)
black_list = models.ManyToManyField(University, related_name="+", blank=True)
other_data = JSONField(default=dict)
......
......@@ -11,7 +11,7 @@ extract_django: init
> generated/abstract.dot
../backend/manage.py graph_models backend_app --disable-abstract-fields -g -I \
Specialty,Offer,Semester,Department,University \
Specialty,Offer,Department,University \
> generated/core.dot
../backend/manage.py graph_models backend_app --disable-abstract-fields -g -I \
......@@ -23,7 +23,7 @@ extract_django: init
> generated/location.dot
../backend/manage.py graph_models backend_app --disable-abstract-fields -g -I \
RecommendationsList,Recommendation,UserData,PreviousDeparture,PreviousDepartureFeedback,Semester,University,Sepcialty\
RecommendationsList,Recommendation,UserData,PreviousDeparture,PreviousDepartureFeedback,University,Sepcialty\
> generated/user.dot
convert_to_svg: init
......
......@@ -115,13 +115,6 @@
moderation_level: 2
viewset_permission: IsStaffOrReadOnly
- model: Semester
viewset: SemesterViewSet
import_location: other_core
api_end_point: semesters
moderation_level: 2
viewset_permission: IsStaffOrReadOnly
- model: Offer
viewset: OfferViewSet
import_location: other_core
......
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