2020-06-03 10:35:23 +00:00
|
|
|
from django.conf import settings
|
|
|
|
from django.urls import reverse_lazy
|
|
|
|
|
|
|
|
from core.models.local import Currency
|
2020-06-03 15:05:18 +00:00
|
|
|
from core.views.backend.generic import BackendListView, BackendUpdateView, BackendDeleteView, BackendCreateView
|
2020-06-03 10:35:23 +00:00
|
|
|
|
|
|
|
class CurrencyListView(BackendListView):
|
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/currencies/index.html"
|
|
|
|
model = Currency
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context["title"] = "Currency Settings"
|
|
|
|
return context
|
|
|
|
|
|
|
|
class CurrencyEditView(BackendUpdateView):
|
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/currencies/update.html"
|
|
|
|
model = Currency
|
|
|
|
success_url = reverse_lazy("currencies")
|
|
|
|
fields = ["name", "code", "symbol", "base", "rate"]
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context["title"] = "Edit Currency"
|
|
|
|
return context
|
|
|
|
|
|
|
|
class CurrencyDeleteView(BackendDeleteView):
|
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/currencies/delete.html"
|
|
|
|
model = Currency
|
|
|
|
success_url = reverse_lazy("currencies")
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context["title"] = "Delete Currency"
|
|
|
|
return context
|
|
|
|
|
|
|
|
class CurrencyCreateView(BackendCreateView):
|
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/currencies/create.html"
|
|
|
|
model = Currency
|
|
|
|
success_url = reverse_lazy("currencies")
|
|
|
|
fields = ["name", "code", "symbol", "base", "rate"]
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context["title"] = "Create Currency"
|
|
|
|
return context
|