|
@@ -1,10 +1,28 @@
|
|
|
from django.shortcuts import render
|
|
|
+from django.contrib.auth.decorators import permission_required
|
|
|
+from django.contrib.auth.mixins import PermissionRequiredMixin
|
|
|
+from rest_framework import generics
|
|
|
+
|
|
|
from .models import *
|
|
|
+from .serializers import MarkerSerializer
|
|
|
|
|
|
|
|
|
def index(request):
|
|
|
+ return render(request, 'gps_logger/index.html')
|
|
|
+
|
|
|
+@permission_required("gps-logger.markers.change")
|
|
|
+def upload(request):
|
|
|
+ return render(request, 'gps_logger/upload.html')
|
|
|
+
|
|
|
+class MarkerCreateView(generics.CreateAPIView, PermissionRequiredMixin):
|
|
|
+ serializer_class = MarkerSerializer
|
|
|
+ permission_required = ("gps-logger.markers.change")
|
|
|
+ def get_serializer(self, *args, **kwargs):
|
|
|
+ if isinstance(kwargs.get("data", {}), list):
|
|
|
+ kwargs["many"] = True
|
|
|
+
|
|
|
+ return super(MarkerCreateView, self).get_serializer(*args, **kwargs)
|
|
|
|
|
|
- context = {
|
|
|
-
|
|
|
- }
|
|
|
- return render(request, 'gps_logger/index.html', context)
|
|
|
+class MarkerView(generics.ListAPIView):
|
|
|
+ serializer_class = MarkerSerializer
|
|
|
+ queryset = Marker.objects
|