示例#1
0
class CountryReportViewSet(viewsets.ModelViewSet):
    permission_classes = (Or(IsAuthenticated,
                             get_guest_permissions_class(['list',
                                                          'retrieve'])), )
    serializer_class = CountryReportSerializer
    queryset = CountryReport.objects.all()

    def list(self, request, *args, **kwargs):
        queryset = CountryReport.objects.all()
        serializer = CountryReportSerializer(queryset, many=True)
        return Response(serializer.data)

    def retrieve(self, request, pk=None, *args, **kwargs):
        queryset = CountryReport.objects.all()
        countryreport = get_object_or_404(queryset, pk=pk)
        serializer = CountryReportRetrieveSerializer(countryreport)
        return Response(serializer.data)
示例#2
0
class SectionViewSet(viewsets.ModelViewSet):
    queryset = Section.objects.filter(parent=None)
    permission_classes = (Or(IsAuthenticated,
                             get_guest_permissions_class(['list',
                                                          'retrieve'])), )
    serializer_class = SectionSerializer
示例#3
0
class MapPointViewSet(viewsets.ModelViewSet):
    permission_classes = (Or(IsAuthenticated,
                             get_guest_permissions_class(['list',
                                                          'retrieve'])), )
    queryset = MapPoint.objects.all()
    serializer_class = MapPointSerializer