#64 place mode and filtering of place modes in list views
This commit is contained in:
@@ -82,9 +82,25 @@ class Explorer(models.Model):
|
||||
choices=EXPLORER_LEVELS
|
||||
)
|
||||
|
||||
def get_place_list_to_display(self):
|
||||
'''
|
||||
Gets the list of places to show on the homepage
|
||||
and the list views
|
||||
'''
|
||||
if self.user.is_superuser:
|
||||
return Place.objects.filter(mode='live')
|
||||
|
||||
return Place.objects.filter(
|
||||
level__lte=self.level,
|
||||
mode='live'
|
||||
) | Place.objects.filter(
|
||||
submitted_by=self,
|
||||
mode='live'
|
||||
)
|
||||
|
||||
def get_places_eligible_to_see(self):
|
||||
if self.user.is_superuser:
|
||||
return Place.objects.all()
|
||||
return Place.objects.filter(mode='live')
|
||||
return Place.objects.all().filter(level__lte=self.level) | self.places.all()
|
||||
|
||||
def is_eligible_to_see(self, place):
|
||||
|
||||
@@ -23,6 +23,13 @@ PLACE_LEVELS = (
|
||||
(5, 'Time Capsule')
|
||||
)
|
||||
|
||||
PLACE_MODES = (
|
||||
('live', 'live'),
|
||||
('draft', 'draft'),
|
||||
('review', 'review'),
|
||||
('archive', 'archive')
|
||||
)
|
||||
|
||||
class Place(Submittable, Taggable, Mapable):
|
||||
"""
|
||||
Place defines a lost place (location, name, description etc.).
|
||||
@@ -40,7 +47,7 @@ class Place(Submittable, Taggable, Mapable):
|
||||
hero = models.ForeignKey(
|
||||
'PlaceImage',
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name='place_heros'
|
||||
)
|
||||
@@ -50,6 +57,12 @@ class Place(Submittable, Taggable, Mapable):
|
||||
choices=PLACE_LEVELS
|
||||
)
|
||||
|
||||
mode = models.TextField(
|
||||
default='live',
|
||||
choices=PLACE_MODES,
|
||||
verbose_name=_('Mode of Place Editing')
|
||||
)
|
||||
|
||||
def get_hero_image(self):
|
||||
if self.hero:
|
||||
return self.hero
|
||||
|
||||
Reference in New Issue
Block a user