expephalon-smsotp/core/views/profiles.py
Klaus-Uwe Mitterer 53780751d1 Preparing files for admin profiles
Changing File models to allow user association
2020-04-16 15:22:03 +02:00

47 lines
1.6 KiB
Python

from django.conf import settings
from django.views.generic import FormView, ListView, DeleteView
from django.urls import reverse_lazy
from django.contrib.auth import get_user_model
from core.models import AdminProfile
class AdminListView(ListView):
template_name = f"{settings.EXPEPHALON_BACKEND}/profiles/index.html"
model = AdminProfile
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["title"] = "Administrator Users"
return context
class AdminEditView(FormView):
template_name = f"{settings.EXPEPHALON_BACKEND}/profiles/update.html"
model = get_user_model()
success_url = reverse_lazy("dbsettings")
fields = ["key", "value"]
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["title"] = "Edit Setting"
return context
class AdminDeleteView(DeleteView):
template_name = f"{settings.EXPEPHALON_BACKEND}/profiles/delete.html"
model = get_user_model()
success_url = reverse_lazy("dbsettings")
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["title"] = "Delete Administrator"
return context
class AdminCreateView(FormView):
template_name = f"{settings.EXPEPHALON_BACKEND}/profiles/create.html"
model = get_user_model()
success_url = reverse_lazy("dbsettings")
fields = ["key", "value"]
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["title"] = "Create Setting"
return context