Commit 12217100 authored by Florent Chehab's avatar Florent Chehab

Removed UserRestrictedModule & tweaked CAS setting

* Removed UserRestrictedModule (and associated models) from the project as it wasn't used (or will not be used)
* Change the settings to make sure the admin of the site is also behind the CAS in production

Fixes #81
parent d3681935
Pipeline #38705 passed with stages
in 3 minutes and 11 seconds
...@@ -16,14 +16,12 @@ from backend_app.models.course import Course ...@@ -16,14 +16,12 @@ from backend_app.models.course import Course
from backend_app.models.courseFeedback import CourseFeedback from backend_app.models.courseFeedback import CourseFeedback
from backend_app.models.currency import Currency from backend_app.models.currency import Currency
from backend_app.models.department import Department from backend_app.models.department import Department
from backend_app.models.exchange import Exchange
from backend_app.models.exchangeFeedback import ExchangeFeedback
from backend_app.models.for_testing.moderation import ForTestingModeration from backend_app.models.for_testing.moderation import ForTestingModeration
from backend_app.models.for_testing.versioning import ForTestingVersioning from backend_app.models.for_testing.versioning import ForTestingVersioning
from backend_app.models.offer import Offer from backend_app.models.offer import Offer
from backend_app.models.pendingModeration import PendingModeration from backend_app.models.pendingModeration import PendingModeration
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 from backend_app.models.specialty import Specialty
from backend_app.models.tag import Tag from backend_app.models.tag import Tag
from backend_app.models.university import University from backend_app.models.university import University
...@@ -52,8 +50,6 @@ ALL_MODELS = [ ...@@ -52,8 +50,6 @@ ALL_MODELS = [
PendingModeration, PendingModeration,
Exchange, Exchange,
ExchangeFeedback, ExchangeFeedback,
Recommendation,
RecommendationList,
Specialty, Specialty,
Tag, Tag,
University, University,
......
# Generated by Django 2.1.7 on 2019-04-23 18:27
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [("backend_app", "0004_auto_20190421_1114")]
operations = [
migrations.AlterUniqueTogether(name="recommendation", unique_together=set()),
migrations.RemoveField(model_name="recommendation", name="moderated_by"),
migrations.RemoveField(model_name="recommendation", name="owner"),
migrations.RemoveField(model_name="recommendation", name="parent_list"),
migrations.RemoveField(model_name="recommendation", name="specialty"),
migrations.RemoveField(model_name="recommendation", name="university"),
migrations.RemoveField(model_name="recommendation", name="updated_by"),
migrations.AlterUniqueTogether(
name="recommendationlist", unique_together=set()
),
migrations.RemoveField(model_name="recommendationlist", name="moderated_by"),
migrations.RemoveField(model_name="recommendationlist", name="owner"),
migrations.RemoveField(model_name="recommendationlist", name="updated_by"),
migrations.DeleteModel(name="Recommendation"),
migrations.DeleteModel(name="RecommendationList"),
]
from django.core.validators import MaxValueValidator
from django.db import models
from backend_app.models.recommendationList import RecommendationList
from backend_app.models.specialty import Specialty
from backend_app.models.university import University
from backend_app.models.userRestrictedModule import (
UserRestrictedModule,
UserRestrictedModuleSerializer,
UserRestrictedModuleViewSet,
)
class Recommendation(UserRestrictedModule):
moderation_level = 0
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.CharField(default="", blank=True, max_length=5000)
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(UserRestrictedModuleViewSet):
queryset = Recommendation.objects.all() # pylint: disable=E1101
serializer_class = RecommendationSerializer
end_point_route = "userRecommendations"
from django.db import models
from backend_app.models.userRestrictedModule import (
UserRestrictedModule,
UserRestrictedModuleSerializer,
UserRestrictedModuleViewSet,
)
class RecommendationList(UserRestrictedModule):
moderation_level = 0
public = models.BooleanField()
title = models.CharField(max_length=200)
class Meta:
unique_together = ("title", "owner")
class RecommendationListSerializer(UserRestrictedModuleSerializer):
class Meta:
model = RecommendationList
fields = "__all__"
class RecommendationListViewSet(UserRestrictedModuleViewSet):
queryset = RecommendationList.objects.all() # pylint: disable=E1101
serializer_class = RecommendationListSerializer
end_point_route = "recommendationList"
from django.db import models
from rest_framework import serializers
from backend_app.models.abstract.essentialModule import (
EssentialModule,
EssentialModuleSerializer,
EssentialModuleViewSet,
)
from base_app.models import User
class UserRestrictedModule(EssentialModule):
"""
"""
# RGPD made easy with CASCADE
owner = 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
class UserRestrictedModuleSerializer(EssentialModuleSerializer):
owner = serializers.HiddenField(default=serializers.CurrentUserDefault())
class Meta:
model = UserRestrictedModule
fields = "__all__"
class UserRestrictedModuleViewSet(EssentialModuleViewSet):
serializer_class = UserRestrictedModuleSerializer
...@@ -14,6 +14,7 @@ from backend_app.models.countryTaggedItem import CountryTaggedItemViewSet ...@@ -14,6 +14,7 @@ from backend_app.models.countryTaggedItem import CountryTaggedItemViewSet
from backend_app.models.courseFeedback import CourseFeedbackViewSet from backend_app.models.courseFeedback import CourseFeedbackViewSet
from backend_app.models.currency import CurrencyViewSet from backend_app.models.currency import CurrencyViewSet
from backend_app.models.department import DepartmentViewSet from backend_app.models.department import DepartmentViewSet
from backend_app.models.exchangeFeedback import ExchangeFeedbackViewSet
from backend_app.models.for_testing.moderation import ForTestingModerationViewSet from backend_app.models.for_testing.moderation import ForTestingModerationViewSet
from backend_app.models.for_testing.versioning import ForTestingVersioningViewSet from backend_app.models.for_testing.versioning import ForTestingVersioningViewSet
from backend_app.models.offer import OfferViewSet from backend_app.models.offer import OfferViewSet
...@@ -21,9 +22,6 @@ from backend_app.models.pendingModeration import ( ...@@ -21,9 +22,6 @@ from backend_app.models.pendingModeration import (
PendingModerationViewSet, PendingModerationViewSet,
PendingModerationObjViewSet, PendingModerationObjViewSet,
) )
from backend_app.models.exchangeFeedback import ExchangeFeedbackViewSet
from backend_app.models.recommendation import RecommendationViewSet
from backend_app.models.recommendationList import RecommendationListViewSet
from backend_app.models.specialty import SpecialtyViewSet from backend_app.models.specialty import SpecialtyViewSet
from backend_app.models.tag import TagViewSet from backend_app.models.tag import TagViewSet
from backend_app.models.university import UniversityViewSet from backend_app.models.university import UniversityViewSet
...@@ -56,8 +54,6 @@ ALL_API_VIEWSETS = [ ...@@ -56,8 +54,6 @@ ALL_API_VIEWSETS = [
PendingModerationViewSet, PendingModerationViewSet,
PendingModerationObjViewSet, PendingModerationObjViewSet,
ExchangeFeedbackViewSet, ExchangeFeedbackViewSet,
RecommendationViewSet,
RecommendationListViewSet,
SpecialtyViewSet, SpecialtyViewSet,
TagViewSet, TagViewSet,
UniversityViewSet, UniversityViewSet,
......
...@@ -178,11 +178,12 @@ AUTH_PASSWORD_VALIDATORS = [ ...@@ -178,11 +178,12 @@ AUTH_PASSWORD_VALIDATORS = [
] ]
LOGIN_URL = "/user/login" LOGIN_URL = "/user/login"
LOGIN_EXEMPT_URLS = [LOGIN_URL, "/admin/"] LOGIN_EXEMPT_URLS = [LOGIN_URL]
if TESTING: if TESTING:
# In a testing environment we want to by pass the loginRequiredMiddleware # In a testing environment we may want to by pass the loginRequiredMiddleware
LOGIN_EXEMPT_URLS.append("api") LOGIN_EXEMPT_URLS.append("api")
LOGIN_EXEMPT_URLS.append("/admin/")
SESSION_EXPIRE_AT_BROWSER_CLOSE = True SESSION_EXPIRE_AT_BROWSER_CLOSE = True
......
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