Implement a hooks page
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
import uuid
|
||||
|
||||
from django.shortcuts import render
|
||||
from django.views import View
|
||||
from django.http import HttpResponseBadRequest
|
||||
|
||||
class OpenSettings(View):
|
||||
allowed_types = ["modal", "widget", "window"]
|
||||
|
||||
async def get(self, request, type):
|
||||
if type not in self.allowed_types:
|
||||
return HttpResponseBadRequest
|
||||
#template_name =
|
||||
|
||||
class DemoModal(View):
|
||||
template_name = "modals/modal.html"
|
||||
|
||||
async def get(self, request):
|
||||
return render(request, self.template_name)
|
||||
|
||||
|
||||
class DemoWidget(View):
|
||||
template_name = "widgets/widget.html"
|
||||
|
||||
async def get(self, request):
|
||||
unique = str(uuid.uuid4())[:8]
|
||||
return render(request, self.template_name, {"unique": unique})
|
||||
|
||||
|
||||
class DemoWindow(View):
|
||||
template_name = "windows/window.html"
|
||||
|
||||
async def get(self, request):
|
||||
return render(request, self.template_name)
|
||||
25
core/views/hooks.py
Normal file
25
core/views/hooks.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import uuid
|
||||
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.http import HttpResponseBadRequest
|
||||
from django.shortcuts import render
|
||||
from django.views import View
|
||||
|
||||
|
||||
class Hooks(LoginRequiredMixin, View):
|
||||
allowed_types = ["modal", "widget", "window", "page"]
|
||||
window_content = "window-content/hooks.html"
|
||||
|
||||
async def get(self, request, type):
|
||||
if type not in self.allowed_types:
|
||||
return HttpResponseBadRequest
|
||||
template_name = f"wm/{type}.html"
|
||||
unique = str(uuid.uuid4())[:8]
|
||||
hooks = [{"user": "test", "hook": "/help22", "received": "40"}]
|
||||
context = {
|
||||
"title": f"{type} Demo",
|
||||
"unique": unique,
|
||||
"window_content": self.window_content,
|
||||
"hooks": hooks,
|
||||
}
|
||||
return render(request, template_name, context)
|
||||
Reference in New Issue
Block a user