|
@@ -18,7 +18,7 @@ def index(request):
|
|
def upload(request):
|
|
def upload(request):
|
|
return render(request, 'gps_logger/upload.html')
|
|
return render(request, 'gps_logger/upload.html')
|
|
|
|
|
|
-class MarkerCreateView(View, PermissionRequiredMixin):
|
|
|
|
|
|
+class MarkerCreateView(PermissionRequiredMixin, View):
|
|
permission_required = ("gps-logger.markers.change")
|
|
permission_required = ("gps-logger.markers.change")
|
|
|
|
|
|
def post(self, request):
|
|
def post(self, request):
|
|
@@ -54,12 +54,7 @@ class MarkerCreateView(View, PermissionRequiredMixin):
|
|
oldMarkers.delete()
|
|
oldMarkers.delete()
|
|
Marker.objects.bulk_create(objects)
|
|
Marker.objects.bulk_create(objects)
|
|
|
|
|
|
- locations = CensoredLocation.objects.all()
|
|
|
|
- for location in locations:
|
|
|
|
- censor_count += location.delete_markers()
|
|
|
|
-
|
|
|
|
- if(cache.get('markers')):
|
|
|
|
- cache.delete('markers')
|
|
|
|
|
|
+ censor_count = censor()
|
|
|
|
|
|
return JsonResponse({
|
|
return JsonResponse({
|
|
'censored': censor_count,
|
|
'censored': censor_count,
|
|
@@ -82,13 +77,17 @@ def marker_view(request):
|
|
cache.set('markers', data, 3600*24)
|
|
cache.set('markers', data, 3600*24)
|
|
return HttpResponse(data, content_type='application/json')
|
|
return HttpResponse(data, content_type='application/json')
|
|
|
|
|
|
-class DeleteCensoredView(View, PermissionRequiredMixin):
|
|
|
|
- permission_required = ("gps-logger.markers.change")
|
|
|
|
|
|
+class DeleteCensoredView(PermissionRequiredMixin, View):
|
|
|
|
+ permission_required = ("gps-logger.markers.change",)
|
|
def get(self, request):
|
|
def get(self, request):
|
|
- counter = 0
|
|
|
|
- locations = CensoredLocation.objects.all()
|
|
|
|
- for location in locations:
|
|
|
|
- counter += location.delete_markers()
|
|
|
|
- if(cache.get('markers')):
|
|
|
|
- cache.delete('markers')
|
|
|
|
- return JsonResponse({'censored': counter})
|
|
|
|
|
|
+ counter = censor()
|
|
|
|
+ return JsonResponse({'censored': counter})
|
|
|
|
+
|
|
|
|
+def censor() -> int:
|
|
|
|
+ counter = 0
|
|
|
|
+ locations = CensoredLocation.objects.all()
|
|
|
|
+ for location in locations:
|
|
|
|
+ counter += location.delete_markers()
|
|
|
|
+ if(cache.get('markers')):
|
|
|
|
+ cache.delete('markers')
|
|
|
|
+ return counter
|