Commit 18f683f8 authored by Florent Chehab's avatar Florent Chehab

Revomed API modules that summurized data

parent c7a149a0
from .campus import Campus, CampusViewSet, CampusSerializer, MainCampusViewSet # noqa: F401
from .campusTaggedItem import CampusTaggedItem, CampusTaggedItemSerializer, CampusTaggedItemViewSet # noqa: F401
from .campusModulesAPI import CampusModulesViewSet # noqa: F401
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 .city import City, CitySerializer, CityViewSet # noqa: F401
from .cityTaggedItem import CityTaggedItem, CityTaggedItemSerializer, CityTaggedItemViewSet # noqa: F401
from .cityModulesAPI import CityModulesViewSet # noqa: F401
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
......@@ -2,4 +2,3 @@ from .country import Country, CountrySerializer, CountryViewSet # 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 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
......@@ -5,4 +5,3 @@ from .universityDri import UniversityDri, UniversityDriSerializer, UniversityDri
from .universityInfo import UniversityInfo, UniversityInfoSerializer, UniversityInfoViewSet # noqa: F401
from .universitySemestersDates import UniversitySemestersDates, UniversitySemestersDatesSerializer, UniversitySemestersDatesViewSet # noqa: F401
from .universityTaggedItem import UniversityTaggedItem, UniversityTaggedItemSerializer, UniversityTaggedItemViewSet # noqa: F401
from .universityModulesAPI import UniversityModulesViewSet # noqa: F401
from backend.models.university import University
from backend.models.campus import CampusSerializer
from backend.models.university import UniversityDriSerializer
from backend.models.university import UniversityInfoSerializer
from backend.models.university import UniversityScholarshipSerializer
from backend.models.university import UniversitySemestersDatesSerializer
from backend.models.university import UniversityTaggedItemSerializer
from backend.models.abstract.my_model import MyModelSerializer, MyModelViewSet
from backend.utils import get_viewset_permissions
class UniversityModulesSerializer(MyModelSerializer):
university_campuses = CampusSerializer(many=True, read_only=True)
university_scholarships = UniversityScholarshipSerializer(
many=True, read_only=True)
university_tagged_items = UniversityTaggedItemSerializer(
many=True, read_only=True)
university_dri = UniversityDriSerializer(many=True, read_only=True)
university_info = UniversityInfoSerializer(read_only=True)
university_semesters_dates = UniversitySemestersDatesSerializer(
read_only=True)
class Meta:
model = University
fields = '__all__'
class UniversityModulesViewSet(MyModelViewSet):
permission_classes = get_viewset_permissions("UniversityModulesViewSet")
serializer_class = UniversityModulesSerializer
queryset = University.objects.all()
LIST_SHOULD_BE_DETAIL = True
def extend_queryset(self):
univ_id = self.kwargs['univ_id']
return self.my_model_queryset.filter(pk=univ_id).prefetch_related(
'university_campuses',
'university_dri',
'university_info',
'university_scholarships',
'university_semesters_dates',
'university_tagged_items'
) # pylint: disable=E1101
......@@ -174,37 +174,6 @@
viewset_permission: IsDriOrReadOnly
versionned: true
- model: null
viewset: UniversityModulesViewSet
import_location: university
api_end_point: universityAll
api_attr: (?P<univ_id>[0-9]+)
api_name: university_details
read_only: true
- model: null
viewset: CountryModulesViewSet
import_location: country
api_end_point: countryAll
api_attr: (?P<country_id>[a-zA-Z]+)
api_name: country_details
read_only: true
- model: null
viewset: CityModulesViewSet
import_location: city
api_end_point: cityAll
api_attr: (?P<city_id>[0-9]+)
api_name: city_details
read_only: true
- model: null
viewset: CampusModulesViewSet
import_location: campus
api_end_point: campusAll
api_attr: (?P<campus_id>[0-9]+)
api_name: campus_details
read_only: true
- model: CampusTaggedItem
......
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