|
|
@ -21,6 +21,31 @@ from django.conf import settings |
|
|
logger = logging.getLogger(__name__) |
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_live_session_subject(course): |
|
|
|
|
|
title = "" |
|
|
|
|
|
course_title = course.title |
|
|
|
|
|
if isinstance(course_title, list): |
|
|
|
|
|
for tr in course_title: |
|
|
|
|
|
if isinstance(tr, dict) and tr.get('language_code') == 'en': |
|
|
|
|
|
val = tr.get('title') or tr.get('text') or tr.get('value') or tr.get('name') |
|
|
|
|
|
if val: |
|
|
|
|
|
title = str(val).strip() |
|
|
|
|
|
break |
|
|
|
|
|
if not title: |
|
|
|
|
|
for tr in course_title: |
|
|
|
|
|
if isinstance(tr, dict) and tr.get('language_code') == 'ru': |
|
|
|
|
|
val = tr.get('title') or tr.get('text') or tr.get('value') or tr.get('name') |
|
|
|
|
|
if val: |
|
|
|
|
|
title = str(val).strip() |
|
|
|
|
|
break |
|
|
|
|
|
if not title: |
|
|
|
|
|
from apps.course.models.course import extract_text_from_json |
|
|
|
|
|
title = extract_text_from_json(course_title) |
|
|
|
|
|
if not title: |
|
|
|
|
|
title = "Course" |
|
|
|
|
|
return f"{title} Live Session" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CourseLiveSessionRoomCreateAPIView(GenericAPIView): |
|
|
class CourseLiveSessionRoomCreateAPIView(GenericAPIView): |
|
|
permission_classes = [IsAuthenticated] |
|
|
permission_classes = [IsAuthenticated] |
|
|
authentication_classes = [TokenAuthentication] |
|
|
authentication_classes = [TokenAuthentication] |
|
|
@ -51,7 +76,7 @@ class CourseLiveSessionRoomCreateAPIView(GenericAPIView): |
|
|
raise AppAPIException({'message': 'Permission denied'}, status_code=403) |
|
|
raise AppAPIException({'message': 'Permission denied'}, status_code=403) |
|
|
|
|
|
|
|
|
# 2. Setup ID and Metadata |
|
|
# 2. Setup ID and Metadata |
|
|
subject = f"{course.title} Live Session" |
|
|
|
|
|
|
|
|
subject = get_live_session_subject(course) |
|
|
|
|
|
|
|
|
# 3. Database Logic - Check FIRST before calling PlugNMeet |
|
|
# 3. Database Logic - Check FIRST before calling PlugNMeet |
|
|
session = CourseLiveSession.objects.filter( |
|
|
session = CourseLiveSession.objects.filter( |
|
|
@ -551,7 +576,7 @@ class CourseLiveSessionTokenAPIView(GenericAPIView): |
|
|
Raises: |
|
|
Raises: |
|
|
PlugNMeetError: If room creation fails |
|
|
PlugNMeetError: If room creation fails |
|
|
""" |
|
|
""" |
|
|
subject = session.subject or f"{course.title} Live Session" |
|
|
|
|
|
|
|
|
subject = session.subject or get_live_session_subject(course) |
|
|
room_id = session.room_id |
|
|
room_id = session.room_id |
|
|
metadata = self._build_metadata(subject) |
|
|
metadata = self._build_metadata(subject) |
|
|
|
|
|
|
|
|
|