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

feat: teacher views dashboard #173

Merged
merged 19 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 18 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
2 changes: 2 additions & 0 deletions backend/portal/urls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .home import urlpatterns as home_urlpatterns
from .login import urlpatterns as login_urlpatterns
from .organisation import urlpatterns as organisation_urlpatterns
from .teacher.dashboard import urlpatterns as teach_dashboard_urlpatterns
from .registration import urlpatterns as registration_urlpatterns
from .teacher import urlpatterns as teacher_urlpatterns

Expand All @@ -21,5 +22,6 @@
*registration_urlpatterns,
*admin_urlpatterns,
*organisation_urlpatterns,
*teach_dashboard_urlpatterns,
*teacher_urlpatterns,
]
80 changes: 80 additions & 0 deletions backend/portal/urls/teacher/dashboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
from django.urls import path, re_path

from ...views.teacher.dashboard import (
dashboard_manage,
organisation_kick,
organisation_toggle_admin,
teacher_disable_2FA,
teacher_accept_student_request,
teacher_reject_student_request,
resend_invite_teacher,
invite_toggle_admin,
delete_teacher_invite,
invite_teacher,
invited_teacher,
update_school,
)


urlpatterns = [
path(
"teach/dashboard/",
dashboard_manage,
name="dashboard"
),
path(
"teach/invite/",
invite_teacher,
name="invite_teacher"
),
path(
"teach/update_school/",
update_school,
name="update_school"
),
re_path(
r"^invited_teacher/(?P<token>[0-9a-f]+)/$",
invited_teacher,
name="invited_teacher"
),
re_path(
r"^teach/dashboard/kick/(?P<pk>[0-9]+)/$",
organisation_kick,
name="organisation_kick"
),
re_path(
r"^teach/dashboard/toggle_admin/(?P<pk>[0-9]+)/$",
organisation_toggle_admin,
name="organisation_toggle_admin"
),
re_path(
r"^teach/dashboard/invite_toggle_admin/(?P<invite_id>[0-9]+)/$",
invite_toggle_admin,
name="invite_toggle_admin"
),
re_path(
r"^teach/dashboard/resend_invite/(?P<token>[0-9a-f]+)/$",
resend_invite_teacher,
name="resend_invite_teacher"
),
re_path(
r"^teach/dashboard/delete_invite/(?P<token>[0-9a-f]+)/$",
delete_teacher_invite,
name="delete_teacher_invite",
),
re_path(
r"^teach/dashboard/disable_2FA/(?P<pk>[0-9]+)/$",
teacher_disable_2FA,
name="teacher_disable_2FA"
),
re_path(
r"^teach/dashboard/student/accept/(?P<pk>[0-9]+)/$",
teacher_accept_student_request,
name="teacher_accept_student_request",
),
re_path(
r"^teach/dashboard/student/reject/(?P<pk>[0-9]+)/$",
teacher_reject_student_request,
name="teacher_reject_student_request",
),
]
6 changes: 3 additions & 3 deletions backend/portal/views/organisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def organisation_leave(request):

# check teacher is not admin
if teacher.is_admin:
return HttpResponse(status=status.HTTP_404_NOT_FOUND)
return HttpResponse(status=status.HTTP_400_BAD_REQUEST)

if request.method == "POST":
classes = Class.objects.filter(teacher=teacher)
Expand All @@ -52,11 +52,11 @@ def organisation_leave(request):
teachers = Teacher.objects.filter(school=teacher.school).exclude(id=teacher.id).values("id", "new_user_id__first_name", "new_user_id__last_name")

if classes.exists():
return JsonResponse(status=status.HTTP_200_OK, data={'hasClasses': True, 'classes': list(classes), 'teachers': list(teachers)})
return JsonResponse(status=status.HTTP_200_OK, data={'source': 'organisationLeave', 'classes': list(classes), 'teachers': list(teachers)})
else:
teacher.school = None
teacher.save()

return JsonResponse(status=status.HTTP_204_NO_CONTENT, data={'hasClasses': False})
return HttpResponse(status=status.HTTP_204_NO_CONTENT)

return HttpResponse(status=status.HTTP_405_METHOD_NOT_ALLOWED)
Loading