Compensation control
* removes CompensationControl model * adds comment field to CompensationAction * adds max length of 200 for comment fields in forms * adds rendering of error messages in case of invalid form input * adds/updates translations
This commit is contained in:
@@ -1,19 +1,9 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from compensation.models import Compensation, CompensationAction, CompensationState, CompensationControl, Payment, \
|
||||
from compensation.models import Compensation, CompensationAction, CompensationState, Payment, \
|
||||
EcoAccountWithdraw, EcoAccount
|
||||
|
||||
|
||||
class CompensationControlAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
"id",
|
||||
"type",
|
||||
"deadline",
|
||||
"expected_result",
|
||||
"by_authority",
|
||||
]
|
||||
|
||||
|
||||
class CompensationStateAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
"id",
|
||||
@@ -28,7 +18,7 @@ class CompensationActionAdmin(admin.ModelAdmin):
|
||||
"action_type",
|
||||
"amount",
|
||||
"unit",
|
||||
"control",
|
||||
"comment",
|
||||
]
|
||||
|
||||
|
||||
@@ -70,6 +60,5 @@ 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)
|
||||
admin.site.register(EcoAccount, EcoAccountAdmin)
|
||||
admin.site.register(EcoAccountWithdraw, EcoAccountWithdrawAdmin)
|
||||
|
||||
@@ -178,9 +178,10 @@ class NewDeadlineModalForm(BaseModalForm):
|
||||
)
|
||||
comment = forms.CharField(
|
||||
required=False,
|
||||
max_length=200,
|
||||
label=_("Comment"),
|
||||
label_suffix=_(""),
|
||||
help_text=_("Additional comment"),
|
||||
help_text=_("Additional comment, maximum {} letters").format(200),
|
||||
widget=forms.Textarea(
|
||||
attrs={
|
||||
"cols": 30,
|
||||
@@ -239,9 +240,10 @@ class NewActionModalForm(BaseModalForm):
|
||||
)
|
||||
comment = forms.CharField(
|
||||
required=False,
|
||||
max_length=200,
|
||||
label=_("Comment"),
|
||||
label_suffix=_(""),
|
||||
help_text=_("Additional comment"),
|
||||
help_text=_("Additional comment, maximum {} letters").format(200),
|
||||
widget=forms.Textarea(
|
||||
attrs={
|
||||
"cols": 30,
|
||||
@@ -265,6 +267,7 @@ class NewActionModalForm(BaseModalForm):
|
||||
action_type=self.cleaned_data["action_type"],
|
||||
amount=self.cleaned_data["amount"],
|
||||
unit=self.cleaned_data["unit"],
|
||||
comment=self.cleaned_data["comment"],
|
||||
created=user_action,
|
||||
)
|
||||
self.instance.actions.add(comp_action)
|
||||
|
||||
@@ -42,17 +42,6 @@ class Payment(BaseResource):
|
||||
)
|
||||
|
||||
|
||||
class CompensationControl(BaseResource):
|
||||
"""
|
||||
Holds data on how a compensation shall be controlled
|
||||
"""
|
||||
deadline = models.ForeignKey("konova.Deadline", on_delete=models.SET_NULL, null=True, blank=True)
|
||||
type = models.CharField(max_length=500, null=True, blank=True)
|
||||
expected_result = models.CharField(max_length=500, null=True, blank=True, help_text="The expected outcome, that needs to be controlled")
|
||||
by_authority = models.ForeignKey(Organisation, null=True, blank=True, on_delete=models.SET_NULL)
|
||||
comment = models.TextField()
|
||||
|
||||
|
||||
class CompensationState(UuidModel):
|
||||
"""
|
||||
Compensations must define the state of an area before and after the compensation.
|
||||
@@ -83,7 +72,7 @@ class CompensationAction(BaseResource):
|
||||
action_type = models.CharField(max_length=500, null=True, blank=True)
|
||||
amount = models.FloatField()
|
||||
unit = models.CharField(max_length=100, null=True, blank=True, choices=UnitChoices.choices)
|
||||
control = models.ForeignKey(CompensationControl, on_delete=models.SET_NULL, null=True, blank=True)
|
||||
comment = models.TextField(blank=True, null=True, help_text="Additional comment")
|
||||
|
||||
def __str__(self):
|
||||
return "{} | {} {}".format(self.action_type, self.amount, self.unit)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% load i18n l10n fontawesome_5 %}
|
||||
{% load i18n l10n fontawesome_5 humanize %}
|
||||
<div id="related-documents" class="card">
|
||||
<div class="card-header rlp-r">
|
||||
<div class="row">
|
||||
@@ -31,7 +31,7 @@
|
||||
{% trans 'Amount' context 'Compensation' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Unit' %}
|
||||
{% trans 'Comment' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Action' %}
|
||||
@@ -44,8 +44,8 @@
|
||||
<td class="align-middle">
|
||||
{{ action.action_type }}
|
||||
</td>
|
||||
<td class="align-middle">{{ action.amount }}</td>
|
||||
<td class="align-middle">{{ action.unit_humanize }}</td>
|
||||
<td class="align-middle">{{ action.amount|floatformat:2|intcomma }} {{ action.unit_humanize }}</td>
|
||||
<td class="align-middle">{{ action.comment|default_if_none:"" }}</td>
|
||||
<td>
|
||||
{% if is_default_member and has_access %}
|
||||
<button data-form-url="{% url 'compensation:action-remove' action.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove action' %}">
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<div class="card-body scroll-300">
|
||||
{% if sum_before_states > sum_after_states %}
|
||||
<div class="row alert alert-danger">
|
||||
{% trans 'Missing surfaces: ' %}{{ diff_states|floatformat:2 }} m²
|
||||
{% trans 'Missing surfaces according to states before: ' %}{{ diff_states|floatformat:2 }} m²
|
||||
</div>
|
||||
{% endif %}
|
||||
<table class="table table-hover">
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<div class="card-body scroll-300">
|
||||
{% if sum_before_states < sum_after_states %}
|
||||
<div class="row alert alert-danger">
|
||||
{% trans 'Missing surfaces: ' %}{{ diff_states|floatformat:2 }} m²
|
||||
{% trans 'Missing surfaces according to states after: ' %}{{ diff_states|floatformat:2 }} m²
|
||||
</div>
|
||||
{% endif %}
|
||||
<table class="table table-hover">
|
||||
|
||||
Reference in New Issue
Block a user