Describe the bug
If a staff (Django-related role) is authenticated and tries to retrieved this endpoint : /appointment/app-admin/user-event/ he'll get the following error if debug = true
Traceback (most recent call last):
File "/Users/adamspierredavid/developer/PycharmProjects/crueltouch/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/adamspierredavid/developer/PycharmProjects/crueltouch/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/adamspierredavid/developer/PycharmProjects/crueltouch/venv/lib/python3.11/site-packages/appointment/decorators.py", line 26, in wrapper
return func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/adamspierredavid/developer/PycharmProjects/crueltouch/venv/lib/python3.11/site-packages/appointment/decorators.py", line 39, in wrapper
return func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/adamspierredavid/developer/PycharmProjects/crueltouch/venv/lib/python3.11/site-packages/appointment/views_admin.py", line 39, in get_user_appointments
appointments = fetch_user_appointments(request.user)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/adamspierredavid/developer/PycharmProjects/crueltouch/venv/lib/python3.11/site-packages/appointment/services.py", line 44, in fetch_user_appointments
staff_member_instance = user.staffmember
^^^^^^^^^^^^^^^^
File "/Users/adamspierredavid/developer/PycharmProjects/crueltouch/venv/lib/python3.11/site-packages/django/utils/functional.py", line 268, in inner
return func(_wrapped, *args)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/adamspierredavid/developer/PycharmProjects/crueltouch/venv/lib/python3.11/site-packages/django/db/models/fields/related_descriptors.py", line 492, in __get__
raise self.RelatedObjectDoesNotExist(
client.models.UserClient.staffmember.RelatedObjectDoesNotExist: UserClient has no staffmember.
[01/Dec/2023 23:29:58] "GET /appointment/app-admin/user-event/ HTTP/1.1" 500 110721
2023-12-01 23:29:58,433 - django.request - ERROR - Internal Server Error: /appointment/app-admin/user-event/
Traceback (most recent call last):
File "/Users/adamspierredavid/developer/PycharmProjects/crueltouch/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/adamspierredavid/developer/PycharmProjects/crueltouch/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/adamspierredavid/developer/PycharmProjects/crueltouch/venv/lib/python3.11/site-packages/appointment/decorators.py", line 26, in wrapper
return func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/adamspierredavid/developer/PycharmProjects/crueltouch/venv/lib/python3.11/site-packages/appointment/decorators.py", line 39, in wrapper
return func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/adamspierredavid/developer/PycharmProjects/crueltouch/venv/lib/python3.11/site-packages/appointment/views_admin.py", line 39, in get_user_appointments
appointments = fetch_user_appointments(request.user)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/adamspierredavid/developer/PycharmProjects/crueltouch/venv/lib/python3.11/site-packages/appointment/services.py", line 44, in fetch_user_appointments
staff_member_instance = user.staffmember
^^^^^^^^^^^^^^^^
File "/Users/adamspierredavid/developer/PycharmProjects/crueltouch/venv/lib/python3.11/site-packages/django/utils/functional.py", line 268, in inner
return func(_wrapped, *args)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/adamspierredavid/developer/PycharmProjects/crueltouch/venv/lib/python3.11/site-packages/django/db/models/fields/related_descriptors.py", line 492, in __get__
raise self.RelatedObjectDoesNotExist(
client.models.UserClient.staffmember.RelatedObjectDoesNotExist: UserClient has no staffmember.
To Reproduce
Steps to reproduce the behavior:
Create a user/account (user1)
Login as admin/superuser (admin) and add user1 to staff.
Login as user1 and go to /appointment/app-admin/user-event/
See error
Expected behavior
Not an error but a redirection or anything more concise than just an error or a 5xx code return.
Can you fix the bug?
[x] Yes, I can fix the bug and will open a pull request.
[ ] No, I can't fix the bug, but I can assist in testing and providing feedback.
[ ] No, I can't fix the bug, but I can provide more information to help you fix it.
[ ] No, I can't fix the bug, but I can open an issue to report it.
Describe the bug If a staff (Django-related role) is authenticated and tries to retrieved this endpoint :
/appointment/app-admin/user-event/
he'll get the following error if debug = trueTo Reproduce Steps to reproduce the behavior:
Expected behavior Not an error but a redirection or anything more concise than just an error or a 5xx code return.
Can you fix the bug?