From 376c8cdff390f0f08909b05ae08a0a373309a707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80=20=D0=93=D0=BB=D0=B0?= =?UTF-8?q?=D0=B4=D0=BA=D0=B8=D1=85?= Date: Fri, 22 Nov 2019 16:00:59 +0300 Subject: [PATCH] State test news with contentpage permission --- apps/news/tests.py | 3 ++- apps/utils/models.py | 4 ---- apps/utils/permissions.py | 10 ++-------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/apps/news/tests.py b/apps/news/tests.py index c2b2e431..74563ca4 100644 --- a/apps/news/tests.py +++ b/apps/news/tests.py @@ -119,7 +119,8 @@ class NewsTestCase(BaseTestCase): 'slug': self.test_news.slug, 'start': self.test_news.start, 'news_type_id': self.test_news.news_type_id, - 'country_id': self.country_ru.id + 'country_id': self.country_ru.id, + "site_id": self.site_ru.id } response = self.client.put(url, data=data, format='json') diff --git a/apps/utils/models.py b/apps/utils/models.py index 8c186f2f..ebfd9a81 100644 --- a/apps/utils/models.py +++ b/apps/utils/models.py @@ -36,10 +36,6 @@ class ProjectBaseMixin(models.Model): abstract = True -def valid(value): - print("Run") - - class TJSONField(JSONField): """Overrided JsonField.""" diff --git a/apps/utils/permissions.py b/apps/utils/permissions.py index c53f3962..8ac8f0d0 100644 --- a/apps/utils/permissions.py +++ b/apps/utils/permissions.py @@ -118,15 +118,9 @@ class IsContentPageManager(IsStandardUser): super().has_permission(request, view) ] # and request.user.email_confirmed, - if hasattr(request, 'user'): - site_id = None - if hasattr(request, 'data'): - site_id = request.data['site_id'] - else: - site_id = request.site_id - + if hasattr(request, 'user') and hasattr(request.data, 'site_id'): role = Role.objects.filter(role=Role.CONTENT_PAGE_MANAGER, - site_id=site_id) \ + site_id=request.data.site_id,) \ .first() # 'Comments moderator' rules = [