<commit_before>from rest_framework import viewsets
from restserver.serializers import *
from restserver.models import *
from rest_framework.response import Response
from rest_framework.decorators import detail_route, list_route

class CountryViewSet(viewsets.ModelViewSet):
    queryset = Country.objects.all()
    serializer_class = CountrySerializer
    
    # Extra method for loading cities according to the parent country
    @detail_route()
    def cities(self,request,pk=None):
        queryset = City.objects.filter(country=self.get_object())
        serializer = CitySerializer(queryset, many=True)
        return Response(serializer.data)
    
class CityViewSet(viewsets.ModelViewSet):
    queryset = City.objects.all()
    serializer_class = CitySerializer
    
class CourseViewSet(viewsets.ModelViewSet):
    queryset = Course.objects.all()
    serializer_class = CourseSerializer

class SchoolViewSet(viewsets.ModelViewSet):
    queryset = School.objects.all()
    serializer_class = SchoolSerializer
    
class SchoolCourseValueViewSet(viewsets.ModelViewSet):<commit_msg>Retrieve courses from given city<commit_after>from rest_framework import viewsets
from restserver.serializers import *
from restserver.models import *
from rest_framework.response import Response
from rest_framework.decorators import detail_route, list_route

class CountryViewSet(viewsets.ModelViewSet):
    queryset = Country.objects.all()
    serializer_class = CountrySerializer
    
    # Extra method for loading cities according to the parent country
    @detail_route()
    def cities(self,request,pk=None):
        queryset = City.objects.filter(country=self.get_object())
        serializer = CitySerializer(queryset, many=True)
        return Response(serializer.data)
    
class CityViewSet(viewsets.ModelViewSet):
    queryset = City.objects.all()
    serializer_class = CitySerializer
    
    # Load courses according to the city
    @detail_route()
    def courses(self,request,pk=None):
        queryset = SchoolCourseValue.objects.filter(school__city=self.get_object())
        # Transfer all courses from relationship to serializer
        serializer = CourseSerializer([scv.course for scv in queryset], many=True)
        return Response(serializer.data)
        
    
class CourseViewSet(viewsets.ModelViewSet):
    queryset = Course.objects.all()
    serializer_class = CourseSerializer

class SchoolViewSet(viewsets.ModelViewSet):
    queryset = School.objects.all()
    serializer_class = SchoolSerializer
    
class SchoolCourseValueViewSet(viewsets.ModelViewSet):
{'fraction_non_alphanumeric': 0.07498057498057498, 'fraction_numerical': 0.0, 'mean_word_length': 4.421052631578948, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2928639', 'n_tokens_mistral': 691, 'n_tokens_neox': 687, 'n_words': 160}