diff --git a/lostplaces/lostplaces_app/templates/partials/tagging.html b/lostplaces/lostplaces_app/templates/partials/tagging.html index 471f880..264a847 100644 --- a/lostplaces/lostplaces_app/templates/partials/tagging.html +++ b/lostplaces/lostplaces_app/templates/partials/tagging.html @@ -1,6 +1,6 @@
-
+
Tags hinzufügen {% csrf_token %} @@ -46,14 +46,10 @@ submit_form.onsubmit = () => false const tagify = new Tagify(input, { - 'whitelist': [{ - % - for tag in all_tags % - } + 'whitelist': [ + {% for tag in config.tagged_item.tags.all %} '{{tag}}', - { - % endfor % - } + {% endfor %} ] }) diff --git a/lostplaces/lostplaces_app/templates/place/place_detail.html b/lostplaces/lostplaces_app/templates/place/place_detail.html index 23eece1..5c6e501 100644 --- a/lostplaces/lostplaces_app/templates/place/place_detail.html +++ b/lostplaces/lostplaces_app/templates/place/place_detail.html @@ -37,7 +37,7 @@
{% url 'place_tag_submit' place_id=place.id as tag_submit_url%} - {% include 'partials/tagging.html' with tag_list=place.tags.all config=tagging_config all_tags=all_tags %} + {% include 'partials/tagging.html' with config=tagging_config %}
diff --git a/lostplaces/lostplaces_app/urls.py b/lostplaces/lostplaces_app/urls.py index 2e7262d..8d88f6d 100644 --- a/lostplaces/lostplaces_app/urls.py +++ b/lostplaces/lostplaces_app/urls.py @@ -25,6 +25,6 @@ urlpatterns = [ path('flat//', FlatView, name='flatpage'), # POST-only URLs for tag submission - path('place/tag/', PlaceTagSubmitView.as_view(), name='place_tag_submit'), + path('place/tag/', PlaceTagSubmitView.as_view(), name='place_tag_submit'), path('place/tag/delete//', PlaceTagDeleteView.as_view(), name='place_tag_delete') ] diff --git a/lostplaces/lostplaces_app/views/place_views.py b/lostplaces/lostplaces_app/views/place_views.py index 4855b20..9f762d7 100644 --- a/lostplaces/lostplaces_app/views/place_views.py +++ b/lostplaces/lostplaces_app/views/place_views.py @@ -33,11 +33,11 @@ class PlaceDetailView(IsAuthenticated, View): 'place': place, 'place_list': [ place ], 'place_map_center': [ place.latitude, place.longitude ], - 'all_tags': Tag.objects.all(), 'tagging_config': { - 'submit_url': reverse_lazy('place_tag_submit', kwargs={'place_id': place.id}), + 'all_tags': Tag.objects.all(), 'submit_form': TagSubmitForm(), 'tagged_item': place, + 'submit_url_name': 'place_tag_submit', 'delete_url_name': 'place_tag_delete' } } diff --git a/lostplaces/lostplaces_app/views/views.py b/lostplaces/lostplaces_app/views/views.py index 8b2c1ef..b0c29c2 100644 --- a/lostplaces/lostplaces_app/views/views.py +++ b/lostplaces/lostplaces_app/views/views.py @@ -54,8 +54,8 @@ class PhotoAlbumDeleteView(PlaceAssetDeleteView): permission_denied_messsage = 'You do not have permissions to alter this photo album' class PlaceTagSubmitView(IsAuthenticated, View): - def post(self, request, place_id, *args, **kwargs): - place = Place.objects.get(pk=place_id) + def post(self, request, tagged_id, *args, **kwargs): + place = Place.objects.get(pk=tagged_id) form = TagSubmitForm(request.POST) if form.is_valid(): tag_list_raw = form.cleaned_data['tag_list']