louking / members

member activity management
Other
1 stars 2 forks source link

racing team info view: AttributeError: 'NoneType' object has no attribute 'localuser' [null member_id] #520

Closed louking closed 1 year ago

louking commented 2 years ago

Need to figure out what might null out member_id in rt_info table. rt_info.csv file has current records will null member_id.

Exception on /admin/fsrc/rt_inforesults [GET]

Traceback (most recent call last):
  File "/var/www/www.members.loutilities.com/venv/lib/python3.9/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/var/www/www.members.loutilities.com/venv/lib/python3.9/site-packages/flask/app.py", line 1519, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/var/www/www.members.loutilities.com/venv/lib/python3.9/site-packages/flask/app.py", line 1517, in full_dispatch_request
    rv = self.dispatch_request()
  File "/var/www/www.members.loutilities.com/venv/lib/python3.9/site-packages/flask/app.py", line 1503, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/var/www/www.members.loutilities.com/venv/lib/python3.9/site-packages/flask_security/decorators.py", line 389, in decorated_view
    return fn(*args, **kwargs)
  File "/var/www/www.members.loutilities.com/venv/lib/python3.9/site-packages/flask/views.py", line 84, in view
    return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
  File "/var/www/www.members.loutilities.com/venv/lib/python3.9/site-packages/flask/views.py", line 158, in dispatch_request
    return current_app.ensure_sync(meth)(*args, **kwargs)
  File "/var/www/www.members.loutilities.com/venv/lib/python3.9/site-packages/loutilities/tables.py", line 2804, in get
    return super(DbCrudApi, self).get()
  File "/var/www/www.members.loutilities.com/venv/lib/python3.9/site-packages/loutilities/tables.py", line 1263, in get
    return self._renderpage()
  File "/var/www/www.members.loutilities.com/venv/lib/python3.9/site-packages/loutilities/tables.py", line 991, in _renderpage
    thisentry = self.nexttablerow()
  File "/var/www/www.members.loutilities.com/venv/lib/python3.9/site-packages/loutilities/tables.py", line 2893, in nexttablerow
    return self.dte.get_response_data(dbrecord)
  File "/var/www/www.members.loutilities.com/venv/lib/python3.9/site-packages/loutilities/tables.py", line 369, in get_response_data
    data[key] = callback(dbentry)
  File "/var/www/www.members.loutilities.com/members/members/members/views/admin/racingteam_admin.py", line 133, in <lambda>
    rt_inforesult_formmapping['name'] = lambda dbrow: dbrow.info.member.localuser.name
AttributeError: 'NoneType' object has no attribute 'localuser'

rt_info.csv

louking commented 1 year ago

I think the problem is that the RacingTeamInfo (rt_info) table points at the RacingTeamMember (rt_member) table, and that the system lets the user delete entries from the rt_member table. If a row from rt_member is deleted, this would null out the member_id in any rt_info records which had pointed to that row.

My solution will be to do the following.