Documents removing

* adds document removing button
* adds translation
* adds Document admin
This commit is contained in:
mipel 2021-07-23 16:04:58 +02:00
parent a0c0a0f074
commit 47ec30919c
7 changed files with 142 additions and 96 deletions

View File

@ -82,7 +82,7 @@
<td class="align-middle">{{intervention.conservation_file_number|default_if_none:""}}</td> <td class="align-middle">{{intervention.conservation_file_number|default_if_none:""}}</td>
</tr> </tr>
<tr> <tr>
<th scope="row">{% trans 'Handler' %}</th> <th scope="row">{% trans 'Intervention handler' %}</th>
<td class="align-middle">{{intervention.handler|default_if_none:""}}</td> <td class="align-middle">{{intervention.handler|default_if_none:""}}</td>
</tr> </tr>
<tr> <tr>
@ -181,12 +181,12 @@
<tbody> <tbody>
{% for comp in intervention.compensations.all %} {% for comp in intervention.compensations.all %}
<tr> <tr>
<td> <td class="align-middle">
<a href="{% url 'compensation:open' comp.id %}"> <a href="{% url 'compensation:open' comp.id %}">
{{ comp.identifier }} {{ comp.identifier }}
</a> </a>
</td> </td>
<td>{{ comp.title }}</td> <td class="align-middle">{{ comp.title }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
@ -230,12 +230,14 @@
</thead> </thead>
<tbody> <tbody>
{% for pay in intervention.payments.all %} {% for pay in intervention.payments.all %}
<a href="{% url 'compensation:pay-open' pay.id %}">
<tr> <tr>
<td>{{ pay.amount }}</td> <td class="align-middle">
<td>{{ pay.comment }}</td> <a href="{% url 'compensation:pay-open' pay.id %}">
</tr> {{ pay.amount }}
</a> </a>
</td>
<td class="align-middle">{{ pay.comment }}</td>
</tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
@ -256,7 +258,7 @@
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="d-flex justify-content-end"> <div class="d-flex justify-content-end">
<a href="{% url 'compensation:new' %}" title="{% trans 'Add new compensation' %}"> <a href="{% url 'doc-new' %}" title="{% trans 'Add new document' %}">
<button class="btn btn-outline-default"> <button class="btn btn-outline-default">
{% fa5_icon 'plus' %} {% fa5_icon 'plus' %}
{% fa5_icon 'file' %} {% fa5_icon 'file' %}
@ -276,66 +278,28 @@
<th scope="col"> <th scope="col">
{% trans 'Comment' %} {% trans 'Comment' %}
</th> </th>
<th scope="col">
{% trans 'Action' %}
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for doc in intervention.documents.all %} {% for doc in intervention.documents.all %}
<tr> <tr>
<td> <td class="align-middle">
<a href="{% url 'compensation:open' doc.id %}"> <a href="{% url 'doc-open' doc.id %}">
{{ doc.title }} {{ doc.title }}
</a> </a>
</td> </td>
<td>{{ doc.comment }}</td> <td class="align-middle">{{ doc.comment }}</td>
</tr> <td>
{% endfor %} <a href="{% url 'doc-remove' doc.id %}" class="mr-2">
</tbody> <button class="btn btn-default" title="{% trans 'Remove document' %}">
</table> {% fa5_icon 'trash' %}
</div>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div id="related-payments" class="card">
<div class="card-header rlp-r">
<div class="row">
<div class="col-sm-6">
<h5>
<span class="badge badge-light">{{intervention.payments.count}}</span>
{% trans 'Payments' %}
</h5>
</div>
<div class="col-sm-6">
<div class="d-flex justify-content-end">
<a href="{% url 'compensation:pay-new' %}" title="{% trans 'Add new payment' %}">
<button class="btn btn-outline-default">
{% fa5_icon 'plus' %}
{% fa5_icon 'money-bill-wave' %}
</button> </button>
</a> </a>
</div> </td>
</div>
</div>
</div>
<div class="card-body">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
{% trans 'Amount' %}
</th>
<th scope="col">
{% trans 'Transfer comment' %}
</th>
</tr> </tr>
</thead>
<tbody>
{% for pay in intervention.payments.all %}
<a href="{% url 'compensation:pay-open' pay.id %}">
<tr>
<td>{{ pay.amount }}</td>
<td>{{ pay.comment }}</td>
</tr>
</a>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>

View File

@ -7,7 +7,7 @@ Created on: 22.07.21
""" """
from django.contrib import admin from django.contrib import admin
from konova.models import Geometry from konova.models import Geometry, Document
class GeometryAdmin(admin.ModelAdmin): class GeometryAdmin(admin.ModelAdmin):
@ -18,4 +18,15 @@ class GeometryAdmin(admin.ModelAdmin):
] ]
class DocumentAdmin(admin.ModelAdmin):
list_display = [
"id",
"title",
"comment",
"created_on",
"created_by",
]
admin.site.register(Geometry, GeometryAdmin) admin.site.register(Geometry, GeometryAdmin)
admin.site.register(Document, DocumentAdmin)

View File

@ -132,7 +132,7 @@ a {
.btn-default{ .btn-default{
color: white; color: white;
background-color: var(--rlp-red); background-color: var(--rlp-red);
border-radius: 0; border-radius: 0.15rem;
} }
.btn-default:hover{ .btn-default:hover{
/* /*

View File

@ -20,7 +20,7 @@ from simple_sso.sso_client.client import Client
from konova.autocompletes import OrganisationAutocomplete, NonOfficialOrganisationAutocomplete from konova.autocompletes import OrganisationAutocomplete, NonOfficialOrganisationAutocomplete
from konova.settings import SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY, DEBUG from konova.settings import SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY, DEBUG
from konova.views import logout_view, home_view, get_document_view from konova.views import logout_view, home_view, get_document_view, new_document_view, remove_document_view
sso_client = Client(SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY) sso_client = Client(SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY)
urlpatterns = [ urlpatterns = [
@ -34,7 +34,11 @@ urlpatterns = [
path('organisation/', include("organisation.urls")), path('organisation/', include("organisation.urls")),
path('user/', include("user.urls")), path('user/', include("user.urls")),
path('news/', include("news.urls")), path('news/', include("news.urls")),
# Documents
path('document/<id>', get_document_view, name="doc-open"), path('document/<id>', get_document_view, name="doc-open"),
path('document/new', new_document_view, name="doc-new"),
path('document/<id>/remove>', remove_document_view, name="doc-remove"),
# Autocomplete paths # Autocomplete paths
path("atcmplt/orgs", OrganisationAutocomplete.as_view(), name="orgs-autocomplete"), path("atcmplt/orgs", OrganisationAutocomplete.as_view(), name="orgs-autocomplete"),

View File

@ -5,11 +5,13 @@ Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 16.11.20 Created on: 16.11.20
""" """
from django.contrib import messages
from django.contrib.auth import logout from django.contrib.auth import logout
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.http import HttpRequest, FileResponse from django.http import HttpRequest, FileResponse
from django.shortcuts import redirect, render, get_object_or_404 from django.shortcuts import redirect, render, get_object_or_404
from django.utils import timezone from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from konova.contexts import BaseContext from konova.contexts import BaseContext
from konova.models import Document from konova.models import Document
@ -66,6 +68,7 @@ def home_view(request: HttpRequest):
return render(request, template, context) return render(request, template, context)
@login_required
def get_document_view(request: HttpRequest, id: str): def get_document_view(request: HttpRequest, id: str):
""" Returns a document as downloadable attachment """ Returns a document as downloadable attachment
@ -77,4 +80,41 @@ def get_document_view(request: HttpRequest, id: str):
""" """
doc = get_object_or_404(Document, id=id) doc = get_object_or_404(Document, id=id)
return FileResponse(doc.file, as_attachment=True) return FileResponse(doc.document, as_attachment=True)
@login_required
def new_document_view(request: HttpRequest):
""" Renders a form for uploading new documents
Args:
request (HttpRequest): The incoming request
Returns:
"""
template = ""
# TODO
context = {}
context = BaseContext(request, context).context
return render(request, template, context)
@login_required
def remove_document_view(request: HttpRequest, id: str):
""" Renders a form for uploading new documents
Args:
request (HttpRequest): The incoming request
Returns:
"""
doc = get_object_or_404(Document, id=id)
title = doc.title
#doc.delete()
messages.success(
request,
_("Document '{}' deleted").format(title)
)
return redirect(request.META.get("HTTP_REFERER", "home"))

Binary file not shown.

View File

@ -4,14 +4,14 @@
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# #
#: intervention/filters.py:25 intervention/filters.py:31 #: intervention/filters.py:25 intervention/filters.py:31
#: intervention/filters.py:38 intervention/filters.py:39 konova/forms.py:73 #: intervention/filters.py:38 intervention/filters.py:39 konova/forms.py:71
#: user/forms.py:38 #: user/forms.py:38
#, fuzzy #, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-07-22 16:04+0200\n" "POT-Creation-Date: 2021-07-23 16:00+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -23,14 +23,15 @@ msgstr ""
#: compensation/tables.py:18 compensation/tables.py:71 intervention/forms.py:26 #: compensation/tables.py:18 compensation/tables.py:71 intervention/forms.py:26
#: intervention/tables.py:23 #: intervention/tables.py:23
#: intervention/templates/intervention/detail-view.html:162 #: intervention/templates/intervention/detail-view.html:174
msgid "Identifier" msgid "Identifier"
msgstr "Kennung" msgstr "Kennung"
#: compensation/tables.py:23 compensation/tables.py:76 intervention/forms.py:33 #: compensation/tables.py:23 compensation/tables.py:76 intervention/forms.py:33
#: intervention/tables.py:28 #: intervention/tables.py:28
#: intervention/templates/intervention/detail-view.html:57 #: intervention/templates/intervention/detail-view.html:57
#: intervention/templates/intervention/detail-view.html:165 #: intervention/templates/intervention/detail-view.html:177
#: intervention/templates/intervention/detail-view.html:276
msgid "Title" msgid "Title"
msgstr "Bezeichnung" msgstr "Bezeichnung"
@ -43,7 +44,7 @@ msgid "Actions"
msgstr "Aktionen" msgstr "Aktionen"
#: compensation/tables.py:44 #: compensation/tables.py:44
#: intervention/templates/intervention/detail-view.html:142 #: intervention/templates/intervention/detail-view.html:154
msgid "Compensations" msgid "Compensations"
msgstr "Kompensationen" msgstr "Kompensationen"
@ -100,14 +101,16 @@ msgid "Which intervention type is this"
msgstr "Welcher Eingriffstyp" msgstr "Welcher Eingriffstyp"
#: intervention/forms.py:44 #: intervention/forms.py:44
#: intervention/templates/intervention/detail-view.html:65
msgid "Law" msgid "Law"
msgstr "Recht" msgstr "Gesetz"
#: intervention/forms.py:47 #: intervention/forms.py:47
msgid "Based on which law" msgid "Based on which law"
msgstr "Basiert auf welchem Recht" msgstr "Basiert auf welchem Recht"
#: intervention/forms.py:50 #: intervention/forms.py:50
#: intervention/templates/intervention/detail-view.html:85
msgid "Intervention handler" msgid "Intervention handler"
msgstr "Eingriffsverursacher" msgstr "Eingriffsverursacher"
@ -156,12 +159,12 @@ msgid "Edit intervention"
msgstr "Eingriff bearbeiten" msgstr "Eingriff bearbeiten"
#: intervention/tables.py:33 #: intervention/tables.py:33
#: intervention/templates/intervention/detail-view.html:77 #: intervention/templates/intervention/detail-view.html:89
msgid "Checked" msgid "Checked"
msgstr "Geprüft" msgstr "Geprüft"
#: intervention/tables.py:39 #: intervention/tables.py:39
#: intervention/templates/intervention/detail-view.html:91 #: intervention/templates/intervention/detail-view.html:103
msgid "Recorded" msgid "Recorded"
msgstr "Verzeichnet" msgstr "Verzeichnet"
@ -237,61 +240,85 @@ msgid "Delete"
msgstr "Löschen" msgstr "Löschen"
#: intervention/templates/intervention/detail-view.html:61 #: intervention/templates/intervention/detail-view.html:61
msgid "Process type"
msgstr "Verfahrenstyp"
#: intervention/templates/intervention/detail-view.html:69
msgid "Registration office" msgid "Registration office"
msgstr "Zulassungsbehörde" msgstr "Zulassungsbehörde"
#: intervention/templates/intervention/detail-view.html:65 #: intervention/templates/intervention/detail-view.html:73
msgid "Registration office file number" msgid "Registration office file number"
msgstr "Aktenzeichen Zulassungsbehörde" msgstr "Aktenzeichen Zulassungsbehörde"
#: intervention/templates/intervention/detail-view.html:69 #: intervention/templates/intervention/detail-view.html:77
msgid "Conservation office" msgid "Conservation office"
msgstr "Naturschutzbehörde" msgstr "Naturschutzbehörde"
#: intervention/templates/intervention/detail-view.html:73 #: intervention/templates/intervention/detail-view.html:81
msgid "Conversation office file number" msgid "Conversation office file number"
msgstr "Aktenzeichen Naturschutzbehörde" msgstr "Aktenzeichen Naturschutzbehörde"
#: intervention/templates/intervention/detail-view.html:105 #: intervention/templates/intervention/detail-view.html:117
msgid "Registration date" msgid "Registration date"
msgstr "Datum Zulassung bzw. Satzungsbeschluss" msgstr "Datum Zulassung bzw. Satzungsbeschluss"
#: intervention/templates/intervention/detail-view.html:109 #: intervention/templates/intervention/detail-view.html:121
msgid "Binding on" msgid "Binding on"
msgstr "Datum Bestandskraft" msgstr "Datum Bestandskraft"
#: intervention/templates/intervention/detail-view.html:113 #: intervention/templates/intervention/detail-view.html:125
msgid "Last modified" msgid "Last modified"
msgstr "Zuletzt bearbeitet" msgstr "Zuletzt bearbeitet"
#: intervention/templates/intervention/detail-view.html:117 #: intervention/templates/intervention/detail-view.html:129
msgid "by" msgid "by"
msgstr "von" msgstr "von"
#: intervention/templates/intervention/detail-view.html:126 #: intervention/templates/intervention/detail-view.html:138
msgid "No geometry added, yet." msgid "No geometry added, yet."
msgstr "Keine Geometrie vorhanden" msgstr "Keine Geometrie vorhanden"
#: intervention/templates/intervention/detail-view.html:147 #: intervention/templates/intervention/detail-view.html:159
msgid "Add new compensation" msgid "Add new compensation"
msgstr "Neue Kompensation hinzufügen" msgstr "Neue Kompensation hinzufügen"
#: intervention/templates/intervention/detail-view.html:192 #: intervention/templates/intervention/detail-view.html:204
msgid "Payments" msgid "Payments"
msgstr "Ersatzzahlungen" msgstr "Ersatzzahlungen"
#: intervention/templates/intervention/detail-view.html:197 #: intervention/templates/intervention/detail-view.html:209
msgid "Add new payment" msgid "Add new payment"
msgstr "Neue Zahlung hinzufügen" msgstr "Neue Zahlung hinzufügen"
#: intervention/templates/intervention/detail-view.html:212 #: intervention/templates/intervention/detail-view.html:224
msgid "Amount" msgid "Amount"
msgstr "Betrag" msgstr "Betrag"
#: intervention/templates/intervention/detail-view.html:215 #: intervention/templates/intervention/detail-view.html:227
msgid "Transfer comment" msgid "Transfer comment"
msgstr "Verwendungszweck" msgstr "Verwendungszweck"
#: intervention/templates/intervention/detail-view.html:256
msgid "Documents"
msgstr "Dokumente"
#: intervention/templates/intervention/detail-view.html:261
msgid "Add new document"
msgstr "Neues Dokument hinzufügen"
#: intervention/templates/intervention/detail-view.html:279
msgid "Comment"
msgstr "Kommentar"
#: intervention/templates/intervention/detail-view.html:282
msgid "Action"
msgstr "Aktionen"
#: intervention/templates/intervention/detail-view.html:297
msgid "Remove document"
msgstr "Dokument löschen"
#: intervention/views.py:62 #: intervention/views.py:62
msgid "Intervention {} added" msgid "Intervention {} added"
msgstr "Eingriff {} hinzugefügt" msgstr "Eingriff {} hinzugefügt"
@ -326,19 +353,19 @@ msgstr "Hierfür müssen Sie Administrator sein!"
msgid "You need to be part of another user group." msgid "You need to be part of another user group."
msgstr "Hierfür müssen Sie einer anderen Nutzergruppe angehören!" msgstr "Hierfür müssen Sie einer anderen Nutzergruppe angehören!"
#: konova/forms.py:46 #: konova/forms.py:44
msgid "Not editable" msgid "Not editable"
msgstr "Nicht editierbar" msgstr "Nicht editierbar"
#: konova/forms.py:72 #: konova/forms.py:70
msgid "Confirm" msgid "Confirm"
msgstr "Bestätigen" msgstr "Bestätigen"
#: konova/forms.py:84 #: konova/forms.py:82
msgid "Remove" msgid "Remove"
msgstr "Entferne" msgstr "Entferne"
#: konova/forms.py:86 #: konova/forms.py:84
msgid "You are about to remove {} {}" msgid "You are about to remove {} {}"
msgstr "Sie sind dabei {} {} zu löschen" msgstr "Sie sind dabei {} {} zu löschen"
@ -394,6 +421,12 @@ msgstr "Ökokonto"
msgid "Withdraw" msgid "Withdraw"
msgstr "Abbuchen" msgstr "Abbuchen"
#: konova/views.py:118
#, fuzzy
#| msgid "Document identifier"
msgid "Document '{}' deleted"
msgstr "Aktenzeichen"
#: news/templates/news/dashboard-news.html:12 news/templates/news/index.html:19 #: news/templates/news/dashboard-news.html:12 news/templates/news/index.html:19
msgid "Published on" msgid "Published on"
msgstr "Veröffentlicht am" msgstr "Veröffentlicht am"
@ -1922,9 +1955,6 @@ msgstr ""
#~ msgid "Intervention identifier" #~ msgid "Intervention identifier"
#~ msgstr "Eingriffskennung" #~ msgstr "Eingriffskennung"
#~ msgid "Processes"
#~ msgstr "Vorgänge"
#~ msgid "" #~ msgid ""
#~ "A process is based on an intervention. Please fill in the missing data " #~ "A process is based on an intervention. Please fill in the missing data "
#~ "for this intervention" #~ "for this intervention"
@ -1962,9 +1992,6 @@ msgstr ""
#~ msgid "Registration office document identifier" #~ msgid "Registration office document identifier"
#~ msgstr "Aktenzeichen Eintragungsstelle" #~ msgstr "Aktenzeichen Eintragungsstelle"
#~ msgid "Document identifier"
#~ msgstr "Aktenzeichen"
#~ msgid "Date" #~ msgid "Date"
#~ msgstr "Datum" #~ msgstr "Datum"