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
|
2020-06-10 11:43:14 +00:00
|
|
|
title = "Currency Settings"
|
2020-06-03 10:35:23 +00:00
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
2020-06-10 11:43:14 +00:00
|
|
|
context["base_currency"] = Currency.get_base()
|
2020-06-03 10:35:23 +00:00
|
|
|
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"]
|
2020-06-10 11:43:14 +00:00
|
|
|
title = "Edit Currency"
|
2020-06-03 10:35:23 +00:00
|
|
|
|
|
|
|
class CurrencyDeleteView(BackendDeleteView):
|
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/currencies/delete.html"
|
|
|
|
model = Currency
|
|
|
|
success_url = reverse_lazy("currencies")
|
2020-06-10 11:43:14 +00:00
|
|
|
title = "Delete Currency"
|
2020-06-03 10:35:23 +00:00
|
|
|
|
|
|
|
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"]
|
2020-06-10 11:43:14 +00:00
|
|
|
title = "Create Currency"
|