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>
</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>
</tr>
<tr>
@ -181,12 +181,12 @@
<tbody>
{% for comp in intervention.compensations.all %}
<tr>
<td>
<td class="align-middle">
<a href="{% url 'compensation:open' comp.id %}">
{{ comp.identifier }}
</a>
</td>
<td>{{ comp.title }}</td>
<td class="align-middle">{{ comp.title }}</td>
</tr>
{% endfor %}
</tbody>
@ -230,12 +230,14 @@
</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>
<td class="align-middle">
<a href="{% url 'compensation:pay-open' pay.id %}">
{{ pay.amount }}
</a>
</td>
<td class="align-middle">{{ pay.comment }}</td>
</tr>
{% endfor %}
</tbody>
</table>
@ -256,7 +258,7 @@
</div>
<div class="col-sm-6">
<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">
{% fa5_icon 'plus' %}
{% fa5_icon 'file' %}
@ -276,66 +278,28 @@
<th scope="col">
{% trans 'Comment' %}
</th>
<th scope="col">
{% trans 'Action' %}
</th>
</tr>
</thead>
<tbody>
{% for doc in intervention.documents.all %}
<tr>
<td>
<a href="{% url 'compensation:open' doc.id %}">
<td class="align-middle">
<a href="{% url 'doc-open' doc.id %}">
{{ doc.title }}
</a>
</td>
<td>{{ doc.comment }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</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' %}
<td class="align-middle">{{ doc.comment }}</td>
<td>
<a href="{% url 'doc-remove' doc.id %}" class="mr-2">
<button class="btn btn-default" title="{% trans 'Remove document' %}">
{% fa5_icon 'trash' %}
</button>
</a>
</div>
</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>
</td>
</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 %}
</tbody>
</table>

View File

@ -7,7 +7,7 @@ Created on: 22.07.21
"""
from django.contrib import admin
from konova.models import Geometry
from konova.models import Geometry, Document
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(Document, DocumentAdmin)

View File

@ -132,7 +132,7 @@ a {
.btn-default{
color: white;
background-color: var(--rlp-red);
border-radius: 0;
border-radius: 0.15rem;
}
.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.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)
urlpatterns = [
@ -34,7 +34,11 @@ urlpatterns = [
path('organisation/', include("organisation.urls")),
path('user/', include("user.urls")),
path('news/', include("news.urls")),
# Documents
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
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
"""
from django.contrib import messages
from django.contrib.auth import logout
from django.contrib.auth.decorators import login_required
from django.http import HttpRequest, FileResponse
from django.shortcuts import redirect, render, get_object_or_404
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from konova.contexts import BaseContext
from konova.models import Document
@ -66,6 +68,7 @@ def home_view(request: HttpRequest):
return render(request, template, context)
@login_required
def get_document_view(request: HttpRequest, id: str):
""" 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)
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.
#
#: 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
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\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
#: intervention/tables.py:23
#: intervention/templates/intervention/detail-view.html:162
#: intervention/templates/intervention/detail-view.html:174
msgid "Identifier"
msgstr "Kennung"
#: compensation/tables.py:23 compensation/tables.py:76 intervention/forms.py:33
#: intervention/tables.py:28
#: 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"
msgstr "Bezeichnung"
@ -43,7 +44,7 @@ msgid "Actions"
msgstr "Aktionen"
#: compensation/tables.py:44
#: intervention/templates/intervention/detail-view.html:142
#: intervention/templates/intervention/detail-view.html:154
msgid "Compensations"
msgstr "Kompensationen"
@ -100,14 +101,16 @@ msgid "Which intervention type is this"
msgstr "Welcher Eingriffstyp"
#: intervention/forms.py:44
#: intervention/templates/intervention/detail-view.html:65
msgid "Law"
msgstr "Recht"
msgstr "Gesetz"
#: intervention/forms.py:47
msgid "Based on which law"
msgstr "Basiert auf welchem Recht"
#: intervention/forms.py:50
#: intervention/templates/intervention/detail-view.html:85
msgid "Intervention handler"
msgstr "Eingriffsverursacher"
@ -156,12 +159,12 @@ msgid "Edit intervention"
msgstr "Eingriff bearbeiten"
#: intervention/tables.py:33
#: intervention/templates/intervention/detail-view.html:77
#: intervention/templates/intervention/detail-view.html:89
msgid "Checked"
msgstr "Geprüft"
#: intervention/tables.py:39
#: intervention/templates/intervention/detail-view.html:91
#: intervention/templates/intervention/detail-view.html:103
msgid "Recorded"
msgstr "Verzeichnet"
@ -237,61 +240,85 @@ msgid "Delete"
msgstr "Löschen"
#: intervention/templates/intervention/detail-view.html:61
msgid "Process type"
msgstr "Verfahrenstyp"
#: intervention/templates/intervention/detail-view.html:69
msgid "Registration office"
msgstr "Zulassungsbehörde"
#: intervention/templates/intervention/detail-view.html:65
#: intervention/templates/intervention/detail-view.html:73
msgid "Registration office file number"
msgstr "Aktenzeichen Zulassungsbehörde"
#: intervention/templates/intervention/detail-view.html:69
#: intervention/templates/intervention/detail-view.html:77
msgid "Conservation office"
msgstr "Naturschutzbehörde"
#: intervention/templates/intervention/detail-view.html:73
#: intervention/templates/intervention/detail-view.html:81
msgid "Conversation office file number"
msgstr "Aktenzeichen Naturschutzbehörde"
#: intervention/templates/intervention/detail-view.html:105
#: intervention/templates/intervention/detail-view.html:117
msgid "Registration date"
msgstr "Datum Zulassung bzw. Satzungsbeschluss"
#: intervention/templates/intervention/detail-view.html:109
#: intervention/templates/intervention/detail-view.html:121
msgid "Binding on"
msgstr "Datum Bestandskraft"
#: intervention/templates/intervention/detail-view.html:113
#: intervention/templates/intervention/detail-view.html:125
msgid "Last modified"
msgstr "Zuletzt bearbeitet"
#: intervention/templates/intervention/detail-view.html:117
#: intervention/templates/intervention/detail-view.html:129
msgid "by"
msgstr "von"
#: intervention/templates/intervention/detail-view.html:126
#: intervention/templates/intervention/detail-view.html:138
msgid "No geometry added, yet."
msgstr "Keine Geometrie vorhanden"
#: intervention/templates/intervention/detail-view.html:147
#: intervention/templates/intervention/detail-view.html:159
msgid "Add new compensation"
msgstr "Neue Kompensation hinzufügen"
#: intervention/templates/intervention/detail-view.html:192
#: intervention/templates/intervention/detail-view.html:204
msgid "Payments"
msgstr "Ersatzzahlungen"
#: intervention/templates/intervention/detail-view.html:197
#: intervention/templates/intervention/detail-view.html:209
msgid "Add new payment"
msgstr "Neue Zahlung hinzufügen"
#: intervention/templates/intervention/detail-view.html:212
#: intervention/templates/intervention/detail-view.html:224
msgid "Amount"
msgstr "Betrag"
#: intervention/templates/intervention/detail-view.html:215
#: intervention/templates/intervention/detail-view.html:227
msgid "Transfer comment"
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
msgid "Intervention {} added"
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."
msgstr "Hierfür müssen Sie einer anderen Nutzergruppe angehören!"
#: konova/forms.py:46
#: konova/forms.py:44
msgid "Not editable"
msgstr "Nicht editierbar"
#: konova/forms.py:72
#: konova/forms.py:70
msgid "Confirm"
msgstr "Bestätigen"
#: konova/forms.py:84
#: konova/forms.py:82
msgid "Remove"
msgstr "Entferne"
#: konova/forms.py:86
#: konova/forms.py:84
msgid "You are about to remove {} {}"
msgstr "Sie sind dabei {} {} zu löschen"
@ -394,6 +421,12 @@ msgstr "Ökokonto"
msgid "Withdraw"
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
msgid "Published on"
msgstr "Veröffentlicht am"
@ -1922,9 +1955,6 @@ msgstr ""
#~ msgid "Intervention identifier"
#~ msgstr "Eingriffskennung"
#~ msgid "Processes"
#~ msgstr "Vorgänge"
#~ msgid ""
#~ "A process is based on an intervention. Please fill in the missing data "
#~ "for this intervention"
@ -1962,9 +1992,6 @@ msgstr ""
#~ msgid "Registration office document identifier"
#~ msgstr "Aktenzeichen Eintragungsstelle"
#~ msgid "Document identifier"
#~ msgstr "Aktenzeichen"
#~ msgid "Date"
#~ msgstr "Datum"