-
Notifications
You must be signed in to change notification settings - Fork 0
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
PADV-1528: Create ViewSet CourseContentItemViewSet #41
Conversation
max_page_size = 100 | ||
|
||
|
||
class CourseContentItemViewSet( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kuipumu Aren't authentication_classes and permission_classes necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anfbermudezme I forgot to add the JwtAuthentication class, but there are no permission classes necessary since this API endpoint is used by unauthenticated users.
from openedx_lti_tool_plugin.utils import get_identity_claims | ||
|
||
|
||
class ContentItemPagination(PageNumberPagination): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kuipumu How about having a separate module for pagination? (pagination.py)
CourseContext QuerySet. | ||
|
||
""" | ||
iss, aud, _sub, _pii = get_identity_claims(self.launch_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kuipumu Please explain what is iss, aud, _sub, _pii.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anfbermudezme The get_identity_claims function has a docstring with references to the OpenID Connect Core 1.0 ID token claims and standard claims, I will add a comment in this line to explain why we are obtaining the iss and aud claim
""" | ||
iss, aud, _sub, _pii = get_identity_claims(self.launch_data) | ||
|
||
return CourseContext.objects\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return CourseContext.objects\ | |
return CourseContext.objects.all_for_lti_tool(iss, aud).filter_by_site_orgs() |
from openedx_lti_tool_plugin.views import requires_plugin_enabled | ||
|
||
|
||
@method_decorator(requires_plugin_enabled, name='dispatch') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@method_decorator(requires_plugin_enabled, name='dispatch') | |
@method_decorator(requires_plugin_enabled, name='dispatch') |
@kuipumu The name of this decorator is too general. Which plugin is required to be enabled?
|
||
|
||
@method_decorator(requires_openedx_lti_tool_plugin_enabled, name='dispatch') | ||
class DeepLinkingViewSet( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this be more of a base view?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexjmpb It's a base view, I followed a similar structure found in rest_framework/viewsets.py
for other ViewSets such has ModelViewSet, are you suggesting we use a different name for this View or are you suggesting a different structure for the API Views?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it was more of a naming question, but it's not that relevant.
@@ -274,10 +275,10 @@ def __str__(self) -> str: | |||
return f'<CourseAccessConfiguration, ID: {self.id}>' | |||
|
|||
|
|||
class CourseContextManager(models.Manager): | |||
"""CourseContext Model Manager.""" | |||
class CourseContextQuerySet(models.QuerySet): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you decided to change this to a queryset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexjmpb I changed it to a queryset so I was able to chain the all_for_lti_tool and filter_by_site_orgs querysets, with a Manager I would have to create a Queryset and duplicate the methods of such Queryset in the manager, the as_manager method does that for you automatically: https://docs.djangoproject.com/en/5.0/topics/db/managers/#creating-a-manager-with-queryset-methods
refactor: LTI Tool Views feat: Upgrade requirements
Ticket
https://agile-jira.pearson.com/browse/PADV-1528
Description
This PR adds a CourseContentItemViewSet ViewSet to list all the Course content items available for a launch ID. This ViewSet will be used to render a paginated form table in the DeepLinkingFormView template.
Additionally this PR also includes an upgrade to the project requirements.
Type of Change
Testing:
make dev.up.lms
.openedx_lti_tool_plugin
on the LMS.ngrok http 18000