[Intervention] Revocations files optional #4

* makes revocation file upload optional
 * adds overview about revocations to intervention index
 * adds/updates translations
This commit is contained in:
mipel
2021-08-26 15:02:34 +02:00
parent 1f8440de57
commit 415fe267d2
7 changed files with 217 additions and 167 deletions

View File

@@ -332,6 +332,7 @@ class NewRevocationForm(BaseModalForm):
file = forms.FileField(
label=_("Document"),
label_suffix=_(""),
required=False,
help_text=_("Must be smaller than 15 Mb"),
widget=forms.FileInput(
attrs={
@@ -371,12 +372,15 @@ class NewRevocationForm(BaseModalForm):
user=self.user,
action=UserAction.EDITED
)
document = Document.objects.create(
title="revocation_of_{}".format(self.instance.identifier),
date_of_creation=self.cleaned_data["date"],
comment=self.cleaned_data["comment"],
file=self.cleaned_data["file"],
)
if self.cleaned_data["file"]:
document = Document.objects.create(
title="revocation_of_{}".format(self.instance.identifier),
date_of_creation=self.cleaned_data["date"],
comment=self.cleaned_data["comment"],
file=self.cleaned_data["file"],
)
else:
document = None
revocation = Revocation.objects.create(
date=self.cleaned_data["date"],
comment=self.cleaned_data["comment"],

View File

@@ -13,7 +13,7 @@ from django.utils.translation import gettext_lazy as _
from intervention.filters import InterventionTableFilter
from intervention.models import Intervention
from konova.sub_settings.django_settings import DEFAULT_DATE_TIME_FORMAT
from konova.sub_settings.django_settings import DEFAULT_DATE_TIME_FORMAT, DEFAULT_DATE_FORMAT
from konova.utils.tables import BaseTable
import django_tables2 as tables
@@ -41,6 +41,12 @@ class InterventionTable(BaseTable):
empty_values=[],
accessor="recorded",
)
rev = tables.Column(
verbose_name=_("Revocation"),
orderable=True,
empty_values=[],
accessor="legal__revocation",
)
e = tables.Column(
verbose_name=_("Editable"),
orderable=True,
@@ -52,16 +58,6 @@ class InterventionTable(BaseTable):
orderable=True,
accessor="modified__timestamp",
)
"""
# ToDo: Decide to keep actions column or to dismiss them
ac = tables.Column(
verbose_name=_("Actions"),
orderable=False,
empty_values=[],
attrs={"td": {"class": "action-col"}}
)
"""
class Meta(BaseTable.Meta):
template_name = "django_tables2/bootstrap4.html"
@@ -164,3 +160,29 @@ class InterventionTable(BaseTable):
icn_class="fas fa-edit rlp-r-inv" if has_access else "far fa-edit",
)
return format_html(html)
def render_rev(self, value, record: Intervention):
""" Renders the revocation column for an intervention
Args:
value (str): The revocation value
record (Intervention): The intervention record
Returns:
"""
html = ""
exists = value is not None
tooltip = _("No revocation")
if exists:
_date = value.date
added_ts = localtime(value.created.timestamp)
added_ts = added_ts.strftime(DEFAULT_DATE_TIME_FORMAT)
on = _date.strftime(DEFAULT_DATE_FORMAT)
tooltip = _("Revocation from {}, added on {} by {}").format(on, added_ts, value.created.user)
html += self.render_stop(
tooltip=tooltip,
icn_filled=exists,
)
return format_html(html)

View File

@@ -50,9 +50,11 @@
</td>
<td class="align-middle">{{ rev.comment }}</td>
<td class="align-middle">
<a href="{% url 'doc-open' rev.document.id %}">
{{ rev.document.file }}
</a>
{% if rev.document %}
<a href="{% url 'doc-open' rev.document.id %}">
{{ rev.document.file }}
</a>
{% endif %}
</td>
<td>
{% if is_default_member and has_access %}