2019-07-26 17:36:03 +00:00
|
|
|
from django.shortcuts import render
|
|
|
|
from django.views.generic import View
|
2019-08-14 21:56:05 +00:00
|
|
|
from django.http.response import JsonResponse
|
2019-08-16 16:46:09 +00:00
|
|
|
from django_coreprotect.gui import gui_data, gui_results
|
|
|
|
from django_coreprotect.activity import activity_data, activity_results
|
|
|
|
from django_coreprotect.utils import safe_int
|
2019-07-26 17:36:03 +00:00
|
|
|
|
|
|
|
|
2019-08-16 16:46:09 +00:00
|
|
|
class GUI(View):
|
2019-07-27 03:22:29 +00:00
|
|
|
|
|
|
|
def get(self, request):
|
2019-08-16 16:46:09 +00:00
|
|
|
form = gui_data(request)
|
2019-08-14 21:56:05 +00:00
|
|
|
return render(request, "coreprotect/coreprotect.html", {"form": form})
|
|
|
|
|
|
|
|
def post(self, request):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2019-08-16 16:46:09 +00:00
|
|
|
class GUIQuery(View):
|
2019-08-14 21:56:05 +00:00
|
|
|
|
|
|
|
def get(self, request):
|
2019-08-16 16:46:09 +00:00
|
|
|
form = gui_data(request)
|
|
|
|
results = gui_results(form)
|
2019-08-14 21:56:05 +00:00
|
|
|
|
|
|
|
if "format" in request.GET and request.GET["format"] == "json":
|
|
|
|
return JsonResponse(results)
|
|
|
|
|
2019-08-15 22:00:54 +00:00
|
|
|
prev_page, next_page = False, False
|
2019-08-16 03:59:43 +00:00
|
|
|
if safe_int(form.page) > 0:
|
2019-08-15 22:00:54 +00:00
|
|
|
prev_page = True
|
2019-08-16 03:59:43 +00:00
|
|
|
if len(results) == safe_int(form.page_size):
|
2019-08-15 22:00:54 +00:00
|
|
|
next_page = True
|
|
|
|
|
2019-08-16 16:46:09 +00:00
|
|
|
return render(request, "coreprotect/table/coreprotect.html", {"results": results, "num": len(results), "prev": prev_page, "next": next_page})
|
2019-07-27 03:22:29 +00:00
|
|
|
|
|
|
|
def post(self, request):
|
|
|
|
pass
|
2019-08-16 16:46:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Activity(View):
|
|
|
|
|
|
|
|
def get(self, request):
|
|
|
|
form = activity_data(request)
|
|
|
|
return render(request, "coreprotect/activity.html", {"form": form})
|
|
|
|
|
|
|
|
def post(self, request):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class ActivityQuery(View):
|
|
|
|
|
|
|
|
def get(self, request):
|
|
|
|
form = activity_data(request)
|
|
|
|
results = activity_results(form)
|
|
|
|
|
|
|
|
if "format" in request.GET and request.GET["format"] == "json":
|
|
|
|
return JsonResponse(results)
|
|
|
|
|
|
|
|
return render(request, "coreprotect/table/activity.html", {"results": results})
|
|
|
|
|
|
|
|
def post(self, request):
|
|
|
|
pass
|
|
|
|
|