From 9852646fff14ccbbee306cba5e05b3db98e130de Mon Sep 17 00:00:00 2001 From: reverend Date: Sun, 13 Sep 2020 10:57:53 +0200 Subject: [PATCH] Renaming IsPlaceSubmitter --- lostplaces/lostplaces_app/tests/views/test_base_views.py | 2 +- lostplaces/lostplaces_app/views/base_views.py | 4 ++-- lostplaces/lostplaces_app/views/place_views.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lostplaces/lostplaces_app/tests/views/test_base_views.py b/lostplaces/lostplaces_app/tests/views/test_base_views.py index e5a5218..5efa093 100644 --- a/lostplaces/lostplaces_app/tests/views/test_base_views.py +++ b/lostplaces/lostplaces_app/tests/views/test_base_views.py @@ -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): diff --git a/lostplaces/lostplaces_app/views/base_views.py b/lostplaces/lostplaces_app/views/base_views.py index 9dbab24..da2c8bf 100644 --- a/lostplaces/lostplaces_app/views/base_views.py +++ b/lostplaces/lostplaces_app/views/base_views.py @@ -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 = '' diff --git a/lostplaces/lostplaces_app/views/place_views.py b/lostplaces/lostplaces_app/views/place_views.py index 5d991ee..1a94c1c 100644 --- a/lostplaces/lostplaces_app/views/place_views.py +++ b/lostplaces/lostplaces_app/views/place_views.py @@ -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.'