feat(online_cms): align CMS APIs with DB models—role normalization, threaded forum, attendance, assignments, quizzes, and link-based materials#1
Conversation
…hreaded forum, attendance, assignments (link submit/grade), quizzes (create/submit persistence), and link-based course materials (migration + endpoints)
There was a problem hiding this comment.
Pull request overview
This PR refactors the online_cms Django app from template-based views into DRF-based APIs aligned with the DB schema, adds grading models/migrations, and introduces JWT-based auth endpoints intended to support a modern course-management frontend.
Changes:
- Replaced legacy
online_cmsview/URL surface with DRF API endpoints for courses, assignments (link submissions), documents (link-based), threaded forum, quizzes, attendance, and grading. - Added
GradingScheme/StudentEvaluationmodels + migrations and a demo seed management command. - Introduced JWT auth endpoints (
/api/auth/login,/api/token/refresh,/api/auth/me) and updated REST framework auth settings.
Reviewed changes
Copilot reviewed 24 out of 26 changed files in this pull request and generated 29 comments.
Show a summary per file
| File | Description |
|---|---|
| FusionIIIT/applications/online_cms/views.py | New DRF API implementation for Online CMS features (assignments, docs, forum, quizzes, attendance, grading). |
| FusionIIIT/applications/online_cms/urls.py | New API routing for Online CMS endpoints. |
| FusionIIIT/applications/online_cms/services.py | Centralized enrollment/roster/instructor-link helpers. |
| FusionIIIT/applications/online_cms/models.py | Adds grading models; expands course material URL field to TextField. |
| FusionIIIT/applications/online_cms/migrations/0002_*.py | Migration introducing grading models. |
| FusionIIIT/applications/online_cms/migrations/0003_*.py | Migration altering CourseDocuments.document_url. |
| FusionIIIT/applications/online_cms/management/commands/seed_ocms_demo.py | Demo seeding command for users/courses/enrollment. |
| FusionIIIT/applications/online_cms/serializers.py | New serializers (currently inconsistent with models in places). |
| FusionIIIT/applications/online_cms/selectors.py | New selectors (currently inconsistent with models in places). |
| FusionIIIT/applications/globals/api/urls.py | Adds endpoints but currently duplicates patterns. |
| FusionIIIT/Fusion/api_auth.py | Adds JWT auth “me” endpoint with role normalization. |
| FusionIIIT/Fusion/urls.py | Wires JWT auth endpoints and mounts Online CMS API URLs. |
| FusionIIIT/Fusion/settings/common.py | Adds rest_framework_simplejwt and JWT config. |
| FusionIIIT/Fusion/settings/development.py | Updates DB + REST_FRAMEWORK auth config (now hard-coded creds). |
| FusionIIIT/Fusion/settings/production.py | Updates REST_FRAMEWORK auth config to include JWT + sessions/basic. |
| FusionIIIT/update_views.py | New local helper script that overwrites tracked code via absolute paths. |
| FusionIIIT/reset_pass.py | New script that resets user passwords to a hard-coded value. |
| FusionIIIT/fix_*.py | Multiple new local helper scripts that mutate files via absolute paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 'NAME': 'fusionlab', | ||
| 'HOST': os.environ.get("DB_HOST", default='localhost'), | ||
| 'USER': 'fusion_admin', | ||
| 'PASSWORD': 'hello123', | ||
| 'USER': 'postgres', | ||
| 'PASSWORD': '2304', | ||
| 'HOST': 'localhost', | ||
| 'PORT': '5432', |
There was a problem hiding this comment.
Development DB settings now hard-code local credentials (user/password/host/port). Please revert to environment-variable based configuration (as before) to avoid leaking credentials and to keep dev setup portable across machines/CI.
| if timezone.is_naive(start_dt): | ||
| start_dt = timezone.make_aware(start_dt) | ||
| if timezone.is_naive(end_dt): | ||
| end_dt = timezone.make_aware(end_dt) |
There was a problem hiding this comment.
timezone.make_aware is applied to start_dt/end_dt, but this project has USE_TZ = False. Creating aware datetimes here can break Quiz saves/comparisons. Please keep parsed datetimes naive when USE_TZ is False, or enable time zone support consistently across settings.
| student = models.Student.objects.get(id__user__username=s_id) | ||
| scheme = models.GradingScheme.objects.get(pk=sc_id) | ||
| ev, _ = models.StudentEvaluation.objects.get_or_create(scheme=scheme, student=student) |
There was a problem hiding this comment.
models.Student is referenced here, but there is no Student model in online_cms.models. This will raise at runtime when evaluating grades; use the imported Student model instead.
| curr = services.get_course_obj(course_code) | ||
| student = models.Student.objects.get(id=extra_info) | ||
| schemes = models.GradingScheme.objects.filter(course_id=curr.course_id) |
There was a problem hiding this comment.
models.Student is referenced here, but Student is not defined in online_cms.models. This will raise AttributeError when a student requests grades; use the Student model imported from applications.academic_information.models.
| @@ -0,0 +1,73 @@ | |||
| from .models import CourseDocuments, Assignment, StudentAssignment, Forum, ForumReply, Quiz, QuestionBank, Topics, Question, StudentGrades | |||
There was a problem hiding this comment.
StudentGrades is imported from .models, but no such model exists in online_cms/models.py. Importing this module will raise ImportError; please remove StudentGrades usage or replace it with the correct model (e.g., StudentEvaluation/GradingScheme).
| if deadline_dt is None and isinstance(deadline, str): | ||
| d = parse_date(deadline) | ||
| if d is not None: | ||
| deadline_dt = timezone.make_aware(timezone.datetime(d.year, d.month, d.day, 23, 59, 0)) |
There was a problem hiding this comment.
timezone.make_aware(...) is used when parsing deadline, but this project has USE_TZ = False in common settings. Saving timezone-aware datetimes with time zone support disabled can raise ValueError; please keep deadline_dt naive when USE_TZ is False (or enable USE_TZ=True consistently).
| deadline_dt = timezone.make_aware(timezone.datetime(d.year, d.month, d.day, 23, 59, 0)) | |
| deadline_dt = timezone.datetime(d.year, d.month, d.day, 23, 59, 0) |
| url(r'^notification/$', views.NotificationRead, name='dummy_notifs'), | ||
| url(r'^auth/me$', views.profile, name='me-api-2'), | ||
|
|
There was a problem hiding this comment.
notification/ and auth/me are registered multiple times in this urlpatterns list, creating duplicate URL patterns. This can lead to confusing URL resolution; please keep a single canonical route for each endpoint.
| url(r'^notification/$', views.NotificationRead, name='dummy_notifs'), | |
| url(r'^auth/me$', views.profile, name='me-api-2'), |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
🚀 Overview
This PR aligns the Online CMS backend APIs with the underlying database models and introduces several core academic features to support a complete course management workflow.
✨ Key Changes
🔐 Role Normalization
💬 Threaded Forum System
📊 Attendance Module
📝 Assignments
🧠 Quizzes
📚 Course Materials (Link-Based)
🛠️ Technical Improvements
🔄 Migration Notes