Object deletion

+ objects are now not simply deleted but the removed_date is being set
+ Seperate table for removed objects
This commit is contained in:
Clemens-Dautermann 2018-12-28 20:22:09 +01:00
parent d5da34ff86
commit 6e2eec0c6e
2 changed files with 66 additions and 20 deletions

View file

@ -2,6 +2,8 @@ from django.shortcuts import render, get_object_or_404
from object_adder.models import Object, Category
from object_adder.forms import ObjectForm
from django.contrib.auth.decorators import login_required
from django.utils import timezone
import re
@ -76,7 +78,8 @@ def objlist(request, orderstr=None):
@login_required
def delete(request, uuid_url):
obj = get_object_or_404(Object, pk=uuid_url)
obj.delete()
obj.removed_date = timezone.now()
obj.save()
return render(request, 'object_lister/delete.html', {'uuid': uuid_url})

View file

@ -12,6 +12,7 @@
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
Abbruch.
</div>
<h3>Inventarisierte Objekte</h3>
<form>
{% csrf_token %}
<table class="objecttable">
@ -23,6 +24,7 @@
<th class="objecttable-head"><a href="./4">Hinzugefügt von</a></th>
</tr>
{% for object in objects %}
{% if object.removed_date is None %}
<tr class="objecttable-row">
<td class="objecttable-data">
<a class="celllink" href="./{{ object.uuid }}">{{ object.title }}</a>
@ -46,12 +48,14 @@
<a class="celllink" href="./{{ object.uuid }}">{{ object.user_added }}</a>
</td>
</tr>
{% endif %}
{% endfor %}
</table>
<p>{{ objammout }} Objekte insgesamt</p>
</form>
</div>
<div class="container shadow lower-box">
<h3>Kategorien</h3>
<table class="cattable">
<tr>
<th class="objecttable-head leftalign">Kategorie</th>
@ -70,6 +74,45 @@
</table>
<p>{{ ncats }} Kategorien insgesamt</p>
</div>
<div class="container shadow lower-box">
<h3>Gelöschte Objekte</h3>
<table class="objecttable">
<tr>
<th class="objecttable-head"><a href="./0">Name</a></th>
<th class="objecttable-head"><a href="./1">Anzahl</a></th>
<th class="objecttable-head"><a href="./2">Kategorie</a></th>
<th class="objecttable-head"><a href="./3">Löschungsdatum</a></th>
<th class="objecttable-head"><a href="./4">Hinzugefügt von</a></th>
</tr>
{% for object in objects %}
{% if object.removed_date is not None %}
<tr class="objecttable-row">
<td class="objecttable-data">
<a class="celllink">{{ object.title }}</a>
</td>
<td class="objecttable-data">
<a class="celllink">{{ object.ammout }}</a>
</td>
{% if object.category is not None %}
<td class="objecttable-data">
<a class="celllink">{{ object.category }}</a>
</td>
{% else %}
<td class="objecttable-data">
<a class="celllink">-------</a>
</td>
{% endif %}
<td class="objecttable-data">
<a class="celllink">{{ object.removed_date }}</a>
</td>
<td class="objecttable-data">
<a class="celllink">{{ object.user_added }}</a>
</td>
</tr>
{% endif %}
{% endfor %}
</table>
</div>
</body>
<script>
function delcat(id) {