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 compensation.models import Compensation, CompensationAction, CompensationState, CompensationControl
|
||||
from compensation.models import Compensation, CompensationAction, CompensationState, CompensationControl, Payment
|
||||
|
||||
|
||||
class CompensationControlAdmin(admin.ModelAdmin):
|
||||
@ -37,8 +37,16 @@ class CompensationAdmin(admin.ModelAdmin):
|
||||
"created_on",
|
||||
]
|
||||
|
||||
class PaymentAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
"id",
|
||||
"amount",
|
||||
"due_on"
|
||||
]
|
||||
|
||||
|
||||
admin.site.register(Compensation, CompensationAdmin)
|
||||
admin.site.register(Payment, PaymentAdmin)
|
||||
admin.site.register(CompensationAction, CompensationActionAdmin)
|
||||
admin.site.register(CompensationState, CompensationStateAdmin)
|
||||
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)
|
||||
documents = models.ManyToManyField("konova.Document", blank=True)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _generate_new_identifier() -> str:
|
||||
""" Generates a new identifier for the intervention object
|
||||
|
@ -36,6 +36,9 @@ class CompensationTable(BaseTable):
|
||||
attrs={"td": {"class": "action-col"}}
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
pass
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.title = _("Compensations")
|
||||
@ -86,6 +89,9 @@ class EcoAccountTable(BaseTable):
|
||||
attrs={"td": {"class": "action-col"}}
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
pass
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.title = _("Eco Accounts")
|
||||
|
@ -21,7 +21,9 @@ def index_view(request: HttpRequest):
|
||||
"""
|
||||
template = "generic_index.html"
|
||||
user = request.user
|
||||
compensations = None # ToDo
|
||||
compensations = Compensation.objects.filter(
|
||||
deleted_on=None,
|
||||
)
|
||||
table = CompensationTable(
|
||||
request=request,
|
||||
queryset=compensations
|
||||
@ -71,8 +73,7 @@ def account_index_view(request: HttpRequest):
|
||||
template = "generic_index.html"
|
||||
user = request.user
|
||||
eco_accounts = EcoAccount.objects.filter(
|
||||
created_by=user,
|
||||
is_deleted=False,
|
||||
deleted_on=None,
|
||||
)
|
||||
table = EcoAccountTable(
|
||||
request=request,
|
||||
|
@ -9,6 +9,8 @@ Created on: 16.11.20
|
||||
from abc import abstractmethod
|
||||
|
||||
from django import forms
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
@ -84,10 +86,11 @@ class RemoveForm(BaseForm):
|
||||
def is_checked(self) -> bool:
|
||||
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():
|
||||
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()
|
||||
return self.object_to_remove
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<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>
|
||||
</a>
|
||||
</div>
|
||||
@ -69,12 +69,12 @@
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<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>
|
||||
</a>
|
||||
</div>
|
||||
<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>
|
||||
</a>
|
||||
</div>
|
||||
@ -88,7 +88,7 @@
|
||||
{% trans 'Eco-account' %}
|
||||
</h4>
|
||||
<div class="row">
|
||||
<a href="{% url 'home' %}">
|
||||
<a href="{% url 'compensation:account-index' %}">
|
||||
<div class="col-sm-5">
|
||||
<div class="qs-box d-flex justify-content-center align-items-center">
|
||||
{% fa5_icon 'tree' %}
|
||||
@ -110,12 +110,12 @@
|
||||
<div class="col-sm-12 col-lg">
|
||||
<div class="col-sm">
|
||||
<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>
|
||||
</a>
|
||||
</div>
|
||||
<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>
|
||||
</a>
|
||||
</div>
|
||||
|
@ -30,7 +30,6 @@ urlpatterns = [
|
||||
path('', home_view, name="home"),
|
||||
path('intervention/', include("intervention.urls")),
|
||||
path('compensation/', include("compensation.urls")),
|
||||
path('eco-account/', include("intervention.urls")), #ToDo
|
||||
path('ema/', include("intervention.urls")), #ToDo
|
||||
path('organisation/', include("organisation.urls")),
|
||||
path('user/', include("user.urls")),
|
||||
|
@ -23,13 +23,13 @@
|
||||
</a>
|
||||
</li>
|
||||
<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' %}
|
||||
{% trans 'Compensation' %}
|
||||
</a>
|
||||
</li>
|
||||
<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' %}
|
||||
{% trans 'Eco-account' %}
|
||||
</a>
|
||||
|
Loading…
Reference in New Issue
Block a user