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})