diff --git a/courses/forms.py b/courses/forms.py index 335e504..eb75607 100644 --- a/courses/forms.py +++ b/courses/forms.py @@ -5,7 +5,7 @@ class CourseForm(forms.ModelForm): 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 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): init_date = self.cleaned_data['init_date'] end_date = self.cleaned_data['end_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 = 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(), } diff --git a/courses/static/js/course.js b/courses/static/js/course.js index 102403d..6c84328 100644 --- a/courses/static/js/course.js +++ b/courses/static/js/course.js @@ -55,9 +55,11 @@ function subscribe(elem, url, id, confirm_message) { var RemoveCourse = { remove: function(url,dados,id_li_link){ - $('#course').modal('hide'); + $('#course').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!"); diff --git a/courses/static/js/modal_subject.js b/courses/static/js/modal_subject.js index 3b04765..d62ad49 100644 --- a/courses/static/js/modal_subject.js +++ b/courses/static/js/modal_subject.js @@ -1,31 +1,27 @@ var RemoveSubject = { remove: function(url,dados,id_li_link){ - $('#subject').modal('hide'); + $("#subject").modal('toggle'); $.post(url,dados, function(data){ $(id_li_link).remove(); - $("#modal_subject").empty(); - $("#accordion").remove(); + $('body').removeClass('modal-open'); + $("#modal_course").empty(); $(".modal-backdrop.in").remove(); alertify.success("Subject removed successfully!"); - setTimeout(function () { location.reload(1); }, 2000); }).fail(function(){ - $("#modal_subject").empty(); - $("#modal_subject").append(data); + $("#modal_course").empty(); + $("#modal_course").append(data); $('#subject').modal('show'); }); } } - var delete_subject = { 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_div_modal).append(data); $(id_modal).modal('show'); }); } -}; \ No newline at end of file +}; diff --git a/courses/templates/course/delete.html b/courses/templates/course/delete.html index ef11ebf..5d4824c 100644 --- a/courses/templates/course/delete.html +++ b/courses/templates/course/delete.html @@ -34,5 +34,3 @@ - - diff --git a/courses/templates/course/view.html b/courses/templates/course/view.html index 2263029..6b44497 100644 --- a/courses/templates/course/view.html +++ b/courses/templates/course/view.html @@ -64,7 +64,7 @@ alertify.success('{{message}}');
{% for subject in subjects %} -
+
diff --git a/courses/templates/subject/create.html b/courses/templates/subject/create.html index b226c02..98ef571 100644 --- a/courses/templates/subject/create.html +++ b/courses/templates/subject/create.html @@ -19,7 +19,7 @@ {% endif %} {% if field.auto_id == 'id_init_date' or field.auto_id == 'id_end_date'%} - + {% render_field field class='form-control date-picker'%} {% elif field.auto_id == 'id_visible' %}
{% endfor %}
@@ -44,6 +59,7 @@ $('.date-picker').datepicker({ language: locale, + startDate: "dateToday", }); {% endblock content %} diff --git a/courses/templates/subject/delete.html b/courses/templates/subject/delete.html index 2da016e..c7caf5d 100644 --- a/courses/templates/subject/delete.html +++ b/courses/templates/subject/delete.html @@ -22,15 +22,16 @@ - + + {% if index %} + + {% endif %}
- - diff --git a/courses/templates/subject/index.html b/courses/templates/subject/index.html index 1a5bf68..b414492 100644 --- a/courses/templates/subject/index.html +++ b/courses/templates/subject/index.html @@ -10,6 +10,7 @@ + {% endblock %} {% block breadcrumbs %} @@ -35,7 +36,7 @@
{% endif %} @@ -102,4 +103,7 @@ + {% endblock %} diff --git a/courses/templates/subject/update.html b/courses/templates/subject/update.html index 9d7ce83..1f934e0 100644 --- a/courses/templates/subject/update.html +++ b/courses/templates/subject/update.html @@ -1,10 +1,10 @@ {% extends 'subject/index.html' %} -{% load static i18n permission_tags widget_tweaks django_bootstrap_breadcrumbs %} +{% load static i18n permission_tags widget_tweaks django_bootstrap_breadcrumbs course_value_field %} {% block breadcrumbs %} {{ block.super }} - {% breadcrumb 'Update subject' 'course:update_subject' %} + {% breadcrumb 'Replicate subject' 'course:replicate_subject' %} {% endblock breadcrumbs %} {% block content %} @@ -15,14 +15,45 @@ {% csrf_token %} {% for field in form %}
- - + {% if field.auto_id != 'id_visible' %} + + {% endif %} {% if field.auto_id == 'id_init_date' or field.auto_id == 'id_end_date'%} - + {% render_field field class='form-control date-picker'%} + {% elif field.auto_id == 'id_visible' %} + {% value_subject_field subject field.name as value_field %} +
+ +
{% else %} - {% render_field field class='form-control' placeholder=field.label%} + {% if field.errors %} + {% render_field field class='form-control' %} + {% else %} + {% if field.auto_id == 'id_description'%} + + {% else %} + {% render_field field class='form-control'%} + {% endif %} + {% endif %} {% endif %} {{ field.help_text }} + {% if field.errors %} +
+
+ +
+ {% endif %}
{% endfor %}
@@ -37,6 +68,10 @@ $('.date-picker').datepicker({ language: locale, + startDate: "dateToday", + }); + $(document).ready(function() { + $('#id_description').summernote(); }); {% endblock content %} diff --git a/courses/views.py b/courses/views.py index d401e8d..3fd9b63 100644 --- a/courses/views.py +++ b/courses/views.py @@ -933,6 +933,10 @@ class DeleteSubjectView(LoginRequiredMixin, HasRoleMixin, LogMixin, generic.Dele context['subjects'] = self.object.course.subjects.filter(Q(visible=True) | Q(professors__in=[self.request.user])) if (has_role(self.request.user,'system_admin')): context['subjects'] = self.object.course.subjects.all() + if (self.request.GET.get('view') == 'index'): + context['index'] = True + else: + context['index'] = False return context def get_success_url(self): -- libgit2 0.21.2