Skip to content

Commit

Permalink
fix: delete level on moderate page
Browse files Browse the repository at this point in the history
  • Loading branch information
razvan-pro committed Jan 19, 2022
1 parent d964ad4 commit c5a35f6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
28 changes: 11 additions & 17 deletions game/static/game/js/level_moderation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global showPopupConfirmation */

var levelID;
var classID;
var students;
Expand All @@ -8,29 +10,21 @@ function deleteLevel() {
saving.deleteLevel(
levelID,
function () {
document.forms["levelModerationForm"].submit();
document.forms["moderateForm"].submit();
},
console.error
);
}

function showPopupConfirmation(title, text, confirm_handler) {
var popup = $(".popup-wrapper");
$(".popup-box__title").text(title);
$(".popup-box__msg").append(text);
$("#confirm_button").click(confirm_handler);

popup.addClass("popup--fade");
}

function confirmDelete() {
var title = "Delete level";
var text =
"<p>" +
gettext("This student's level will be permanently deleted. Are you sure?") +
"</p>";

showPopupConfirmation(title, text, deleteLevel);
let title = "Delete level";
let text = `
<div class='popup-text'>
<p>This student's level will be permanently deleted. Are you sure?</p>
</div>`;
let confirmHandler = "deleteLevel()";

showPopupConfirmation(title, text, confirmHandler);
}

$(document).ready(function () {
Expand Down
12 changes: 9 additions & 3 deletions game/tests/test_level_moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,21 @@ def test_moderation_teachers_class(self):

_, _, student = create_school_student_directly(access_code)

create_save_level(student, level_name)
level_id = create_save_level(student, level_name)

self.teacher_login(email, password)

url = reverse("level_moderation")
response = self.client.get(url)
level_moderation_url = reverse("level_moderation")
response = self.client.get(level_moderation_url)
assert class_name in response.content.decode()
assert level_name in response.content.decode()

# Test delete level
delete_level_url = reverse("delete_level", kwargs={"levelID": level_id})
self.client.post(delete_level_url)
response = self.client.get(level_moderation_url)
assert level_name not in response.content.decode()

def test_moderation_another_class(self):
level_name = "test_level2"
email, password = signup_teacher_directly()
Expand Down

0 comments on commit c5a35f6

Please sign in to comment.