2020-04-15 20:19:03 +00:00
|
|
|
from django.conf import settings
|
|
|
|
from django.views.generic import ListView, UpdateView, DeleteView, CreateView
|
|
|
|
from django.urls import reverse_lazy
|
|
|
|
|
|
|
|
try:
|
|
|
|
from dbsettings.models import Setting
|
|
|
|
|
|
|
|
class DBSettingsListView(ListView):
|
2020-04-15 20:43:40 +00:00
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/dbsettings/index.html"
|
2020-04-15 20:19:03 +00:00
|
|
|
model = Setting
|
|
|
|
|
2020-04-16 09:02:22 +00:00
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context["title"] = "Database Settings"
|
|
|
|
return context
|
|
|
|
|
2020-04-15 20:19:03 +00:00
|
|
|
class DBSettingsEditView(UpdateView):
|
2020-04-15 20:43:40 +00:00
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/dbsettings/update.html"
|
2020-04-15 20:19:03 +00:00
|
|
|
model = Setting
|
|
|
|
success_url = reverse_lazy("dbsettings")
|
|
|
|
fields = ["key", "value"]
|
2020-04-16 09:02:22 +00:00
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context["title"] = "Edit Setting"
|
|
|
|
return context
|
2020-04-15 20:19:03 +00:00
|
|
|
|
|
|
|
class DBSettingsDeleteView(DeleteView):
|
2020-04-15 20:43:40 +00:00
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/dbsettings/delete.html"
|
2020-04-15 20:19:03 +00:00
|
|
|
model = Setting
|
|
|
|
success_url = reverse_lazy("dbsettings")
|
|
|
|
|
2020-04-16 09:02:22 +00:00
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context["title"] = "Delete Setting"
|
|
|
|
return context
|
|
|
|
|
2020-04-15 20:19:03 +00:00
|
|
|
class DBSettingsCreateView(CreateView):
|
2020-04-15 20:43:40 +00:00
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/dbsettings/create.html"
|
2020-04-15 20:19:03 +00:00
|
|
|
model = Setting
|
|
|
|
success_url = reverse_lazy("dbsettings")
|
|
|
|
fields = ["key", "value"]
|
|
|
|
|
2020-04-16 09:02:22 +00:00
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context["title"] = "Create Setting"
|
|
|
|
return context
|
|
|
|
|
2020-04-15 20:19:03 +00:00
|
|
|
except ModuleNotFoundError:
|
|
|
|
pass
|