expephalon/core/views/backend/dbsettings.py

47 lines
1.6 KiB
Python
Raw Normal View History

from django.conf import settings
from django.urls import reverse_lazy
from dbsettings.models import Setting
2020-06-03 15:05:18 +00:00
from core.views.backend.generic import BackendListView, BackendUpdateView, BackendDeleteView, BackendCreateView
class DBSettingsListView(BackendListView):
template_name = f"{settings.EXPEPHALON_BACKEND}/dbsettings/index.html"
model = Setting
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["title"] = "Database Settings"
return context
class DBSettingsEditView(BackendUpdateView):
template_name = f"{settings.EXPEPHALON_BACKEND}/dbsettings/update.html"
model = Setting
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 DBSettingsDeleteView(BackendDeleteView):
template_name = f"{settings.EXPEPHALON_BACKEND}/dbsettings/delete.html"
model = Setting
success_url = reverse_lazy("dbsettings")
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["title"] = "Delete Setting"
return context
class DBSettingsCreateView(BackendCreateView):
template_name = f"{settings.EXPEPHALON_BACKEND}/dbsettings/create.html"
model = Setting
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