Improved currency display
Implemented RedirectViews Changed URL scheme for submodules Updated kumisms and ratesapi submodules
This commit is contained in:
parent
e7feba94ae
commit
fb02819e36
8 changed files with 24 additions and 24 deletions
|
@ -1,5 +1,3 @@
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
from core.exceptions.mail import NoSuchTemplate
|
from core.exceptions.mail import NoSuchTemplate
|
||||||
|
|
||||||
from dbsettings.functions import getValue
|
from dbsettings.functions import getValue
|
||||||
|
|
|
@ -11,9 +11,9 @@ for module in settings.EXPEPHALON_MODULES:
|
||||||
mou = importlib.import_module(f"{module}.urls")
|
mou = importlib.import_module(f"{module}.urls")
|
||||||
if "ADMIN_URLS" in mou.__dict__.keys():
|
if "ADMIN_URLS" in mou.__dict__.keys():
|
||||||
for url, action, name in mou.ADMIN_URLS:
|
for url, action, name in mou.ADMIN_URLS:
|
||||||
URLPATTERNS.append(path(f'admin/modules/{module}/{url}', action, name=f"{module}_{name}"))
|
URLPATTERNS.append(path(f'admin/modules/{module}/{url}', action, name=f"module_{module}_{name}"))
|
||||||
if "API_URLS" in mou.__dict__.keys():
|
if "API_URLS" in mou.__dict__.keys():
|
||||||
for url, action, name in mou.API_URLS:
|
for url, action, name in mou.API_URLS:
|
||||||
URLPATTERNS.append(path(f"api/modules/{module}/{url}", action, name=f"api_{module}_{name}"))
|
URLPATTERNS.append(path(f"api/modules/{module}/{url}", action, name=f"api_module_{module}_{name}"))
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
from core.modules.navigation import navigations
|
from core.modules.navigation import navigations
|
||||||
from core.classes.navigation import NavSection, NavItem
|
from core.classes.navigation import NavSection, NavItem
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
# Dashboard Section
|
# Dashboard Section
|
||||||
|
|
||||||
dashboard_section = NavSection("Dashboard")
|
dashboard_section = NavSection("Dashboard")
|
||||||
|
|
|
@ -7,10 +7,11 @@ from core.views.backend.generic import BackendListView, BackendUpdateView, Backe
|
||||||
class CurrencyListView(BackendListView):
|
class CurrencyListView(BackendListView):
|
||||||
template_name = f"{settings.EXPEPHALON_BACKEND}/currencies/index.html"
|
template_name = f"{settings.EXPEPHALON_BACKEND}/currencies/index.html"
|
||||||
model = Currency
|
model = Currency
|
||||||
|
title = "Currency Settings"
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["title"] = "Currency Settings"
|
context["base_currency"] = Currency.get_base()
|
||||||
return context
|
return context
|
||||||
|
|
||||||
class CurrencyEditView(BackendUpdateView):
|
class CurrencyEditView(BackendUpdateView):
|
||||||
|
@ -18,29 +19,17 @@ class CurrencyEditView(BackendUpdateView):
|
||||||
model = Currency
|
model = Currency
|
||||||
success_url = reverse_lazy("currencies")
|
success_url = reverse_lazy("currencies")
|
||||||
fields = ["name", "code", "symbol", "base", "rate"]
|
fields = ["name", "code", "symbol", "base", "rate"]
|
||||||
|
title = "Edit Currency"
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super().get_context_data(**kwargs)
|
|
||||||
context["title"] = "Edit Currency"
|
|
||||||
return context
|
|
||||||
|
|
||||||
class CurrencyDeleteView(BackendDeleteView):
|
class CurrencyDeleteView(BackendDeleteView):
|
||||||
template_name = f"{settings.EXPEPHALON_BACKEND}/currencies/delete.html"
|
template_name = f"{settings.EXPEPHALON_BACKEND}/currencies/delete.html"
|
||||||
model = Currency
|
model = Currency
|
||||||
success_url = reverse_lazy("currencies")
|
success_url = reverse_lazy("currencies")
|
||||||
|
title = "Delete Currency"
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super().get_context_data(**kwargs)
|
|
||||||
context["title"] = "Delete Currency"
|
|
||||||
return context
|
|
||||||
|
|
||||||
class CurrencyCreateView(BackendCreateView):
|
class CurrencyCreateView(BackendCreateView):
|
||||||
template_name = f"{settings.EXPEPHALON_BACKEND}/currencies/create.html"
|
template_name = f"{settings.EXPEPHALON_BACKEND}/currencies/create.html"
|
||||||
model = Currency
|
model = Currency
|
||||||
success_url = reverse_lazy("currencies")
|
success_url = reverse_lazy("currencies")
|
||||||
fields = ["name", "code", "symbol", "base", "rate"]
|
fields = ["name", "code", "symbol", "base", "rate"]
|
||||||
|
title = "Create Currency"
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super().get_context_data(**kwargs)
|
|
||||||
context["title"] = "Create Currency"
|
|
||||||
return context
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from django.views.generic import TemplateView, ListView, CreateView, FormView, DeleteView, UpdateView
|
from django.views.generic import TemplateView, ListView, CreateView, FormView, DeleteView, UpdateView
|
||||||
|
|
||||||
from core.mixins.auth import AdminMixin
|
from core.mixins.auth import AdminMixin
|
||||||
|
from core.views.generic import RedirectView
|
||||||
|
|
||||||
class BackendViewMixin(AdminMixin):
|
class BackendViewMixin(AdminMixin):
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
|
@ -27,4 +28,7 @@ class BackendDeleteView(BackendViewMixin, DeleteView):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class BackendUpdateView(BackendViewMixin, UpdateView):
|
class BackendUpdateView(BackendViewMixin, UpdateView):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class BackendRedirectView(AdminMixin, RedirectView):
|
||||||
pass
|
pass
|
9
core/views/generic.py
Normal file
9
core/views/generic.py
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
from django.views import View
|
||||||
|
from django.shortcuts import redirect
|
||||||
|
|
||||||
|
class RedirectView(View):
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
try:
|
||||||
|
return redirect(request.GET.get("next"))
|
||||||
|
except:
|
||||||
|
return redirect(self.next)
|
2
kumisms
2
kumisms
|
@ -1 +1 @@
|
||||||
Subproject commit 0aa67e65c1a0eede3016e727e587ca21fb5b4bc9
|
Subproject commit 8ee4066973d81d3556b021e0b892ae325fc89b48
|
|
@ -39,15 +39,17 @@
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Code</th>
|
<th>Code</th>
|
||||||
<th>Symbol</th>
|
<th>Symbol</th>
|
||||||
|
<th>Exchange Rate to {{ base_currency.code }}</th>
|
||||||
<th>Options</th>
|
<th>Options</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for currency in object_list %}
|
{% for currency in object_list %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ currency.name }}</td>
|
<td>{% if currency == base_currency %}<b>{{ currency.name }}</b>{% else %}{{ currency.name }}{% endif %}</td>
|
||||||
<td>{{ currency.code }}</td>
|
<td>{{ currency.code }}</td>
|
||||||
<td>{{ currency.symbol }}</td>
|
<td>{{ currency.symbol }}</td>
|
||||||
|
<td>{{ currency.rate }}</td>
|
||||||
<td><a href="{% url "currencies_edit" currency.id %}"><i class="fas fa-edit" title="Edit Currency"></i></a> <a href="{% url "currencies_delete" currency.id %}"><i style="color: darkred;" class="fas fa-trash-alt" title="Delete Currency"></i></a></td>
|
<td><a href="{% url "currencies_edit" currency.id %}"><i class="fas fa-edit" title="Edit Currency"></i></a> <a href="{% url "currencies_delete" currency.id %}"><i style="color: darkred;" class="fas fa-trash-alt" title="Delete Currency"></i></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Reference in a new issue