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

User unable to add items that are also global #439

Closed
1 task done
jon-nfc opened this issue Dec 21, 2024 · 0 comments · Fixed by #441
Closed
1 task done

User unable to add items that are also global #439

jon-nfc opened this issue Dec 21, 2024 · 0 comments · Fixed by #441
Assignees
Labels
bug::failure to confirm Bug caused by failure to confirm item worked type::bug Issue Type v1.6-beta Version Affected.
Milestone

Comments

@jon-nfc
Copy link
Member

jon-nfc commented Dec 21, 2024

When adding an item that is also set via app settings as a global item, the user is unable to add the item.

Details

The Centurion admin can set a number of models as global. As such when a user creates the item, it is moved to the global organization that has been set.

It's currently assumed that If the user does not have access to view the application settings, the application crashes as the user can not obtain the application settings required to move the item to the global organization. this needs to b confirmed This also happens to a super user as well.

issue is due to that during adjusting the settings field Owner organization is available as a filed to set when it should not be. This field is for future expansion.

stack trace

Internal Server Error: /api/v2/itam/software
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
    return view_func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/rest_framework/viewsets.py", line 124, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/drf_spectacular/drainage.py", line 207, in wrapped_method
    return method(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/rest_framework/mixins.py", line 19, in create
    self.perform_create(serializer)
  File "/usr/local/lib/python3.11/site-packages/rest_framework/mixins.py", line 24, in perform_create
    serializer.save()
  File "/usr/local/lib/python3.11/site-packages/rest_framework/serializers.py", line 208, in save
    self.instance = self.create(validated_data)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/rest_framework/serializers.py", line 989, in create
    instance = ModelClass._default_manager.create(**validated_data)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 679, in create
    obj.save(force_insert=True, using=self.db)
  File "/app/access/models.py", line 324, in save
    self.clean()
  File "/app/itam/models/software.py", line 251, in clean
    app_settings = AppSettings.objects.get(owner_organization=None)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 649, in get
    raise self.model.DoesNotExist(
settings.models.app_settings.AppSettings.DoesNotExist: AppSettings matching query does not exist.

Links

Tasks

  • Refactor so that a standard user can add an item if they have the permissions to do so.
@jon-nfc jon-nfc added type::bug Issue Type bug::failure to confirm Bug caused by failure to confirm item worked v1.6-beta Version Affected. labels Dec 21, 2024
@jon-nfc jon-nfc moved this to Backlog in Centurion ERP Dec 21, 2024
@jon-nfc jon-nfc added this to the Next Release milestone Dec 21, 2024
@jon-nfc jon-nfc moved this from Backlog to Planning in Centurion ERP Dec 21, 2024
@jon-nfc jon-nfc self-assigned this Dec 22, 2024
@jon-nfc jon-nfc moved this from Planning to In progress in Centurion ERP Dec 22, 2024
@jon-nfc jon-nfc linked a pull request Dec 22, 2024 that will close this issue
9 tasks
@jon-nfc jon-nfc moved this from In progress to Done in Centurion ERP Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug::failure to confirm Bug caused by failure to confirm item worked type::bug Issue Type v1.6-beta Version Affected.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant