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