UEWBot / dipvis

Django-based visualiser for tournaments for the boardgame Diplomacy
GNU General Public License v3.0
7 stars 5 forks source link

Exception in game details page #240

Closed UEWBot closed 1 year ago

UEWBot commented 1 year ago

When a game doesn’t have powers assigned. “final_sc” is None, so we can’t access its “count” attribute

UEWBot commented 1 year ago

Template error: In template /home/ubuntu/dipvis/visualiser/tournament/templates/base.html, error at line 0 'NoneType' object has no attribute 'count' 1 : {% load i18n %} 2 : {% load static %} 3 : <!DOCTYPE html> 4 : {% get_current_language as LANGUAGE_CODE %} 5 : 6 : 7 : 8 : 9 : {% if redirect_url %} 10 :

Traceback:

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner

  1. response = get_response(request)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response

  1. response = self.process_exception_by_middleware(e, request)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response

  1. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/ubuntu/dipvis/visualiser/tournament/game_views.py" in game_simple

  1. return render(request, 'games/%s.html' % template, context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/shortcuts.py" in render

  1. content = loader.render_to_string(template_name, context, request, using=using)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/loader.py" in render_to_string

  1. return template.render(context, request)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/backends/django.py" in render

  1. return self.template.render(context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/base.py" in render

  1. return self._render(context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/base.py" in _render

  1. return self.nodelist.render(context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/base.py" in render

  1. bit = node.render_annotated(context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/base.py" in render_annotated

  1. return self.render(context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/loader_tags.py" in render

  1. return compiled_parent._render(context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/base.py" in _render

  1. return self.nodelist.render(context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/base.py" in render

  1. bit = node.render_annotated(context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/base.py" in render_annotated

  1. return self.render(context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/loader_tags.py" in render

  1. result = block.nodelist.render(context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/base.py" in render

  1. bit = node.render_annotated(context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/base.py" in render_annotated

  1. return self.render(context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/defaulttags.py" in render

  1. nodelist.append(node.render_annotated(context))

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/base.py" in render_annotated

  1. return self.render(context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/base.py" in render

  1. output = self.filter_expression.resolve(context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/base.py" in resolve

  1. obj = self.var.resolve(context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/base.py" in resolve

  1. value = self._resolve_lookup(context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/template/base.py" in _resolve_lookup

  1. current = current()

File "/home/ubuntu/dipvis/visualiser/tournament/models.py" in result_str

  1. if final_sc.count == 0:

Exception Type: AttributeError at /tournaments/9/games/R2GA/ Exception Value: 'NoneType' object has no attribute 'count'

UEWBot commented 1 year ago

Note that after the "get seven" page, we return with an error if powers aren't assigned to players, but in reality the Games have already been created in the database, so the links to the game details page is valid.