Linkage improvement
* adds linking to submenus * adds PaymentAdmin * adds Meta class inheritance for tables
This commit is contained in:
parent
ee6984de00
commit
8f0db2ae3e
@ -1,6 +1,6 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from compensation.models import Compensation, CompensationAction, CompensationState, CompensationControl
|
from compensation.models import Compensation, CompensationAction, CompensationState, CompensationControl, Payment
|
||||||
|
|
||||||
|
|
||||||
class CompensationControlAdmin(admin.ModelAdmin):
|
class CompensationControlAdmin(admin.ModelAdmin):
|
||||||
@ -37,8 +37,16 @@ class CompensationAdmin(admin.ModelAdmin):
|
|||||||
"created_on",
|
"created_on",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
class PaymentAdmin(admin.ModelAdmin):
|
||||||
|
list_display = [
|
||||||
|
"id",
|
||||||
|
"amount",
|
||||||
|
"due_on"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(Compensation, CompensationAdmin)
|
admin.site.register(Compensation, CompensationAdmin)
|
||||||
|
admin.site.register(Payment, PaymentAdmin)
|
||||||
admin.site.register(CompensationAction, CompensationActionAdmin)
|
admin.site.register(CompensationAction, CompensationActionAdmin)
|
||||||
admin.site.register(CompensationState, CompensationStateAdmin)
|
admin.site.register(CompensationState, CompensationStateAdmin)
|
||||||
admin.site.register(CompensationControl, CompensationControlAdmin)
|
admin.site.register(CompensationControl, CompensationControlAdmin)
|
||||||
|
@ -74,7 +74,6 @@ class Compensation(BaseObject):
|
|||||||
geometry = models.ForeignKey(Geometry, null=True, blank=True, on_delete=models.SET_NULL)
|
geometry = models.ForeignKey(Geometry, null=True, blank=True, on_delete=models.SET_NULL)
|
||||||
documents = models.ManyToManyField("konova.Document", blank=True)
|
documents = models.ManyToManyField("konova.Document", blank=True)
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _generate_new_identifier() -> str:
|
def _generate_new_identifier() -> str:
|
||||||
""" Generates a new identifier for the intervention object
|
""" Generates a new identifier for the intervention object
|
||||||
|
@ -36,6 +36,9 @@ class CompensationTable(BaseTable):
|
|||||||
attrs={"td": {"class": "action-col"}}
|
attrs={"td": {"class": "action-col"}}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class Meta(BaseTable.Meta):
|
||||||
|
pass
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.title = _("Compensations")
|
self.title = _("Compensations")
|
||||||
@ -86,6 +89,9 @@ class EcoAccountTable(BaseTable):
|
|||||||
attrs={"td": {"class": "action-col"}}
|
attrs={"td": {"class": "action-col"}}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class Meta(BaseTable.Meta):
|
||||||
|
pass
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.title = _("Eco Accounts")
|
self.title = _("Eco Accounts")
|
||||||
|
@ -21,7 +21,9 @@ def index_view(request: HttpRequest):
|
|||||||
"""
|
"""
|
||||||
template = "generic_index.html"
|
template = "generic_index.html"
|
||||||
user = request.user
|
user = request.user
|
||||||
compensations = None # ToDo
|
compensations = Compensation.objects.filter(
|
||||||
|
deleted_on=None,
|
||||||
|
)
|
||||||
table = CompensationTable(
|
table = CompensationTable(
|
||||||
request=request,
|
request=request,
|
||||||
queryset=compensations
|
queryset=compensations
|
||||||
@ -71,8 +73,7 @@ def account_index_view(request: HttpRequest):
|
|||||||
template = "generic_index.html"
|
template = "generic_index.html"
|
||||||
user = request.user
|
user = request.user
|
||||||
eco_accounts = EcoAccount.objects.filter(
|
eco_accounts = EcoAccount.objects.filter(
|
||||||
created_by=user,
|
deleted_on=None,
|
||||||
is_deleted=False,
|
|
||||||
)
|
)
|
||||||
table = EcoAccountTable(
|
table = EcoAccountTable(
|
||||||
request=request,
|
request=request,
|
||||||
|
@ -9,6 +9,8 @@ Created on: 16.11.20
|
|||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
@ -84,10 +86,11 @@ class RemoveForm(BaseForm):
|
|||||||
def is_checked(self) -> bool:
|
def is_checked(self) -> bool:
|
||||||
return self.cleaned_data.get("check", False)
|
return self.cleaned_data.get("check", False)
|
||||||
|
|
||||||
def save(self):
|
def save(self, user: User):
|
||||||
if self.object_to_remove is not None and self.is_checked():
|
if self.object_to_remove is not None and self.is_checked():
|
||||||
self.object_to_remove.is_active = False
|
self.object_to_remove.is_active = False
|
||||||
self.object_to_remove.is_deleted = True
|
self.object_to_remove.deleted_on = timezone.now()
|
||||||
|
self.object_to_remove.deleted_by = user
|
||||||
self.object_to_remove.save()
|
self.object_to_remove.save()
|
||||||
return self.object_to_remove
|
return self.object_to_remove
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
<div class="row my-1">
|
<div class="row my-1">
|
||||||
<a href="{% url 'home' %}">
|
<a href="{% url 'intervention:new' %}">
|
||||||
<button class="btn btn-default">{% fa5_icon 'plus' %} {% trans 'Create' %}</button>
|
<button class="btn btn-default">{% fa5_icon 'plus' %} {% trans 'Create' %}</button>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@ -69,12 +69,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
<div class="row my-1">
|
<div class="row my-1">
|
||||||
<a href="{% url 'home' %}">
|
<a href="{% url 'compensation:new' %}">
|
||||||
<button class="btn btn-default">{% fa5_icon 'plus' %} {% trans 'Create' %}</button>
|
<button class="btn btn-default">{% fa5_icon 'plus' %} {% trans 'Create' %}</button>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="row my-1">
|
<div class="row my-1">
|
||||||
<a href="{% url 'home' %}">
|
<a href="{% url 'compensation:index' %}">
|
||||||
<button class="btn btn-default">{% fa5_icon 'eye' %} {% trans 'Show' %}</button>
|
<button class="btn btn-default">{% fa5_icon 'eye' %} {% trans 'Show' %}</button>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@ -88,7 +88,7 @@
|
|||||||
{% trans 'Eco-account' %}
|
{% trans 'Eco-account' %}
|
||||||
</h4>
|
</h4>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<a href="{% url 'home' %}">
|
<a href="{% url 'compensation:account-index' %}">
|
||||||
<div class="col-sm-5">
|
<div class="col-sm-5">
|
||||||
<div class="qs-box d-flex justify-content-center align-items-center">
|
<div class="qs-box d-flex justify-content-center align-items-center">
|
||||||
{% fa5_icon 'tree' %}
|
{% fa5_icon 'tree' %}
|
||||||
@ -110,12 +110,12 @@
|
|||||||
<div class="col-sm-12 col-lg">
|
<div class="col-sm-12 col-lg">
|
||||||
<div class="col-sm">
|
<div class="col-sm">
|
||||||
<div class="row my-1">
|
<div class="row my-1">
|
||||||
<a href="{% url 'home' %}">
|
<a href="{% url 'compensation:account-new' %}">
|
||||||
<button class="btn btn-default">{% fa5_icon 'plus' %} {% trans 'Create' %}</button>
|
<button class="btn btn-default">{% fa5_icon 'plus' %} {% trans 'Create' %}</button>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="row my-1">
|
<div class="row my-1">
|
||||||
<a href="{% url 'home' %}">
|
<a href="{% url 'compensation:account-index' %}">
|
||||||
<button class="btn btn-default">{% fa5_icon 'eye' %} {% trans 'Show' %}</button>
|
<button class="btn btn-default">{% fa5_icon 'eye' %} {% trans 'Show' %}</button>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -30,7 +30,6 @@ urlpatterns = [
|
|||||||
path('', home_view, name="home"),
|
path('', home_view, name="home"),
|
||||||
path('intervention/', include("intervention.urls")),
|
path('intervention/', include("intervention.urls")),
|
||||||
path('compensation/', include("compensation.urls")),
|
path('compensation/', include("compensation.urls")),
|
||||||
path('eco-account/', include("intervention.urls")), #ToDo
|
|
||||||
path('ema/', include("intervention.urls")), #ToDo
|
path('ema/', include("intervention.urls")), #ToDo
|
||||||
path('organisation/', include("organisation.urls")),
|
path('organisation/', include("organisation.urls")),
|
||||||
path('user/', include("user.urls")),
|
path('user/', include("user.urls")),
|
||||||
|
@ -23,13 +23,13 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class=" menu-elem">
|
<li class=" menu-elem">
|
||||||
<a class="nav-btn nav-link" href="{% url 'home' %}">
|
<a class="nav-btn nav-link" href="{% url 'compensation:index' %}">
|
||||||
{% fa5_icon 'leaf' %}
|
{% fa5_icon 'leaf' %}
|
||||||
{% trans 'Compensation' %}
|
{% trans 'Compensation' %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class=" menu-elem">
|
<li class=" menu-elem">
|
||||||
<a class="nav-btn nav-link" href="{% url 'home' %}">
|
<a class="nav-btn nav-link" href="{% url 'compensation:account-index' %}">
|
||||||
{% fa5_icon 'tree' %}
|
{% fa5_icon 'tree' %}
|
||||||
{% trans 'Eco-account' %}
|
{% trans 'Eco-account' %}
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user