Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submitting imprint page feedback breaks region feedback list #1289

Closed
melegiul opened this issue Mar 11, 2022 · 4 comments · Fixed by #1360
Closed

Submitting imprint page feedback breaks region feedback list #1289

melegiul opened this issue Mar 11, 2022 · 4 comments · Fixed by #1360
Labels
bug Something isn't working prio: low Not urgent, can be resolved in the distant future.
Milestone

Comments

@melegiul
Copy link
Contributor

Describe the Bug

Submitting imprint page feedback breaks region feedback list

Steps to Reproduce

  1. Submit imprint page feedback (e.g. POST /api/nurnberg/de/feedback/imprint-page)
  2. Go to region feedback list

Expected Behavior

Show region feedback view

Actual Behavior

AttributeError at /nurnberg/feedback/
Exception Value: 'NoneType' object has no attribute 'get_translation'

Additional Information

JSON Body:

{
    "rating": "up",
    "is_technical": "False"
}
Traceback
Environment:


Request Method: GET
Request URL: http://localhost:8008/nurnberg/feedback/

Django Version: 3.2.12
Python Version: 3.9.10
Installed Applications:
['integreat_cms.cms',
'integreat_cms.gvz_api',
'integreat_cms.mylinkcheck.apps.ModifiedLinkcheckConfig',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.messages',
'django.contrib.sessions',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'corsheaders',
'rules.apps.AutodiscoverRulesConfig',
'treebeard',
'webpack_loader',
'widget_tweaks',
'polymorphic',
'cacheops',
'django.contrib.admin',
'debug_toolbar']
Installed Middleware:
['debug_toolbar.middleware.DebugToolbarMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'integreat_cms.core.middleware.RegionMiddleware',
'integreat_cms.core.middleware.AccessControlMiddleware',
'integreat_cms.cms.middleware.TimezoneMiddleware',
'integreat_cms.api.middleware.JsonDebugToolbarMiddleware']


Template error:
In template /home/melegiul/dev/integreat-cms/integreat_cms/cms/templates/_raw.html, error at line 0
 'NoneType' object has no attribute 'get_translation'
 1 : {% load static %}
 2 : {% load i18n %}
 3 : {% load render_bundle from webpack_loader %}
 4 : <!DOCTYPE html>
 5 : <html>
 6 : <head>
 7 :     <meta charset="utf-8" />
 8 :     <meta http-equiv="X-UA-Compatible" content="IE=edge" />
 9 :     <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, shrink-to-fit=no, user-scalable=no" />
 10 :     <title>{% trans 'Integreat Editorial System' %}</title>


Traceback (most recent call last):
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 829, in _resolve_lookup
  current = current[bit]

During handling of the above exception ('ImprintPageFeedback' object is not subscriptable), another exception occurred:
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
  response = get_response(request)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
  response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
  return self.dispatch(request, *args, **kwargs)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/utils/decorators.py", line 43, in _wrapper
  return bound_method(*args, **kwargs)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
  return view_func(request, *args, **kwargs)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/views/generic/base.py", line 98, in dispatch
  return handler(request, *args, **kwargs)
File "/home/melegiul/dev/integreat-cms/integreat_cms/cms/views/feedback/region_feedback_list_view.py", line 119, in get
  return render(
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/shortcuts.py", line 19, in render
  content = loader.render_to_string(template_name, context, request, using=using)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/loader.py", line 62, in render_to_string
  return template.render(context, request)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/backends/django.py", line 61, in render
  return self.template.render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 170, in render
  return self._render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/test/utils.py", line 100, in instrumented_test_render
  return self.nodelist.render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
  bit = node.render_annotated(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
  return self.render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render
  return compiled_parent._render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/test/utils.py", line 100, in instrumented_test_render
  return self.nodelist.render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
  bit = node.render_annotated(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
  return self.render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render
  return compiled_parent._render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/test/utils.py", line 100, in instrumented_test_render
  return self.nodelist.render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
  bit = node.render_annotated(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
  return self.render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/loader_tags.py", line 62, in render
  result = block.nodelist.render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
  bit = node.render_annotated(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
  return self.render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/loader_tags.py", line 62, in render
  result = block.nodelist.render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
  bit = node.render_annotated(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
  return self.render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/defaulttags.py", line 214, in render
  nodelist.append(node.render_annotated(context))
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
  return self.render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/defaulttags.py", line 315, in render
  return nodelist.render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
  bit = node.render_annotated(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
  return self.render(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 988, in render
  output = self.filter_expression.resolve(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 671, in resolve
  obj = self.var.resolve(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 796, in resolve
  value = self._resolve_lookup(context)
File "/home/melegiul/dev/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 837, in _resolve_lookup
  current = getattr(current, bit)
File "/home/melegiul/dev/integreat-cms/integreat_cms/cms/models/feedback/imprint_page_feedback.py", line 23, in object_name
  return self.region.imprint.get_translation(self.language.slug).title

Exception Type: AttributeError at /nurnberg/feedback/
Exception Value: 'NoneType' object has no attribute 'get_translation'

@melegiul melegiul added the bug Something isn't working label Mar 11, 2022
@timobrembeck timobrembeck added this to the Version 1.1 milestone Mar 11, 2022
@timobrembeck timobrembeck added the prio: high Needs to be resolved ASAP. label Mar 11, 2022
@timobrembeck
Copy link
Member

I just noticed the app doesn't have feedback to the disclaimer/imprint anymore:
https://integreat.app/augsburg/de/disclaimer
So probably we can just remove all imprint feedback functionality in the CMS.

@timobrembeck
Copy link
Member

Oh, but the native app still has feedback for the imprint, so we should keep the endpoint.

I just noticed that the bug only exists when the imprint doesn't exist and in this case, it's not possible to submit feedback anyway, so I guess this is more of a theoretical problem. Still valid but with a lower prio.

@timobrembeck timobrembeck added prio: low Not urgent, can be resolved in the distant future. and removed prio: high Needs to be resolved ASAP. labels Mar 11, 2022
@svenseeberg svenseeberg modified the milestones: Version 1.1, Version 1.2 Mar 16, 2022
@ulliholtgrave
Copy link
Member

This was fixed in #1321 and #1312

@timobrembeck
Copy link
Member

I can still reproduce this on develop:

  1. Make sure the imprint does not exist in a specific region, e.g. Augsburg

  2. Simulate feedback from the app:

> curl -X "POST" "http://localhost:8000/api/augsburg/de/feedback/imprint-page" -d 'comment=not%20workingt!!!!1!'
{"success": "Feedback successfully submitted"}
  1. Then open the feedback list http://localhost:8000/augsburg/feedback/
  2. Get the following traceback:
Traceback
Mar 31 13:10:05 ERROR django.request - Internal Server Error: /augsburg/feedback/
Traceback (most recent call last):
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 829, in _resolve_lookup
    current = current[bit]
TypeError: 'ImprintPageFeedback' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/views/generic/base.py", line 98, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/timo/job/integreat/integreat-cms/integreat_cms/cms/views/feedback/region_feedback_list_view.py", line 119, in get
    return render(
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 170, in render
    return self._render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/test/utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/test/utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/test/utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/defaulttags.py", line 214, in render
    nodelist.append(node.render_annotated(context))
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/defaulttags.py", line 315, in render
    return nodelist.render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 988, in render
    output = self.filter_expression.resolve(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 671, in resolve
    obj = self.var.resolve(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 796, in resolve
    value = self._resolve_lookup(context)
  File "/home/timo/job/integreat/integreat-cms/.venv/lib/python3.9/site-packages/django/template/base.py", line 837, in _resolve_lookup
    current = getattr(current, bit)
  File "/home/timo/job/integreat/integreat-cms/integreat_cms/cms/models/feedback/imprint_page_feedback.py", line 23, in object_name
    return self.region.imprint.get_translation(self.language.slug).title
AttributeError: 'NoneType' object has no attribute 'get_translation'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working prio: low Not urgent, can be resolved in the distant future.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants