36 lines
972 B
Python
36 lines
972 B
Python
from django.shortcuts import render
|
|
from django.views.generic import View
|
|
from django.http.response import JsonResponse
|
|
from django_coreprotect.forms import *
|
|
|
|
|
|
class Home(View):
|
|
|
|
def get(self, request):
|
|
form = form_data(request)
|
|
return render(request, "coreprotect/coreprotect.html", {"form": form})
|
|
|
|
def post(self, request):
|
|
pass
|
|
|
|
|
|
class Query(View):
|
|
|
|
def get(self, request):
|
|
form = form_data(request)
|
|
results = result_data(form)
|
|
|
|
if "format" in request.GET and request.GET["format"] == "json":
|
|
return JsonResponse(results)
|
|
|
|
prev_page, next_page = False, False
|
|
if safe_int(form.page) > 0:
|
|
prev_page = True
|
|
if len(results) == safe_int(form.page_size):
|
|
next_page = True
|
|
|
|
return render(request, "coreprotect/table.html", {"results": results, "num": len(results), "prev": prev_page, "next": next_page})
|
|
|
|
def post(self, request):
|
|
pass
|