mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-01-20 15:22:58 -05:00
all
This commit is contained in:
@@ -4,6 +4,7 @@ from cms.version import VERSION
|
||||
|
||||
from .frontend_translations import get_translation, get_translation_strings
|
||||
from .methods import is_mediacms_editor, is_mediacms_manager
|
||||
from .models import Category
|
||||
|
||||
|
||||
def stuff(request):
|
||||
@@ -64,4 +65,26 @@ def stuff(request):
|
||||
if request.user.is_superuser:
|
||||
ret["DJANGO_ADMIN_URL"] = settings.DJANGO_ADMIN_URL
|
||||
|
||||
# LTI Integration: Add category UID for LTI-authenticated users
|
||||
if getattr(settings, 'USE_LTI', False):
|
||||
# Check if user has an active LTI session
|
||||
lti_session = request.session.get('lti_session')
|
||||
if lti_session and request.user.is_authenticated:
|
||||
ret['lti_session'] = lti_session
|
||||
|
||||
# Get the category for this LTI context via lti_platform and lti_context_id
|
||||
platform_id = lti_session.get('platform_id')
|
||||
context_id = lti_session.get('context_id')
|
||||
|
||||
if platform_id and context_id:
|
||||
try:
|
||||
# Look up category by LTI platform and context
|
||||
category = Category.objects.get(lti_platform_id=platform_id, lti_context_id=context_id)
|
||||
|
||||
# Check if user has permission to upload to this category
|
||||
if request.user.has_upload_access_to_category(category):
|
||||
ret['lti_category_uid'] = category.uid
|
||||
except Category.DoesNotExist:
|
||||
pass
|
||||
|
||||
return ret
|
||||
|
||||
Reference in New Issue
Block a user