From 6421e4f5be7cd5745276a978c6a2ae5941c89e48 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Thu, 18 Jul 2024 09:20:31 +0700 Subject: [PATCH] Fix value error for new org image --- judge/views/contests.py | 7 ++++--- templates/site-logo-fragment.html | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/judge/views/contests.py b/judge/views/contests.py index e1ca582..f60032f 100644 --- a/judge/views/contests.py +++ b/judge/views/contests.py @@ -417,13 +417,14 @@ class ContestMixin(object): self.request.user ) context["logo_override_image"] = self.object.logo_override_image + if ( not context["logo_override_image"] and self.object.organizations.count() == 1 ): - context[ - "logo_override_image" - ] = self.object.organizations.first().organization_image.url + org_image = self.object.organizations.first().organization_image + if org_image: + context["logo_override_image"] = org_image.url return context diff --git a/templates/site-logo-fragment.html b/templates/site-logo-fragment.html index 8133b6f..7b47f7b 100644 --- a/templates/site-logo-fragment.html +++ b/templates/site-logo-fragment.html @@ -1,6 +1,6 @@ {% if request.in_contest_mode and request.participation.contest.logo_override_image %} {{ SITE_NAME }} -{% elif request.organization %} +{% elif request.organization and request.organization.organization_image %} {{ SITE_NAME }} {% elif organization_image is defined and organization_image %} {{ SITE_NAME }}