From 9d6a4c6ee65d3da88c9be0b67f089c50e1f45841 Mon Sep 17 00:00:00 2001 From: Felipe Henrique de Almeida Bormann Date: Wed, 18 Jan 2017 13:21:09 -0300 Subject: [PATCH] subscription was made complete --- subjects/static/subjects/js/modal_subject.js | 37 ++++++++++++++++++++++++++++++++++++- subjects/templates/subjects/subject_card.html | 10 ++++++---- subjects/templates/subjects/subscribe.html | 31 ++++++++++++++++++++++--------- subjects/urls.py | 1 + subjects/views.py | 24 ++++++++++++++++++------ 5 files changed, 83 insertions(+), 20 deletions(-) diff --git a/subjects/static/subjects/js/modal_subject.js b/subjects/static/subjects/js/modal_subject.js index 413b938..27d7c9a 100644 --- a/subjects/static/subjects/js/modal_subject.js +++ b/subjects/static/subjects/js/modal_subject.js @@ -28,4 +28,39 @@ var delete_subject = { } }); } -}; \ No newline at end of file +}; + + +var subscribe_subject = { + get: function(url, id_modal, id_div_modal){ + $.get(url, function(data){ + if($(id_modal).length){ + $(id_div_modal).empty(); + } + if (!data['error']){ //If there is no error in the removing process, no message is shown + $(id_div_modal).append(data); + $(id_modal).modal('show'); + }else{ + window.location.href = data['url']; // If there is a error, we redirect to another URL + } + }); + } +} + + +var SubscribeSubject = { + subscribe: function(url,dados,id_li_link){ + $("#subject").modal('toggle'); + $.post(url,dados, function(data){ + $(id_li_link).remove(); + $('body').removeClass('modal-open'); + $("#modal_course").empty(); + $(".modal-backdrop.in").remove(); + alertify.success("Subscription was succesfull!"); + }).fail(function(){ + $("#modal_course").empty(); + $("#modal_course").append(data); + $('#subject').modal('show'); + }); + } +} \ No newline at end of file diff --git a/subjects/templates/subjects/subject_card.html b/subjects/templates/subjects/subject_card.html index a313de0..b6b1a19 100644 --- a/subjects/templates/subjects/subject_card.html +++ b/subjects/templates/subjects/subject_card.html @@ -47,14 +47,16 @@

{% trans "End" %}: {{subject.end_date}}

- -

{{subject.description_brief|safe}}

+ {% if subject.description_brief %} +

{{subject.description_brief|safe}}

+ {% endif %} + {% if show_buttons %} {% if request.user in subject.students.all or request.user in subject.professor.all or request.user.is_staff or request.user in subject.category.coordinators.all %} {% trans "Access Subject" %} {% else %} - {% trans "Subscribe to Subject" %} + {% trans "Subscribe to Subject" %} {% endif %} {% endif %} @@ -115,7 +117,7 @@ {% if request.user in subject.students.all or request.user in subject.professor.all or request.user.is_staff or request.user in subject.category.coordinators.all %} {% trans "Access Subject" %} {% else %} - {% trans "Subscribe to Subject" %} + {% trans "Subscribe to Subject" %} {% endif %} {% endif %} diff --git a/subjects/templates/subjects/subscribe.html b/subjects/templates/subjects/subscribe.html index 8dadf28..bce69a3 100644 --- a/subjects/templates/subjects/subscribe.html +++ b/subjects/templates/subjects/subscribe.html @@ -1,22 +1,35 @@ {% load static i18n permission_tags %} -