Finished admin console
This commit is contained in:
		@@ -70,14 +70,14 @@ $('form[name=form-upload-questions]').submit(function(event) {
 | 
			
		||||
// Edit and Delete Test Button Handlers
 | 
			
		||||
$('.test-action').click(function(event) {
 | 
			
		||||
    
 | 
			
		||||
    let _id = $(this).data('_id');
 | 
			
		||||
    let id = $(this).data('id');
 | 
			
		||||
    let action = $(this).data('action');
 | 
			
		||||
 | 
			
		||||
    if (action == 'delete') {
 | 
			
		||||
    if (action == 'delete' || action == 'start' || action == 'end') {
 | 
			
		||||
        $.ajax({
 | 
			
		||||
            url: `/admin/tests/delete/`,
 | 
			
		||||
            url: `/admin/tests/edit/`,
 | 
			
		||||
            type: 'POST',
 | 
			
		||||
            data: JSON.stringify({'_id': _id}),
 | 
			
		||||
            data: JSON.stringify({'id': id, 'action': action}), // TODO Change how CRUD operations work
 | 
			
		||||
            contentType: 'application/json',
 | 
			
		||||
            success: function(response) {
 | 
			
		||||
                window.location.href = '/admin/tests/';
 | 
			
		||||
@@ -87,21 +87,7 @@ $('.test-action').click(function(event) {
 | 
			
		||||
            },
 | 
			
		||||
        });
 | 
			
		||||
    } else if (action == 'edit') {
 | 
			
		||||
        window.location.href = `/admin/test/${_id}/`
 | 
			
		||||
    } else if (action == 'close'){
 | 
			
		||||
        $.ajax({
 | 
			
		||||
            url: `/admin/tests/close/`,
 | 
			
		||||
            type: 'POST',
 | 
			
		||||
            data: JSON.stringify({'_id': _id}),
 | 
			
		||||
            contentType: 'application/json',
 | 
			
		||||
            success: function(response) {
 | 
			
		||||
                $(window).scrollTop(0);
 | 
			
		||||
                window.location.reload();
 | 
			
		||||
            },
 | 
			
		||||
            error: function(response){
 | 
			
		||||
                error_response(response);
 | 
			
		||||
            },
 | 
			
		||||
        });
 | 
			
		||||
        window.location.href = `/admin/test/${id}/`
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    event.preventDefault();
 | 
			
		||||
@@ -185,13 +171,13 @@ $('#dismiss-cookie-alert').click(function(event){
 | 
			
		||||
// Script for Result Actions
 | 
			
		||||
$('.result-action-buttons').click(function(event){
 | 
			
		||||
 | 
			
		||||
    var _id = $(this).data('_id');
 | 
			
		||||
    var id = $(this).data('id');
 | 
			
		||||
 | 
			
		||||
    if ($(this).data('result-action') == 'generate') {
 | 
			
		||||
        $.ajax({
 | 
			
		||||
            url: '/admin/certificate/',
 | 
			
		||||
            type: 'POST',
 | 
			
		||||
            data: JSON.stringify({'_id': _id}),
 | 
			
		||||
            data: JSON.stringify({'id': id}),
 | 
			
		||||
            contentType: 'application/json',
 | 
			
		||||
            dataType: 'html',
 | 
			
		||||
            success: function(response) {
 | 
			
		||||
@@ -207,7 +193,7 @@ $('.result-action-buttons').click(function(event){
 | 
			
		||||
        $.ajax({
 | 
			
		||||
            url: window.location.href,
 | 
			
		||||
            type: 'POST',
 | 
			
		||||
            data: JSON.stringify({'_id': _id, 'action': action}),
 | 
			
		||||
            data: JSON.stringify({'id': id, 'action': action}),
 | 
			
		||||
            contentType: 'application/json',
 | 
			
		||||
            success: function(response) {
 | 
			
		||||
                if (action == 'delete') {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user