Club-Alpin-Annecy / collectives

Site de collectives du caf Annecy
https://doc.collectives.cafannecy.fr
15 stars 19 forks source link

Wrong parameter for get function #688

Closed jnguiot closed 4 months ago

jnguiot commented 4 months ago

Seen whil accessing https://collectives.cafannecy.fr/collectives/4912

2024-03-10 18:12:43,780 ERROR root waitress-12 : 500 Internal Server Error: The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. datefmt=
Traceback (most recent call last):
  File "/home/production/collectives-flask2/.env/lib/python3.9/site-packages/flask/app.py", line 1455, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/production/collectives-flask2/.env/lib/python3.9/site-packages/flask/app.py", line 869, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/production/collectives-flask2/.env/lib/python3.9/site-packages/flask/app.py", line 867, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/production/collectives-flask2/.env/lib/python3.9/site-packages/flask/app.py", line 852, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/home/production/collectives-flask2/collectives/utils/crawlers.py", line 77, in inner_function
    return func(*args, **kwargs)
  File "/home/production/collectives-flask2/.env/lib/python3.9/site-packages/flask_login/utils.py", line 290, in decorated_view
    return current_app.ensure_sync(func)(*args, **kwargs)
  File "/home/production/collectives-flask2/collectives/utils/access.py", line 58, in decorated_function
    return function(*args, **kwargs)
  File "/home/production/collectives-flask2/collectives/routes/event.py", line 253, in view_event
    return render_template(
  File "/home/production/collectives-flask2/.env/lib/python3.9/site-packages/flask/templating.py", line 152, in render_template
    return _render(app, template, context)
  File "/home/production/collectives-flask2/.env/lib/python3.9/site-packages/flask/templating.py", line 133, in _render
    rv = template.render(context)
  File "/home/production/collectives-flask2/.env/lib/python3.9/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/home/production/collectives-flask2/.env/lib/python3.9/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/production/collectives-flask2/collectives/templates/event/event.html", line 5, in top-level template code
    {% import 'partials/event/self_register.html' as self_register with context %}
  File "/home/production/collectives-flask2/collectives/templates/base.html", line 53, in top-level template code
    {% block content %}{% endblock %}
  File "/home/production/collectives-flask2/collectives/templates/event/event.html", line 263, in block 'content'
    {% if event.user_group and event.user_group.has_conditions() %}
  File "/home/production/collectives-flask2/.env/lib/python3.9/site-packages/jinja2/environment.py", line 485, in getattr
    return getattr(obj, attribute)
  File "/home/production/collectives-flask2/collectives/models/event/model.py", line 281, in user_group
    self._migrate_parent_event_id()
  File "/home/production/collectives-flask2/collectives/models/event/misc.py", line 133, in _migrate_parent_event_id
    condition.event = db.session.get(self, parent_event_id)
  File "/home/production/collectives-flask2/.env/lib/python3.9/site-packages/sqlalchemy/orm/scoping.py", line 1064, in get
    return self._proxied.get(
  File "/home/production/collectives-flask2/.env/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 3653, in get
    return self._get_impl(
  File "/home/production/collectives-flask2/.env/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 3743, in _get_impl
    raise sa_exc.ArgumentError(
sqlalchemy.exc.ArgumentError: Expected mapped class or mapper, got: <Event 4912>

THis is due to : https://github.com/Club-Alpin-Annecy/collectives/blob/841d7fadd5014fe7fdc467af69c8174c6dd0be82/collectives/models/event/misc.py#L133 get should not have self , but Event