Skip to content

Commit

Permalink
Fix issues with attempts to access empty datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
c-e-p committed Apr 19, 2024
1 parent 48a4b90 commit 63387c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ourchive_app/frontend/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ def load_settings(request):

def load_announcements(request):
announcements = do_get(f'api/adminannouncements/active', request).response_data
announcements = [x for x in announcements['results'] if not request.COOKIES.get(f'dismiss_announcement_{x["id"]}')]
announcements = [x for x in announcements.get('results', []) if not request.COOKIES.get(f'dismiss_announcement_{x["id"]}')]
return {'admin_announcements': announcements}
3 changes: 2 additions & 1 deletion ourchive_app/frontend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@

logger = logging.getLogger(__name__)


def index(request):
top_tags = []
recent_works = []
response = do_get(f'api/tags/top', request, params=request.GET, object_name='top tags')
if response.response_info.status_code >= 200 and response.response_info.status_code < 300:
top_tags = response.response_data['results']
top_tags = sorted(top_tags, key=itemgetter('tag_count'), reverse=True)
highest_count = top_tags[0]['tag_count']
highest_count = top_tags[0]['tag_count'] if len(top_tags) > 0 else 0
tag_max_size = 3
for tag in top_tags:
tag_count = tag['tag_count']
Expand Down

0 comments on commit 63387c0

Please sign in to comment.