Skip to content

Commit

Permalink
added copy funtion for stelle as well
Browse files Browse the repository at this point in the history
  • Loading branch information
csae8092 committed Apr 1, 2022
1 parent 2477d1c commit 5379d4e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
22 changes: 21 additions & 1 deletion archiv/copy_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.shortcuts import redirect
from django.contrib.auth.decorators import login_required

from archiv.models import SpatialCoverage
from archiv.models import SpatialCoverage, Stelle


@login_required
Expand All @@ -21,3 +21,23 @@ def copy_beleg(request):
item.save()
item.stelle.set(stellen)
return redirect(item.get_edit_url())


@login_required
def copy_stelle(request):
try:
current_id = request.GET['current-id']
except KeyError:
return redirect('/')
try:
item = Stelle.objects.get(id=current_id)
except (ObjectDoesNotExist, ValueError):
return redirect('/')
use_case = item.use_case.all()
item.id = None
item.zitat = "###KOPIE###"
item.summary = "###KOPIE###"
item.lemmata = None
item.save()
item.use_case.set(use_case)
return redirect(item.get_edit_url())
1 change: 0 additions & 1 deletion archiv/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,6 @@ class SpatialCoverage(models.Model):
is_public=True,
arche_prop="hasSubject",
)

kommentar = models.TextField(
blank=True, null=True,
verbose_name="Comment",
Expand Down
17 changes: 6 additions & 11 deletions archiv/templates/archiv/spatial_coverage_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,19 @@ <h2 >
<a href="{{ object.get_edit_url }}" title="edit">
<i data-feather="edit"></i>
</a>
<a href="{{ object.get_delete_url }}" title="delete">
<i data-feather="delete"></i>
</a>
<a href="{% url 'archiv:copy_beleg' %}?current-id={{object.id}}" title="copy">
<i data-feather="copy"></i>
</a>
{% endif %}
{% if 'archeutils' in APPS %}
<a href="{% url 'archeutils:res_as_arche_graph' app_name=app_name model_name=class_name|lower pk=object.id %}" title="As ARCHE-RDF">
<i data-feather="download"></i>
</a>
{% endif%}
</h2>
<h4><a href="{% url 'archiv:copy_beleg' %}?current-id={{object.id}}" title="copy">
<i data-feather="copy"></i>
</a></h5>
</div>
<div class="col-md-2">
<h2>
Expand Down Expand Up @@ -220,14 +223,6 @@ <h2>
</div>

</div>
{% if user.is_authenticated %}
<div class="card-footer" style="text-align: right;">
<a href="{{ object.get_delete_url }}" title="delete">
<i data-feather="delete"></i>
</a>
</div>
{% endif %}

</div>
</div>
{% endblock custom %}
Expand Down
5 changes: 4 additions & 1 deletion archiv/templates/archiv/stelle_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h2>
</h2>
{% endif %}
</div>
<div class="col-md-8">
<div class="col-md-8" style="text-align: center;">
<h2 style="text-align: center;">
<small><a href="{{ object.get_listview_url }}" title="back to listview"><small>{{ class_name }}</small></a></small>
{{ object }}
Expand All @@ -41,6 +41,9 @@ <h2 style="text-align: center;">
<a href="{{ object.get_delete_url }}" title="delete">
<i data-feather="delete"></i>
</a>
<a href="{% url 'archiv:copy_stelle' %}?current-id={{object.id}}" title="copy">
<i data-feather="copy"></i>
</a>
{% endif %}
{% if 'archeutils' in APPS %}
<a href="{% url 'archeutils:res_as_arche_graph' app_name=app_name model_name=class_name|lower pk=object.id %}" title="As ARCHE-RDF">
Expand Down
5 changes: 5 additions & 0 deletions archiv/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
copy_views.copy_beleg,
name='copy_beleg'
),
url(
r'^stelle-copy/$',
copy_views.copy_stelle,
name='copy_stelle'
),
url(
r'^usecase/$',
views.UseCaseListView.as_view(),
Expand Down

0 comments on commit 5379d4e

Please sign in to comment.