Deletion of tags
This commit is contained in:
@@ -33,8 +33,13 @@ class PlaceDetailView(IsAuthenticated, View):
|
||||
'place': place,
|
||||
'place_list': [ place ],
|
||||
'place_map_center': [ place.latitude, place.longitude ],
|
||||
'tagging_form': TagSubmitForm(),
|
||||
'all_tags': Tag.objects.all()
|
||||
'all_tags': Tag.objects.all(),
|
||||
'tagging_config': {
|
||||
'submit_url': reverse_lazy('place_tag_submit', kwargs={'place_id': place.id}),
|
||||
'submit_form': TagSubmitForm(),
|
||||
'tagged_item': place,
|
||||
'delete_url_name': 'place_tag_delete'
|
||||
}
|
||||
}
|
||||
return render(request, 'place/place_detail.html', context)
|
||||
|
||||
|
@@ -5,6 +5,7 @@ from django.contrib.messages.views import SuccessMessageMixin
|
||||
from django.contrib import messages
|
||||
from django.urls import reverse_lazy
|
||||
from django.shortcuts import render, redirect
|
||||
from django.http import HttpResponseForbidden
|
||||
|
||||
from lostplaces_app.forms import ExplorerCreationForm, TagSubmitForm
|
||||
from lostplaces_app.models import Place, PhotoAlbum
|
||||
@@ -12,8 +13,11 @@ from lostplaces_app.views.base_views import IsAuthenticated
|
||||
|
||||
from lostplaces_app.views.base_views import (
|
||||
PlaceAssetCreateView,
|
||||
PlaceAssetDeleteView
|
||||
PlaceAssetDeleteView,
|
||||
)
|
||||
|
||||
from taggit.models import Tag
|
||||
|
||||
class SignUpView(SuccessMessageMixin, CreateView):
|
||||
form_class = ExplorerCreationForm
|
||||
success_url = reverse_lazy('login')
|
||||
@@ -56,3 +60,10 @@ class PlaceTagSubmitView(IsAuthenticated, View):
|
||||
place.save()
|
||||
|
||||
return redirect(reverse_lazy('place_detail', kwargs={'pk': place.id}))
|
||||
|
||||
class PlaceTagDeleteView(IsAuthenticated, View):
|
||||
def get(self, request, tagged_id, tag_id, *args, **kwargs):
|
||||
place = Place.objects.get(pk=tagged_id)
|
||||
tag = Tag.objects.get(pk=tag_id)
|
||||
place.tags.remove(tag)
|
||||
return redirect(reverse_lazy('place_detail', kwargs={'pk': tagged_id}))
|
Reference in New Issue
Block a user