diff --git a/compensation/admin.py b/compensation/admin.py index 104048d..1c15be7 100644 --- a/compensation/admin.py +++ b/compensation/admin.py @@ -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) diff --git a/compensation/models.py b/compensation/models.py index 1af74cf..9d3e0ca 100644 --- a/compensation/models.py +++ b/compensation/models.py @@ -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 diff --git a/compensation/tables.py b/compensation/tables.py index 8f22bbc..06f7575 100644 --- a/compensation/tables.py +++ b/compensation/tables.py @@ -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") diff --git a/compensation/views.py b/compensation/views.py index fd3ab43..1c047e7 100644 --- a/compensation/views.py +++ b/compensation/views.py @@ -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, diff --git a/konova/forms.py b/konova/forms.py index a97fd20..71dceb7 100644 --- a/konova/forms.py +++ b/konova/forms.py @@ -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 diff --git a/konova/templates/konova/home.html b/konova/templates/konova/home.html index fdb0fde..c0c6661 100644 --- a/konova/templates/konova/home.html +++ b/konova/templates/konova/home.html @@ -31,7 +31,7 @@
- +
@@ -69,12 +69,12 @@
- +
- +
@@ -88,7 +88,7 @@ {% trans 'Eco-account' %}
- +
{% fa5_icon 'tree' %} @@ -110,12 +110,12 @@
diff --git a/konova/urls.py b/konova/urls.py index 62d72b7..827ba43 100644 --- a/konova/urls.py +++ b/konova/urls.py @@ -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")), diff --git a/templates/navbar.html b/templates/navbar.html index 57aab48..2b700c3 100644 --- a/templates/navbar.html +++ b/templates/navbar.html @@ -23,13 +23,13 @@