Commit a938e15d authored by Florent Chehab's avatar Florent Chehab
Browse files

Merge branch 'clean_backend' into 'master'

Clean backend

See merge request chehabfl/outgoing_rex!35
parents 9e62f092 92f591e0
from django.db import models
from backend.models.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.abstract.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.currency import Currency
from rest_framework import serializers
from django.core.validators import MinValueValidator
......
from .taggedItem import TaggedItem, TaggedItemSerializer, TaggedItemViewSet # noqa: F401
from django.db import models
from backend.models.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from .tag import Tag
from backend.models.abstract.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.tag import Tag
from backend.validators.tag import tagged_item_validation
from backend.models.tools import JSONField
from backend.fields import JSONField
class TaggedItem(BasicModule):
......@@ -22,4 +22,4 @@ class TaggedItemSerializer(BasicModuleSerializer):
class TaggedItemViewSet(BasicModuleViewSet):
def extend_queryset(self):
return self.mymodel_queryset.prefetch_related('tag')
return self.my_model_queryset.prefetch_related('tag')
from .campus import Campus, CampusViewSet, CampusSerializer, MainCampusViewSet # noqa: F401
from .campusTaggedItem import CampusTaggedItem, CampusTaggedItemSerializer, CampusTaggedItemViewSet # noqa: F401
from .campusModulesAPI import CampusModulesViewSet # noqa: F401
from django.db import models
from backend.models.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.abstract.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.city import City
from backend.models.university import University
from django.core.validators import MinValueValidator, MaxValueValidator
......@@ -14,7 +14,7 @@ class Campus(BasicModule):
comment = models.TextField(null=True, blank=True)
city = models.ForeignKey(City, on_delete=models.PROTECT, null=False)
university = models.ForeignKey(
University, on_delete=models.PROTECT, null=False, related_name="univ_campus")
University, on_delete=models.PROTECT, null=False, related_name="university_campuses")
lat = models.DecimalField(
max_digits=10,
......
from backend.models.campus import Campus
from backend.models.campus import CampusTaggedItemSerializer
from backend.models.abstract.my_model import MyModelSerializer, MyModelViewSet
from backend.utils import get_viewset_permissions
class CampusModulesSerializer(MyModelSerializer):
campus_tagged_items = CampusTaggedItemSerializer(
many=True, read_only=True)
class Meta:
model = Campus
fields = '__all__'
class CampusModulesViewSet(MyModelViewSet):
permission_classes = get_viewset_permissions("CampusModulesViewSet")
serializer_class = CampusModulesSerializer
queryset = Campus.objects.all()
LIST_SHOULD_BE_DETAIL = True
def extend_queryset(self):
campus_id = self.kwargs['campus_id']
return self.my_model_queryset.filter(pk=campus_id).prefetch_related(
'campus_tagged_items'
) # pylint: disable=E1101
from django.db import models
from backend.models.campus import Campus
from backend.models.tag import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend.models.abstract.taggedItem import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend.utils import get_model_config, get_viewset_permissions
class CampusTaggedItem(TaggedItem):
model_config = get_model_config("CampusTaggedItem")
campus = models.OneToOneField(
Campus, on_delete=models.PROTECT, related_name='city_items', primary_key=True)
campus = models.ForeignKey(
Campus, on_delete=models.PROTECT, related_name='campus_tagged_items')
@classmethod
def get_serializer(cls):
......
from .city import City, CitySerializer, CityViewSet # noqa: F401
from .cityTaggedItem import CityTaggedItem, CityTaggedItemSerializer, CityTaggedItemViewSet # noqa: F401
from .cityModulesAPI import CityModulesViewSet # noqa: F401
from django.db import models
from backend.models.country import Country
from backend.models.my_model import MyModel, MyModelSerializer, MyModelVersionnedViewSet
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelVersionnedViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
from backend.models.city import City
from backend.models.city import CityTaggedItemSerializer
from backend.models.abstract.my_model import MyModelSerializer, MyModelViewSet
from backend.utils import get_viewset_permissions
class CityModulesSerializer(MyModelSerializer):
city_tagged_items = CityTaggedItemSerializer(
many=True, read_only=True)
class Meta:
model = City
fields = '__all__'
class CityModulesViewSet(MyModelViewSet):
permission_classes = get_viewset_permissions("CityModulesViewSet")
serializer_class = CityModulesSerializer
queryset = City.objects.all()
LIST_SHOULD_BE_DETAIL = True
def extend_queryset(self):
city_id = self.kwargs['city_id']
return self.my_model_queryset.filter(pk=city_id).prefetch_related(
'city_tagged_items'
) # pylint: disable=E1101
from django.db import models
from backend.models.tag import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend.models.abstract.taggedItem import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend.models.city import City
from backend.utils import get_model_config, get_viewset_permissions
......@@ -7,8 +7,8 @@ from backend.utils import get_model_config, get_viewset_permissions
class CityTaggedItem(TaggedItem):
model_config = get_model_config("CityTaggedItem")
city = models.OneToOneField(
City, on_delete=models.PROTECT, related_name='city_items', primary_key=True)
city = models.ForeignKey(
City, on_delete=models.PROTECT, related_name='city_tagged_items')
@classmethod
def get_serializer(cls):
......
from .country import Country, CountrySerializer, CountryViewSet # noqa: F401
from .countryScholarship import CountryScholarship, CountryScholarshipViewSet # noqa: F401
from .countryDri import CountryDri, CountryDriViewSet # noqa: F401
from .countryScholarship import CountryScholarship, CountryScholarshipSerializer, CountryScholarshipViewSet # noqa: F401
from .countryDri import CountryDri, CountryDriSerializer, CountryDriViewSet # noqa: F401
from .countryTaggedItem import CountryTaggedItem, CountryTaggedItemSerializer, CountryTaggedItemViewSet # noqa: F401
from .countryModulesAPI import CountryModulesViewSet # noqa: F401
from django.db import models
from backend.models.my_model import MyModel, MyModelSerializer, MyModelVersionnedViewSet
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelVersionnedViewSet
from backend.utils import get_model_config, get_viewset_permissions
# Data model based on : https://unstats.un.org/unsd/methodology/m49/overview/
......
from django.db import models
from backend.models.country import Country
from backend.models.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.models.abstract.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
from backend.models.country import Country
from backend.models.country import CountryDriSerializer
from backend.models.country import CountryScholarshipSerializer
from backend.models.country import CountryTaggedItemSerializer
from backend.models.abstract.my_model import MyModelSerializer, MyModelViewSet
from backend.utils import get_viewset_permissions
class CountryModulesSerializer(MyModelSerializer):
country_scholarships = CountryScholarshipSerializer(
many=True, read_only=True)
country_tagged_items = CountryTaggedItemSerializer(
many=True, read_only=True)
country_dri = CountryDriSerializer(many=True, read_only=True)
class Meta:
model = Country
fields = '__all__'
class CountryModulesViewSet(MyModelViewSet):
permission_classes = get_viewset_permissions("CountryModulesViewSet")
serializer_class = CountryModulesSerializer
queryset = Country.objects.all()
LIST_SHOULD_BE_DETAIL = True
def extend_queryset(self):
country_id = self.kwargs['country_id']
return self.my_model_queryset.filter(pk=country_id).prefetch_related(
'country_dri',
'country_scholarships',
'country_tagged_items'
) # pylint: disable=E1101
from django.db import models
from backend.models.country import Country
from backend.models.scholarship import Scholarship, ScholarshipSerializer, ScholarshipViewSet
from backend.models.abstract.scholarship import Scholarship, ScholarshipSerializer, ScholarshipViewSet
from backend.utils import get_model_config, get_viewset_permissions
class CountryScholarship(Scholarship):
model_config = get_model_config("CountryScholarship")
country = models.ManyToManyField(
Country, related_name="country_scholarhip")
Country, related_name="country_scholarships")
@classmethod
def get_serializer(cls):
......
from django.db import models
from backend.models.tag import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend.models.abstract.taggedItem import TaggedItem, TaggedItemSerializer, TaggedItemViewSet
from backend.models.country import Country
from backend.utils import get_model_config, get_viewset_permissions
class CountryTaggedItem(TaggedItem):
model_config = get_model_config("CountryTaggedItem")
country = models.OneToOneField(
Country, on_delete=models.PROTECT, related_name='country_items', primary_key=True)
country = models.ForeignKey(
Country, on_delete=models.PROTECT, related_name='country_tagged_items')
@classmethod
def get_serializer(cls):
......
from django.db import models
from django.core.validators import MinValueValidator
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
from django.db import models
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
from django.db import models
from backend.models.university import University
from backend.models.other_core import Semester, Specialty
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.utils import get_model_config, get_viewset_permissions
......
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