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:
parent
d5da34ff86
commit
6e2eec0c6e
2 changed files with 66 additions and 20 deletions
|
|
@ -2,6 +2,8 @@ from django.shortcuts import render, get_object_or_404
|
||||||
from object_adder.models import Object, Category
|
from object_adder.models import Object, Category
|
||||||
from object_adder.forms import ObjectForm
|
from object_adder.forms import ObjectForm
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -76,7 +78,8 @@ def objlist(request, orderstr=None):
|
||||||
@login_required
|
@login_required
|
||||||
def delete(request, uuid_url):
|
def delete(request, uuid_url):
|
||||||
obj = get_object_or_404(Object, pk=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})
|
return render(request, 'object_lister/delete.html', {'uuid': uuid_url})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
|
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
|
||||||
Abbruch.
|
Abbruch.
|
||||||
</div>
|
</div>
|
||||||
|
<h3>Inventarisierte Objekte</h3>
|
||||||
<form>
|
<form>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<table class="objecttable">
|
<table class="objecttable">
|
||||||
|
|
@ -23,35 +24,38 @@
|
||||||
<th class="objecttable-head"><a href="./4">Hinzugefügt von</a></th>
|
<th class="objecttable-head"><a href="./4">Hinzugefügt von</a></th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for object in objects %}
|
{% for object in objects %}
|
||||||
<tr class="objecttable-row">
|
{% if object.removed_date is None %}
|
||||||
<td class="objecttable-data">
|
<tr class="objecttable-row">
|
||||||
<a class="celllink" href="./{{ object.uuid }}">{{ object.title }}</a>
|
|
||||||
</td>
|
|
||||||
<td class="objecttable-data">
|
|
||||||
<a class="celllink" href="./{{ object.uuid }}">{{ object.ammout }}</a>
|
|
||||||
</td>
|
|
||||||
{% if object.category is not None %}
|
|
||||||
<td class="objecttable-data">
|
<td class="objecttable-data">
|
||||||
<a class="celllink" href="./{{ object.uuid }}">{{ object.category }}</a>
|
<a class="celllink" href="./{{ object.uuid }}">{{ object.title }}</a>
|
||||||
</td>
|
</td>
|
||||||
{% else %}
|
|
||||||
<td class="objecttable-data">
|
<td class="objecttable-data">
|
||||||
<a class="celllink" href="./{{ object.uuid }}">-------</a>
|
<a class="celllink" href="./{{ object.uuid }}">{{ object.ammout }}</a>
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% if object.category is not None %}
|
||||||
<td class="objecttable-data">
|
<td class="objecttable-data">
|
||||||
<a class="celllink" href="./{{ object.uuid }}">{{ object.inventarized_date }}</a>
|
<a class="celllink" href="./{{ object.uuid }}">{{ object.category }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="objecttable-data">
|
{% else %}
|
||||||
<a class="celllink" href="./{{ object.uuid }}">{{ object.user_added }}</a>
|
<td class="objecttable-data">
|
||||||
</td>
|
<a class="celllink" href="./{{ object.uuid }}">-------</a>
|
||||||
</tr>
|
</td>
|
||||||
|
{% endif %}
|
||||||
|
<td class="objecttable-data">
|
||||||
|
<a class="celllink" href="./{{ object.uuid }}">{{ object.inventarized_date }}</a>
|
||||||
|
</td>
|
||||||
|
<td class="objecttable-data">
|
||||||
|
<a class="celllink" href="./{{ object.uuid }}">{{ object.user_added }}</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
<p>{{ objammout }} Objekte insgesamt</p>
|
<p>{{ objammout }} Objekte insgesamt</p>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="container shadow lower-box">
|
<div class="container shadow lower-box">
|
||||||
|
<h3>Kategorien</h3>
|
||||||
<table class="cattable">
|
<table class="cattable">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="objecttable-head leftalign">Kategorie</th>
|
<th class="objecttable-head leftalign">Kategorie</th>
|
||||||
|
|
@ -70,6 +74,45 @@
|
||||||
</table>
|
</table>
|
||||||
<p>{{ ncats }} Kategorien insgesamt</p>
|
<p>{{ ncats }} Kategorien insgesamt</p>
|
||||||
</div>
|
</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>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
function delcat(id) {
|
function delcat(id) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue