Renaming IsPlaceSubmitter
This commit is contained in:
		@@ -53,7 +53,7 @@ class TestIsAuthenticatedMixin(TestCase):
 | 
			
		||||
        self.assertTrue(response.context['messages'])
 | 
			
		||||
        self.assertTrue(len(response.context['messages']) > 0)
 | 
			
		||||
 | 
			
		||||
class TestIsPlaceSubmitter(TestCase):
 | 
			
		||||
class TestIsPlaceSubmitterMixin(TestCase):
 | 
			
		||||
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def setUpTestData(cls):
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ class IsAuthenticatedMixin(LoginRequiredMixin, View):
 | 
			
		||||
        messages.error(self.request, self.permission_denied_message)
 | 
			
		||||
        return super().handle_no_permission()
 | 
			
		||||
 | 
			
		||||
class IsPlaceSubmitter(UserPassesTestMixin, View):
 | 
			
		||||
class IsPlaceSubmitterMixin(UserPassesTestMixin, View):
 | 
			
		||||
    '''
 | 
			
		||||
    A view mixin that checks wethe a user is the submitter
 | 
			
		||||
    of a place Throws 403 if the user is not. The subclass 
 | 
			
		||||
@@ -81,7 +81,7 @@ class PlaceAssetCreateView(IsAuthenticatedMixin, SuccessMessageMixin, CreateView
 | 
			
		||||
    def get_success_url(self):
 | 
			
		||||
        return reverse_lazy('place_detail', kwargs={'pk': self.place.id})
 | 
			
		||||
 | 
			
		||||
class PlaceAssetDeleteView(IsAuthenticatedMixin, IsPlaceSubmitter, SingleObjectMixin, View):
 | 
			
		||||
class PlaceAssetDeleteView(IsAuthenticatedMixin, IsPlaceSubmitterMixin, SingleObjectMixin, View):
 | 
			
		||||
    model = None
 | 
			
		||||
    success_message = ''
 | 
			
		||||
    permission_denied_message = ''
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@ from django.shortcuts import render, redirect
 | 
			
		||||
from django.urls import reverse_lazy
 | 
			
		||||
 | 
			
		||||
from lostplaces_app.models import Place, PlaceImage
 | 
			
		||||
from lostplaces_app.views import IsAuthenticatedMixin, IsPlaceSubmitter
 | 
			
		||||
from lostplaces_app.views import IsAuthenticatedMixin, IsPlaceSubmitterMixin
 | 
			
		||||
from lostplaces_app.forms import PlaceForm, PlaceImageCreateForm, TagSubmitForm
 | 
			
		||||
 | 
			
		||||
from taggit.models import Tag
 | 
			
		||||
@@ -48,7 +48,7 @@ class PlaceDetailView(IsAuthenticatedMixin, View):
 | 
			
		||||
        }
 | 
			
		||||
        return render(request, 'place/place_detail.html', context)
 | 
			
		||||
 | 
			
		||||
class PlaceUpdateView(IsAuthenticatedMixin, IsPlaceSubmitter, SuccessMessageMixin, UpdateView):
 | 
			
		||||
class PlaceUpdateView(IsAuthenticatedMixin, IsPlaceSubmitterMixin, SuccessMessageMixin, UpdateView):
 | 
			
		||||
    template_name = 'place/place_update.html'
 | 
			
		||||
    model = Place
 | 
			
		||||
    form_class = PlaceForm
 | 
			
		||||
@@ -117,7 +117,7 @@ class PlaceCreateView(IsAuthenticatedMixin, View):
 | 
			
		||||
            )
 | 
			
		||||
            place_image.save()
 | 
			
		||||
 | 
			
		||||
class PlaceDeleteView(IsAuthenticatedMixin, IsPlaceSubmitter, DeleteView):
 | 
			
		||||
class PlaceDeleteView(IsAuthenticatedMixin, IsPlaceSubmitterMixin, DeleteView):
 | 
			
		||||
    template_name = 'place/place_delete.html'
 | 
			
		||||
    model = Place
 | 
			
		||||
    success_message = 'Successfully deleted place.'
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user