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

Properly filter classrooms by role. #8054

Merged
merged 2 commits into from
May 6, 2021

Conversation

rtibbles
Copy link
Member

@rtibbles rtibbles commented May 5, 2021

Summary

References

Fixes #8053

Reviewer guidance

  • Create a classroom
  • Add a leaner to the classroom
  • Create a facility coach user
  • Login as the facility coach user
  • Go to Coach
  • Confirm that the newly created class appears, either as an option, or as the default if it is the only classroom

Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@rtibbles rtibbles requested review from jredrejo and radinamatic May 5, 2021 17:33
@rtibbles rtibbles added this to the 0.15.0 milestone May 5, 2021
@radinamatic
Copy link
Member

radinamatic commented May 5, 2021

Looks fixed as described! 👍🏽

One error appeared upon opening the browser, after checking out your branch and starting the server:

ERROR    Internal Server Error: /api/auth/classroom/
Traceback (most recent call last):
  File "/home/didivm/.venvs/kolibri3/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/didivm/.venvs/kolibri3/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/didivm/.venvs/kolibri3/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/didivm/.venvs/kolibri3/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/didivm/.venvs/kolibri3/lib/python3.6/site-packages/rest_framework/viewsets.py", line 116, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/didivm/.venvs/kolibri3/lib/python3.6/site-packages/rest_framework/views.py", line 495, in dispatch
    response = self.handle_exception(exc)
  File "/home/didivm/.venvs/kolibri3/lib/python3.6/site-packages/rest_framework/views.py", line 455, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/home/didivm/.venvs/kolibri3/lib/python3.6/site-packages/rest_framework/views.py", line 492, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/didivm/LE/kolibri/kolibri/core/api.py", line 107, in list
    queryset = self.filter_queryset(self.prefetch_queryset(self.get_queryset()))
  File "/home/didivm/.venvs/kolibri3/lib/python3.6/site-packages/rest_framework/generics.py", line 152, in filter_queryset
    queryset = backend().filter_queryset(self.request, queryset, self)
  File "/home/didivm/.venvs/kolibri3/lib/python3.6/site-packages/django_filters/rest_framework/backends.py", line 54, in filter_queryset
    return filter_class(request.query_params, queryset=queryset, request=request).qs
  File "/home/didivm/.venvs/kolibri3/lib/python3.6/site-packages/django_filters/rest_framework/filterset.py", line 50, in qs
    return super(FilterSet, self).qs
  File "/home/didivm/.venvs/kolibri3/lib/python3.6/site-packages/django_filters/filterset.py", line 220, in qs
    qs = filter_.filter(qs, value)
  File "/home/didivm/.venvs/kolibri3/lib/python3.6/site-packages/django_filters/filters.py", line 713, in __call__
    return self.method(qs, self.f.field_name, value)
  File "/home/didivm/LE/kolibri/kolibri/core/auth/api.py", line 429, in filter_has_role_for
    roles = requesting_user.roles.exclude(kind=role_kinds.ASSIGNABLE_COACH)
AttributeError: 'KolibriAnonymousUser' object has no attribute 'roles'

LEDev2104 (start)  Running  - Oracle VM VirtualBox_008

The error does not replicate when I restart the server & the browser, so unsure if it's a blocker...

@rtibbles
Copy link
Member Author

rtibbles commented May 5, 2021

Thanks, that's a bug, will fix!

@MBKayro
Copy link

MBKayro commented May 5, 2021

i confirm, it works. Bug fixed

Copy link
Member

@radinamatic radinamatic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Facility admin is back in the game! 👍🏽

Copy link
Member

@jredrejo jredrejo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine, and code looks really good to me

@rtibbles rtibbles merged commit 7c149e2 into learningequality:develop May 6, 2021
@rtibbles rtibbles deleted the classroom_role_filter branch May 6, 2021 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Facility coach as a user type not apply
4 participants