Commit 7427179e authored by Florent Chehab's avatar Florent Chehab
Browse files

prepared move to model_config

parent ac56d059
Pipeline #26851 passed with stages
in 2 minutes and 25 seconds
from django.db import models
from backend.models.my_model import MyModel
from backend.utils.friendly_path import friendly_path
from backend.utils import get_moderation_level
from backend.utils import get_model_config
path_and_rename = friendly_path("uploads/universities/logos/", 'name')
......@@ -10,7 +10,7 @@ class University(MyModel):
"""
Model storing information about universities
"""
moderation_level = get_moderation_level("University")
model_config = get_model_config("University")
name = models.CharField(max_length=200)
acronym = models.CharField(max_length=20, null=True, blank=True)
......
from django.db import models
from backend.models.university import University
from backend.models.module import DriRestrictedModule, DriRestrictedModuleSerializer, DriRestrictedModuleViewSet
from backend.utils import get_moderation_level, get_viewset_permissions
from backend.utils import get_model_config, get_viewset_permissions
class UniversityDri(DriRestrictedModule):
moderation_level = get_moderation_level("UniversityDri")
model_config = get_model_config("UniversityDri")
university = models.ManyToManyField(
University, related_name="university_dri")
......
......@@ -3,11 +3,11 @@ from backend.models.module import BasicModule, BasicModuleSerializer, BasicModul
from backend.models.university import University
from backend.models.location import Currency
from django.core.validators import MinValueValidator
from backend.utils import get_moderation_level, get_viewset_permissions
from backend.utils import get_model_config, get_viewset_permissions
class UniversityInfo(BasicModule):
moderation_level = get_moderation_level("UniversityInfo")
model_config = get_model_config("UniversityInfo")
university = models.OneToOneField(
University, on_delete=models.CASCADE, related_name='university_info', primary_key=True, null=False)
......
from django.db import models
from backend.models.university import University
from backend.models.module import Scholarship, ScholarshipSerializer, ScholarshipViewSet
from backend.utils import get_moderation_level, get_viewset_permissions
from backend.utils import get_model_config, get_viewset_permissions
class UniversityScholarship(Scholarship):
moderation_level = get_moderation_level("UniversityScholarship")
model_config = get_model_config("UniversityScholarship")
university = models.ForeignKey(
University, on_delete=models.PROTECT, null=False, related_name="univScholarship")
......
......@@ -2,7 +2,7 @@ from django.db import models
from backend.models.module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.university import University
from rest_framework import serializers
from backend.utils import get_moderation_level, get_viewset_permissions
from backend.utils import get_model_config, get_viewset_permissions
def check_nones(val1, val2):
......@@ -16,7 +16,7 @@ def check_nones(val1, val2):
class UniversitySemestersDates(BasicModule):
moderation_level = get_moderation_level("UniversitySemestersDates")
model_config = get_model_config("UniversitySemestersDates")
university = models.OneToOneField(
University, on_delete=models.CASCADE, related_name='university_semesters_dates', primary_key=True, null=False)
......
from django.db import models
from backend.models.tag import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend.models.university import University
from backend.utils import get_moderation_level, get_viewset_permissions
from backend.utils import get_model_config, get_viewset_permissions
class UniversityTaggedItem(TaggedItem):
moderation_level = get_moderation_level("UniversityTaggedItem")
model_config = get_model_config("UniversityTaggedItem")
university = models.OneToOneField(
University, on_delete=models.PROTECT, related_name='city_items', primary_key=True)
......
......@@ -5,11 +5,11 @@ from backend.models.university import University
from django.contrib.auth.models import User
from django.contrib.postgres.fields import JSONField
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.utils import get_moderation_level, get_viewset_permissions
from backend.utils import get_model_config, get_viewset_permissions
class PreviousDeparture(MyModel):
moderation_level = get_moderation_level("PreviousDeparture")
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)
......
......@@ -4,11 +4,11 @@ from django.core.validators import MaxValueValidator
from backend.models.user import UserRestrictedModule, UserRestrictedModuleSerializer, UserRestrictedModuleViewSet
from backend.models.user import PreviousDeparture
from django.contrib.postgres.fields import JSONField
from backend.utils import get_moderation_level, get_viewset_permissions
from backend.utils import get_model_config, get_viewset_permissions
class PreviousDepartureFeedback(UserRestrictedModule):
moderation_level = get_moderation_level("Country")
model_config = get_model_config("Country")
departure = models.OneToOneField(
PreviousDeparture, on_delete=models.CASCADE)
......
......@@ -6,11 +6,11 @@ from backend.models.user import UserRestrictedModule, UserRestrictedModuleSerial
from backend.models.other_core import Specialty
from backend.models.user import RecommendationList
from backend.utils import get_moderation_level, get_viewset_permissions
from backend.utils import get_model_config, get_viewset_permissions
class Recommendation(UserRestrictedModule):
moderation_level = get_moderation_level("Recommendation")
model_config = get_model_config("Recommendation")
university = models.ForeignKey(University, on_delete=models.PROTECT)
parent_list = models.ForeignKey(
RecommendationList, on_delete=models.PROTECT, related_name='recommendations')
......
from django.db import models
from backend.models.user import UserRestrictedModule, UserRestrictedModuleSerializer, UserRestrictedModuleViewSet
from backend.utils import get_moderation_level, get_viewset_permissions
from backend.utils import get_model_config, get_viewset_permissions
class RecommendationList(UserRestrictedModule):
moderation_level = get_moderation_level("RecommendationList")
model_config = get_model_config("RecommendationList")
public = models.BooleanField()
title = models.CharField(max_length=200)
......
......@@ -4,11 +4,11 @@ from backend.models.university import University
from django.contrib.postgres.fields import JSONField
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from django.contrib.auth.models import User
from backend.utils import get_viewset_permissions, get_moderation_level
from backend.utils import get_viewset_permissions, get_model_config
class UserData(MyModel):
moderation_level = get_moderation_level("UserData")
model_config = get_model_config("UserData")
owner = models.OneToOneField(User, on_delete=models.CASCADE)
contact_info = JSONField(default=dict)
......
from .is_member import is_member # noqa: F401
from .file import read_file, write_file # noqa: F401
from .find_api_end_point_for_viewset import find_api_end_point_for_viewset # noqa: F401
from .get_moderation_level import get_moderation_level # noqa: F401
from .get_model_config import get_model_config # noqa: F401
from .get_viewset_permissions import get_viewset_permissions # noqa: F401
from .does_user_have_moderation_rights import does_user_have_moderation_rights # noqa: F401
......@@ -2,7 +2,7 @@ import yaml
from os.path import join, realpath, dirname
def get_moderation_level(model):
def get_model_config(model):
current_dir = dirname(realpath(__file__))
api_file_loc = join(current_dir, '../../general/api/api_config.yml')
with open(api_file_loc, "r") as file:
......
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