Merge remote-tracking branch 'origin/develop' into feature/50-Linktypes

This commit is contained in:
2021-10-02 02:47:42 +02:00
10 changed files with 216 additions and 21 deletions

View File

@@ -82,6 +82,18 @@ class Explorer(models.Model):
choices=EXPLORER_LEVELS
)
def get_places_eligible_to_see(self):
if self.user.is_superuser:
return Place.objects.all()
return Place.objects.all().filter(level__lte=self.level) | self.places.all()
def is_eligible_to_see(self, place):
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