diff --git a/Instructor/static/js/user-designate.js b/Instructor/static/js/user-designate.js
deleted file mode 100644
index f9aacca..0000000
--- a/Instructor/static/js/user-designate.js
+++ /dev/null
@@ -1,44 +0,0 @@
-'use strict';
-
-/**
- * This JS file is used in the user-list page
- */
-
-function formSaveCallback() {
- /**
- * This function is run when the form is saved, it fills out the session-input field with the proper JSON
- */
-
- let newObj = {"AM": [], "PM": []};
- $(".AM-session").children("tr").each((index, object) => {
- newObj["AM"].push($(object).children("th").attr('id'));
- });
- $(".PM-session").children("tr").each((index, object) => {
- newObj["PM"].push($(object).children("th").attr('id'));
- });
- $(".session-input").val(JSON.stringify(newObj));
-}
-
-$(document).ready(function () {
- /**
- * This function is run when the document has successfully loaded
- * It initializes the Sortable library and sets up the form's save callback
- */
-
- const options = {
- group: "sessions",
- animation: 150,
- multiDrag: true,
- selectedClass: "bg-light",
- fallbackTolerance: 3,
- ghostClass: "bg-light",
- };
-
- $(".AM-session").sortable(options);
-
- $(".PM-session").sortable(options);
-
- $(".session-form").submit(formSaveCallback);
- formSaveCallback();
-
-});
diff --git a/Instructor/templates/user_list.html b/Instructor/templates/user_list.html
index 5e64244..e442d7d 100644
--- a/Instructor/templates/user_list.html
+++ b/Instructor/templates/user_list.html
@@ -1,16 +1,11 @@
{% extends "admin_base.html" %}
{% comment %}
- This page shows the Instructor a list of users that they can drag-and-drop between the AM and PM table.
- They can also set users as Reviewers or Not Reviewers.
+ This page shows the Instructor a list of users that they can set as Reviewers or Non-Reviewers.
{% endcomment %}
{% block resources %}
{% load static %}
-
-
-
{% endblock %}
@@ -19,7 +14,6 @@
{% block containerClass %}container{% endblock %}
{% block mainContent %}
- {# TODO: Add the ability to sync this user list with ActiveDirectory #}
@@ -85,7 +79,6 @@
- Drag users in order to change their session.
Click the toggle switch next to a user to make them a reviewer.
diff --git a/Instructor/views.py b/Instructor/views.py
index 88e2040..c9d9168 100644
--- a/Instructor/views.py
+++ b/Instructor/views.py
@@ -48,7 +48,7 @@ class AdminHomeView(LoginRequiredMixin, IsSuperUserMixin, TemplateView):
class UserListView(LoginRequiredMixin, IsSuperUserMixin, TemplateView):
"""
- This view shows a list of users that the instructor can change from AM to PM and set as reviewers
+ This view shows a list of users that the instructor can set as reviewers
:cvar template_name: The template to render and return to the user
:cvar http_method_names: The HTTP methods to accept from the client
@@ -58,24 +58,6 @@ class UserListView(LoginRequiredMixin, IsSuperUserMixin, TemplateView):
template_name = "user_list.html"
http_method_names = ['get', 'post']
- _schema = {
- 'type': "object",
- 'properties': {
- 'AM': {
- 'type': "array",
- 'items': {
- 'type': "string"
- }
- },
- 'PM': {
- 'type': "array",
- 'items': {
- 'type': "string"
- }
- }
- }
- }
-
def get_queryset(self):
"""
This defines what objects from the database to list, we don't want Instructors to be listed, so we exclude them
@@ -86,33 +68,6 @@ class UserListView(LoginRequiredMixin, IsSuperUserMixin, TemplateView):
return User.objects.filter(is_superuser=False)
- def update_sessions(self, sessions_json, objs):
- """
- This function sets the Users in objs to their sessions specified in session_json
-
- :param sessions_json: A JSON representation of which users are in which session
- :param objs: A list of User objects
- :type sessions_json: str
- :type objs: list
- """
-
- try:
- sessions = JSONDecoder().decode(sessions_json)
- validate(sessions, self._schema)
- for user_id in sessions['AM']:
- user = User.objects.get(id=main_models.val_uuid(user_id))
- objs[objs.index(user)].session = User.Session.AM
- for user_id in sessions['PM']:
- user = User.objects.get(id=main_models.val_uuid(user_id))
- objs[objs.index(user)].session = User.Session.PM
- self.get_queryset().bulk_update(objs, ['session'], batch_size=10)
- except User.DoesNotExist:
- raise Http404('Invalid Data')
- except JSONDecodeError:
- raise Http404('Invalid Data')
- except JsonValidationError:
- raise Http404('Invalid Data')
-
def post(self, *args, **kwargs):
"""
This function defines back-end behaviour when the user uses the POST method.
@@ -123,7 +78,6 @@ class UserListView(LoginRequiredMixin, IsSuperUserMixin, TemplateView):
for index, user in enumerate(objs):
objs[index].is_reviewer = str(user.id) in self.request.POST.getlist('reviewers')
self.get_queryset().bulk_update(objs, ['is_reviewer'], batch_size=10)
- self.update_sessions(self.request.POST.get("sessions"), objs)
messages.add_message(self.request, messages.SUCCESS, "Users Updated")
return redirect("instructor-home")
diff --git a/tests/test_instructor.py b/tests/test_instructor.py
index 2c404c6..3ccc8ec 100644
--- a/tests/test_instructor.py
+++ b/tests/test_instructor.py
@@ -120,30 +120,11 @@ class UserDesignationTest(TestCase):
ids = [str(self.users[user].id) for user in user_list]
return ids
- def make_sessions_json(self, am_list, pm_list):
- am_ids = [str(self.users[user].id) for user in am_list]
- pm_ids = [str(self.users[user].id) for user in pm_list]
- return JSONEncoder().encode({
- 'AM': am_ids,
- 'PM': pm_ids
- })
-
def test_designate_reviewer(self) -> None:
self.clients['super'].post(reverse('user-list'), data={
'reviewers': self.make_reviewers_list(['reviewer-am', 'student-am']),
- 'sessions': self.make_sessions_json(['reviewer-am', 'student-am'], ['reviewer-pm', 'student-pm'])
})
self.assertTrue(User.objects.get(username="reviewer-am").is_reviewer)
self.assertFalse(User.objects.get(username="reviewer-pm").is_reviewer)
self.assertTrue(User.objects.get(username="student-am").is_reviewer)
self.assertFalse(User.objects.get(username="student-pm").is_reviewer)
-
- def test_switch_sessions(self) -> None:
- self.clients['super'].post(reverse('user-list'), data={
- 'reviewers': self.make_reviewers_list(['reviewer-am', 'reviewer-pm']),
- 'sessions': self.make_sessions_json(['reviewer-pm', 'student-am'], ['reviewer-am', 'student-pm'])
- })
- self.assertEqual(User.objects.get(username='reviewer-am').session, User.Session.PM)
- self.assertEqual(User.objects.get(username='reviewer-pm').session, User.Session.AM)
- self.assertEqual(User.objects.get(username='student-am').session, User.Session.AM)
- self.assertEqual(User.objects.get(username='student-pm').session, User.Session.PM)