From 9eb35814cc7f360a9fc632fa9f2bb83481a3f2af Mon Sep 17 00:00:00 2001 From: Felipe Henrique de Almeida Bormann Date: Mon, 26 Dec 2016 17:13:43 -0300 Subject: [PATCH] delete course is working but still has course inside it's name function, we have to replace most of them for naming purposes --- amadeus/static/js/course.js | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ categories/templates/categories/delete.html | 36 ++++++++++++++++++++++++++++++++++++ categories/templates/categories/list.html | 17 +++++++++++------ categories/urls.py | 2 +- categories/views.py | 17 ++++++++++++++++- 5 files changed, 165 insertions(+), 8 deletions(-) create mode 100755 amadeus/static/js/course.js create mode 100644 categories/templates/categories/delete.html diff --git a/amadeus/static/js/course.js b/amadeus/static/js/course.js new file mode 100755 index 0000000..540053f --- /dev/null +++ b/amadeus/static/js/course.js @@ -0,0 +1,101 @@ +var locale = navigator.language || navigator.userLanguage; + +$('.date-picker').datepicker({ + language: locale, +}); + +/* +* +* Function to get a cookie stored on browser +* +*/ +function getCookie(name) { + var cookieValue = null; + if (document.cookie && document.cookie !== '') { + var cookies = document.cookie.split(';'); + for (var i = 0; i < cookies.length; i++) { + var cookie = jQuery.trim(cookies[i]); + // Does this cookie string begin with the name we want? + if (cookie.substring(0, name.length + 1) === (name + '=')) { + cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); + break; + } + } + } + return cookieValue; +} +/* +* +* Function to subscribe (works for courses and subjects) +* +*/ +function subscribe(elem, url, id, confirm_message) { + alertify.confirm(confirm_message, function(){ + $.ajax({ + dataType: "json", + url: url, + success: function (data) { + if (data.status == "ok") { + elem.remove(); + alertify.success(data.message); + $(".panel_"+id).find(".view_btn").show() + } else { + alertify.error(data.message); + } + } + }); + }); +} + +/* +* +* Function to delete a course +* +*/ + +var RemoveCourse = { + remove: function(url,dados,id_li_link){ + $('#category').modal().hide(); + $.post(url,dados, function(data){ + $(id_li_link).remove(); + // alert("certo"); + $('body').removeClass('modal-open'); + $("#modal_course").empty(); + $(".modal-backdrop.in").remove(); + alertify.success("Course removed successfully!"); + // setTimeout(function () { location.reload(1); }, 1); + }).fail(function(){ + $("#modal_course").empty(); + $("#modal_course").append(data); + $('#course').modal('show'); + }); + } +} + +var delete_course = { + get: function (url, id_modal, id_div_modal){ + $.get(url, function(data){ + if($(id_modal).length){ + $(id_div_modal).empty(); + $(id_div_modal).append(data); + } else { + $(id_div_modal).append(data); + } + $(id_modal).modal('show'); + }); + } +}; +/* +* +* Function to load create course's form +* +*/ +function replicate_course(url, course) { + $.ajax({ + url: url, + data: {'form': course}, + success: function(data) { + $(".course_replicate_form").html(data); + } + }); +} diff --git a/categories/templates/categories/delete.html b/categories/templates/categories/delete.html new file mode 100644 index 0000000..ad0f084 --- /dev/null +++ b/categories/templates/categories/delete.html @@ -0,0 +1,36 @@ +{% load static i18n permission_tags %} + + + \ No newline at end of file diff --git a/categories/templates/categories/list.html b/categories/templates/categories/list.html index 71eab69..eef74a4 100755 --- a/categories/templates/categories/list.html +++ b/categories/templates/categories/list.html @@ -37,16 +37,21 @@ {{category.name}} - {% if user|has_role:'sys_admin' %} -