Refactoring tagging
This commit is contained in:
parent
317437fedc
commit
7f73035b02
@ -1,6 +1,6 @@
|
|||||||
<div class="LP-TagList">
|
<div class="LP-TagList">
|
||||||
<ul class="LP-TagList__List">
|
<ul class="LP-TagList__List">
|
||||||
{% for tag in tag_list %}
|
{% for tag in config.tagged_item.tags.all %}
|
||||||
<li class="LP-TagList__Item">
|
<li class="LP-TagList__Item">
|
||||||
<div class="LP-Tag">
|
<div class="LP-Tag">
|
||||||
<a href="#" class="LP-Link">
|
<a href="#" class="LP-Link">
|
||||||
@ -23,7 +23,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form id="id_tag_submit_form" class="LP-Form LP-Form--inline LP-Form--tagging" method="POST" action="{{config.submit_url}}">
|
<form id="id_tag_submit_form" class="LP-Form LP-Form--inline LP-Form--tagging" method="POST" action="{% url config.submit_url_name tagged_id=config.tagged_item.id%}">
|
||||||
<fieldset class="LP-Form__Fieldset">
|
<fieldset class="LP-Form__Fieldset">
|
||||||
<legend class="LP-Form__Legend">Tags hinzufügen</legend>
|
<legend class="LP-Form__Legend">Tags hinzufügen</legend>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
@ -46,14 +46,10 @@
|
|||||||
submit_form.onsubmit = () => false
|
submit_form.onsubmit = () => false
|
||||||
|
|
||||||
const tagify = new Tagify(input, {
|
const tagify = new Tagify(input, {
|
||||||
'whitelist': [{
|
'whitelist': [
|
||||||
%
|
{% for tag in config.tagged_item.tags.all %}
|
||||||
for tag in all_tags %
|
|
||||||
}
|
|
||||||
'{{tag}}',
|
'{{tag}}',
|
||||||
{
|
{% endfor %}
|
||||||
% endfor %
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
<section class="LP-Section">
|
<section class="LP-Section">
|
||||||
|
|
||||||
{% url 'place_tag_submit' place_id=place.id as tag_submit_url%}
|
{% 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 %}
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -25,6 +25,6 @@ urlpatterns = [
|
|||||||
path('flat/<slug:slug>/', FlatView, name='flatpage'),
|
path('flat/<slug:slug>/', FlatView, name='flatpage'),
|
||||||
|
|
||||||
# POST-only URLs for tag submission
|
# POST-only URLs for tag submission
|
||||||
path('place/tag/<int:place_id>', PlaceTagSubmitView.as_view(), name='place_tag_submit'),
|
path('place/tag/<int:tagged_id>', PlaceTagSubmitView.as_view(), name='place_tag_submit'),
|
||||||
path('place/tag/delete/<int:tagged_id>/<int:tag_id>', PlaceTagDeleteView.as_view(), name='place_tag_delete')
|
path('place/tag/delete/<int:tagged_id>/<int:tag_id>', PlaceTagDeleteView.as_view(), name='place_tag_delete')
|
||||||
]
|
]
|
||||||
|
@ -33,11 +33,11 @@ class PlaceDetailView(IsAuthenticated, View):
|
|||||||
'place': place,
|
'place': place,
|
||||||
'place_list': [ place ],
|
'place_list': [ place ],
|
||||||
'place_map_center': [ place.latitude, place.longitude ],
|
'place_map_center': [ place.latitude, place.longitude ],
|
||||||
'all_tags': Tag.objects.all(),
|
|
||||||
'tagging_config': {
|
'tagging_config': {
|
||||||
'submit_url': reverse_lazy('place_tag_submit', kwargs={'place_id': place.id}),
|
'all_tags': Tag.objects.all(),
|
||||||
'submit_form': TagSubmitForm(),
|
'submit_form': TagSubmitForm(),
|
||||||
'tagged_item': place,
|
'tagged_item': place,
|
||||||
|
'submit_url_name': 'place_tag_submit',
|
||||||
'delete_url_name': 'place_tag_delete'
|
'delete_url_name': 'place_tag_delete'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,8 @@ class PhotoAlbumDeleteView(PlaceAssetDeleteView):
|
|||||||
permission_denied_messsage = 'You do not have permissions to alter this photo album'
|
permission_denied_messsage = 'You do not have permissions to alter this photo album'
|
||||||
|
|
||||||
class PlaceTagSubmitView(IsAuthenticated, View):
|
class PlaceTagSubmitView(IsAuthenticated, View):
|
||||||
def post(self, request, place_id, *args, **kwargs):
|
def post(self, request, tagged_id, *args, **kwargs):
|
||||||
place = Place.objects.get(pk=place_id)
|
place = Place.objects.get(pk=tagged_id)
|
||||||
form = TagSubmitForm(request.POST)
|
form = TagSubmitForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
tag_list_raw = form.cleaned_data['tag_list']
|
tag_list_raw = form.cleaned_data['tag_list']
|
||||||
|
Loading…
Reference in New Issue
Block a user