Skip to content

Commit

Permalink
Add admin option to manually hide levels from search
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Apr 7, 2022
1 parent f63a5ad commit cc086a1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class Level(models.Model):
comment = models.TextField(blank=True, null=True)
is_public = models.BooleanField(blank=True, null=True, db_index=True) #this is to prevent leaking unlisted levels publicly
is_deleted = models.BooleanField(blank=True, null=True, db_index=True)
hide_from_search = models.BooleanField(db_index=True, default=False)

cache_level_name = models.CharField(blank=True, null=True, max_length=255, db_index=True)
cache_submitted = models.DateTimeField(blank=True, null=True, db_index=True)
Expand Down
2 changes: 1 addition & 1 deletion history/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def search(request):

query_filter = Q(cache_level_name__icontains=query) | Q(online_id=query) if query.isnumeric() else Q(cache_level_name__icontains=query)

levels = Level.objects.filter(query_filter).filter(is_public=True)
levels = Level.objects.filter(query_filter).filter(is_public=True, hide_from_search=False)

#TODO: better implement admin search filters
if request.user.is_authenticated and query == 'admin:private' and request.user.is_superuser:
Expand Down

0 comments on commit cc086a1

Please sign in to comment.