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

fix: add cache wrapper for can_view_courses filter #299

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import jwt
from authlib.common.urls import add_params_to_qs, add_params_to_uri
from flask import current_app, session, request
from flask import current_app, session
from superset.security import SupersetSecurityManager
from superset.utils.memoized import memoized

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,15 @@
# Add this custom template processor which returns the list of courses the current user can access
from openedx_jinja_filters import *

def can_view_courses_wrapper(*args, **kwargs):
from superset.utils.cache import memoized_func
from superset.extensions import cache_manager

return memoized_func(key="{username}", cache=cache_manager.cache)(can_view_courses)(*args, **kwargs)


JINJA_CONTEXT_ADDONS = {
'can_view_courses': can_view_courses,
'can_view_courses': can_view_courses_wrapper,
{% for filter in SUPERSET_EXTRA_JINJA_FILTERS %}'{{ filter }}': {{filter}},{% endfor %}
}

Expand Down