Merge remote-tracking branch 'origin/master' into feature/unauth_content
This commit is contained in:
		@@ -11,7 +11,9 @@ from django.urls import reverse_lazy
 | 
			
		||||
 | 
			
		||||
from lostplaces_app.models import Place, PlaceImage
 | 
			
		||||
from lostplaces_app.views import IsAuthenticated, IsPlaceSubmitter
 | 
			
		||||
from lostplaces_app.forms import PlaceForm, PlaceImageCreateForm
 | 
			
		||||
from lostplaces_app.forms import PlaceForm, PlaceImageCreateForm, TagSubmitForm
 | 
			
		||||
 | 
			
		||||
from taggit.models import Tag
 | 
			
		||||
 | 
			
		||||
class PlaceListView(IsAuthenticated, ListView):
 | 
			
		||||
    paginate_by = 5
 | 
			
		||||
@@ -30,7 +32,14 @@ class PlaceDetailView(IsAuthenticated, View):
 | 
			
		||||
        context = {
 | 
			
		||||
            'place': 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': {
 | 
			
		||||
                '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,15 +5,19 @@ from django.contrib.messages.views import SuccessMessageMixin
 | 
			
		||||
from django.contrib import messages
 | 
			
		||||
from django.urls import reverse_lazy
 | 
			
		||||
from django.shortcuts import render, redirect, get_object_or_404
 | 
			
		||||
from django.http import HttpResponseForbidden
 | 
			
		||||
 | 
			
		||||
from lostplaces_app.forms import ExplorerCreationForm
 | 
			
		||||
from lostplaces_app.forms import ExplorerCreationForm, TagSubmitForm
 | 
			
		||||
from lostplaces_app.models import Place, PhotoAlbum
 | 
			
		||||
from lostplaces_app.views import IsAuthenticated
 | 
			
		||||
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')
 | 
			
		||||
@@ -49,5 +53,27 @@ class PhotoAlbumDeleteView(PlaceAssetDeleteView):
 | 
			
		||||
    success_message = 'Photo Album deleted'
 | 
			
		||||
    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)
 | 
			
		||||
		form = TagSubmitForm(request.POST)
 | 
			
		||||
		if form.is_valid():
 | 
			
		||||
			tag_list_raw = form.cleaned_data['tag_list']
 | 
			
		||||
			tag_list_raw = tag_list_raw.strip().split(',')
 | 
			
		||||
			tag_list = []
 | 
			
		||||
			for tag in tag_list_raw:
 | 
			
		||||
				tag_list.append(tag.strip())
 | 
			
		||||
			place.tags.add(*tag_list)
 | 
			
		||||
			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}))
 | 
			
		||||
 | 
			
		||||
def FlatView(request, slug):
 | 
			
		||||
    return render(request, 'flat/' + slug + '.html')
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user