plchweb/base_app/views.py
Marcel Plch 8752197c2c
Fix sidebar
It is not entirely fixed, but it's at least generated from django data
now. Should make it fairly easier to make it behave better.
2024-11-30 01:50:45 +01:00

63 lines
1.6 KiB
Python

from django.shortcuts import render
from django.shortcuts import render, redirect
from django.views.generic import TemplateView, FormView
import json
# Helper functions
def get_domains():
domains = None
with open("data/domains.json", "r") as f:
data = f.read()
domains = json.loads(data)
return domains
# Create your views here.
class GenericView(TemplateView):
def cx_handle_get(self, request, template, *args, **kwargs):
paths = [
{"href": "/",
"name": "Home"},
{"href": "/curriculum-vitae",
"name": "Curriculum Vitae"},
{"href": "/ukraine",
"name": "Ukraine"},
]
return render(request, template, {"paths" : paths})
class IndexView(GenericView):
def get(self, request, *args, **kwargs):
paths = [
{"href": "/",
"name": "Home"},
{"href": "/curriculum-vitae",
"name": "Curriculum Vitae"},
{"href": "/ukraine",
"name": "Ukraine"},
]
return self.cx_handle_get(request, "index.html", {"paths" : paths})
class CVView(GenericView):
def get(self, request, *args, **kwargs):
return self.cx_handle_get(request, "CV.html", {})
class LoremView(GenericView):
def get(self, request, *args, **kwargs):
return self.cx_handle_get(request, "lorem.html", {})
class UkraineView(GenericView):
def get(self, request, *args, **kwargs):
domains = get_domains()
return self.cx_handle_get(request, "ukraine.html", {"domains" : domains})