diff --git a/courses/forms.py b/courses/forms.py index eb75607..b620063 100644 --- a/courses/forms.py +++ b/courses/forms.py @@ -8,7 +8,7 @@ class UpdateCourseForm(CourseForm): class Meta: model = Course fields = ('name', 'category', 'coordenator','public') labels = { 'name': _('Name'), 'category': _('Category'), 'coordenator': _('Coordenator'), 'public':_('Public'), } help_texts = { 'name': _('Course name'), 'coordenator': _('Course Coordenator'), 'public':_('To define if the course can be accessed by people not registered'), } widgets = { 'category': forms.Select(), 'coordenator': forms.Select(), } class SubjectForm(forms.ModelForm): def clean_end_date(self): end_date = self.cleaned_data['end_date'] if('init_date' in self.cleaned_data): init_date = self.cleaned_data['init_date'] if init_date and end_date and end_date < init_date: raise forms.ValidationError(_('The end date may not be before the start date.')) return end_date class Meta: model = Subject fields = ('name', 'description','init_date', 'end_date', 'visible',) labels = { 'name': _('Name'), 'description': _('Description'), 'init_date': _('Start date'), 'end_date': _('End date'), 'visible': _('Is it visible?'), } help_texts = { 'name': _("Subjects's name"), 'description': _("Subjects's description"), 'init_date': _('Start date of the subject'), 'end_date': _('End date of the subject'), 'visible': _('Is the subject visible?'), } widgets = { 'description':SummernoteWidget(), } class TopicForm(forms.ModelForm): - class Meta: model = Topic fields = ('name', 'description',) labels = { 'name': _('Name'), 'description': _('Description'), } help_texts = { 'name': _("Topic's name"), 'description': _("Topic's description"), } widgets = { 'description':SummernoteWidget(), } + class Meta: model = Topic fields = ('name', 'description','visible') labels = { 'name': _('Name'), 'description': _('Description'), 'visible': _('Is the topic visible?'), } help_texts = { 'name': _("Topic's name"), 'description': _("Topic's description"), 'visible': _('Is it visible?'), } widgets = { 'description':SummernoteWidget(), } class ActivityFileForm(forms.ModelForm): name = forms.CharField( required=False, max_length=100, widget=forms.TextInput(attrs={ 'placeholder': 'Nome', 'class': 'form-control' },)) pdf = forms.URLField(required=True, widget=S3DirectWidget( dest='activitys', html=( '
' ))) class Meta: model = ActivityFile fields = ['pdf','name'] diff --git a/courses/static/js/topic.js b/courses/static/js/topic.js index 467faab..f5329bb 100644 --- a/courses/static/js/topic.js +++ b/courses/static/js/topic.js @@ -1,30 +1,26 @@ -function openTopic(url, topic, btn) { - var icon = btn.find('i'); - var action = '', log_id; - - if (icon.hasClass('fa-angle-down')) { - icon.removeClass('fa-angle-down'); - icon.addClass('fa-angle-up'); - action = 'open'; - log_id = -1; - } else { - icon.addClass('fa-angle-down'); - icon.removeClass('fa-angle-up'); - action = 'close'; - log_id = $(".topic_" + topic).find(".log_id").val(); +var topic = { + get: function (url, id_div, faz){ + if(!$(id_div + ' div').length || faz == 'true'){ + $.get(url, function(data){ + $(id_div).empty(); + $(id_div).append(data); + }); } - - $.ajax({ - url: url, - data: {"action": action, "log_id": log_id}, - dataType: 'json', - success: function (data) { - if (action == 'open') { - $(".topic_" + topic).find(".log_id").val(data.log_id); - } - }, - error: function(data) { - console.log('Error'); - } - }); -} \ No newline at end of file + }, + post: function(url,dados,id_div){ + $.post(url,dados, function(data){ + $(id_div).empty(); + $.ajax({ + method: "get", + url: data['url'], + success: function(view){ + $(id_div).append(view); + } + }); + alertify.success("Topic updated successfully!"); + }).fail(function(data){ + $(id_div).empty(); + $(id_div).append(data); + }); + } +}; diff --git a/courses/static/js/topic_editation_presentation.js b/courses/static/js/topic_editation_presentation.js deleted file mode 100644 index a241ba2..0000000 --- a/courses/static/js/topic_editation_presentation.js +++ /dev/null @@ -1,15 +0,0 @@ - -$(document).ready(function(){ - $(".editation").hide(); -}); - -function show_editation(id_topic){ - $(".presentation_"+ id_topic).hide(); - $(".editation_"+ id_topic).show(); - $(".editation_"+ id_topic).find('#summernote').summernote({height: 300}); -}; - -function show_presentation(id_topic){ - $(".editation_"+ id_topic).hide(); - $(".presentation_"+ id_topic).show(); -}; diff --git a/courses/templates/subject/create.html b/courses/templates/subject/create.html index 98ef571..07f4848 100644 --- a/courses/templates/subject/create.html +++ b/courses/templates/subject/create.html @@ -11,7 +11,7 @@