diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index bf0527e..2cb7086 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index dc24be3..17137ff 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/templates/core/live_classroom.html b/core/templates/core/live_classroom.html new file mode 100644 index 0000000..35005d8 --- /dev/null +++ b/core/templates/core/live_classroom.html @@ -0,0 +1,57 @@ +{% extends 'base.html' %} +{% load i18n static %} + +{% block title %}{% trans "Live Classroom" %} - {{ subject.name_en }}{% endblock %} + +{% block content %} +
+ +
+ +
+ + + +{% endblock %} diff --git a/core/templates/core/student_dashboard.html b/core/templates/core/student_dashboard.html index a93be93..876f2b3 100644 --- a/core/templates/core/student_dashboard.html +++ b/core/templates/core/student_dashboard.html @@ -126,7 +126,14 @@ {{ subject.teacher.user.get_full_name|default:"No Teacher" }} - {% trans "Go to Class" %} +
+ + + + + + {% trans "Go to Class" %} +
@@ -179,4 +186,4 @@ -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/core/templates/core/teacher_dashboard.html b/core/templates/core/teacher_dashboard.html index b2ca55f..e127cae 100644 --- a/core/templates/core/teacher_dashboard.html +++ b/core/templates/core/teacher_dashboard.html @@ -107,8 +107,14 @@ {{ subject.subscribers.count }} {% trans "Students" %} -
- {% trans "Manage Class" %} +
+ + + + + {% trans "Start Live Class" %} + + {% trans "Manage Class" %}
diff --git a/core/urls.py b/core/urls.py index ed37225..99dda18 100644 --- a/core/urls.py +++ b/core/urls.py @@ -17,4 +17,5 @@ urlpatterns = [ path('subscribe//', views.subscribe_subject, name='subscribe_subject'), path('payment/success/', views.payment_success, name='payment_success'), path('payment/cancel/', views.payment_cancel, name='payment_cancel'), + path('classroom//', views.live_classroom, name='live_classroom'), ] \ No newline at end of file diff --git a/core/views.py b/core/views.py index b1f44dc..b256573 100644 --- a/core/views.py +++ b/core/views.py @@ -1,3 +1,4 @@ +from django.core.exceptions import PermissionDenied from django.shortcuts import render, redirect, get_object_or_404 from django.utils import translation from django.conf import settings @@ -243,4 +244,31 @@ def payment_success(request): @login_required def payment_cancel(request): - return redirect('profile') \ No newline at end of file + return redirect('profile') + +@login_required +def live_classroom(request, subject_id): + subject = get_object_or_404(Subject, pk=subject_id) + + is_teacher = False + is_student = False + + if hasattr(request.user, 'teacher_profile') and subject.teacher and subject.teacher.user == request.user: + is_teacher = True + + if hasattr(request.user, 'student_profile') and request.user.student_profile.subscribed_subjects.filter(pk=subject_id).exists(): + is_student = True + + if not (is_teacher or is_student): + raise PermissionDenied("You are not authorized to join this class.") + + # Generate Room Name + # We use a consistent room name based on Subject ID + room_name = f"EduPlatform_Live_Subject_{subject.id}" + + return render(request, 'core/live_classroom.html', { + 'subject': subject, + 'room_name': room_name, + 'user_display_name': request.user.get_full_name() or request.user.username, + 'is_teacher': is_teacher + })