fix: attribute error on org list page

Error for organisations with no AnswerSet
This commit is contained in:
James Graham
2021-03-09 17:43:46 +00:00
parent 989c8141b3
commit 97473a46e2

View File

@@ -71,14 +71,18 @@ class OrganisationListView(LoginRequiredMixin, ListView):
answers = organisation.current_answers
country = 'Unknown'
if len(answers.countries) == 1:
country = answers.countries[0].name
try:
if len(answers.countries) == 1:
country = answers.countries[0].name
elif len(answers.countries) > 1:
country = 'International'
elif len(answers.countries) > 1:
country = 'International'
if answers.is_partner_organisation:
country = f'{settings.PARENT_PROJECT_NAME} partners'
if answers.is_partner_organisation:
country = f'{settings.PARENT_PROJECT_NAME} partners'
except AttributeError:
# Organisation has no AnswerSet - country is 'Unknown'
orgs = orgs_by_country.get(country, [])
orgs.append(organisation)