From 84b01f3a9a362d3c6aa44ff83e984d9b62e585f2 Mon Sep 17 00:00:00 2001 From: reverend Date: Fri, 1 Oct 2021 23:44:46 +0200 Subject: [PATCH] #42 Place submitter and super users should be able to see a place --- django_lostplaces/lostplaces/models/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/django_lostplaces/lostplaces/models/models.py b/django_lostplaces/lostplaces/models/models.py index 9ed5f05..74ca406 100644 --- a/django_lostplaces/lostplaces/models/models.py +++ b/django_lostplaces/lostplaces/models/models.py @@ -86,7 +86,11 @@ class Explorer(models.Model): return Place.objects.all().filter(level__lte=self.level) def is_eligible_to_see(self, place): - return place in self.get_places_eligible_to_see() + return ( + self.user.is_superuser or + place.submitted_by == self or + place in self.get_places_eligible_to_see() + ) def __str__(self): return self.user.username