Skip to content

Commit 94501fa

Browse files
authored
Admins should have access to draft content (#1853)
1 parent 9b12ae0 commit 94501fa

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

posts/models.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,13 @@ def annotate_user_permission(self, user: User = None):
253253
ObjectPermission.CURATOR,
254254
]
255255
)
256-
& Q(curation_status=Post.CurationStatus.PENDING)
256+
& Q(
257+
# Admins should have access to draft and pending content
258+
curation_status__in=[
259+
Post.CurationStatus.DRAFT,
260+
Post.CurationStatus.PENDING,
261+
]
262+
)
257263
)
258264
| (
259265
Q(_user_permission__isnull=False)

tests/unit/test_posts/test_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ def test_non_approved_queryset(self, user1, user2):
200200

201201
# Post exists for creator
202202
assert Post.objects.filter_permission(user=user1).filter(pk=p1.pk).exists()
203-
# Draft post should not be visible to anyone except creators
204-
assert not Post.objects.filter_permission(user=user3).filter(pk=p1.pk).exists()
203+
# Draft post should not be visible to anyone except creators and admins/curators
204+
assert Post.objects.filter_permission(user=user3).filter(pk=p1.pk).exists()
205205
# Post is not visible for Forecaster
206206
assert not Post.objects.filter_permission(user=user2).filter(pk=p1.pk).exists()
207207
# Post is not visible for a random user

0 commit comments

Comments
 (0)