Commit 7db9c89ca173142d08aeb4a78eeb6e82c6dd6090
1 parent
aedc5757
Exists in
master
and in
5 other branches
replicate subject
Showing
6 changed files
with
80 additions
and
6 deletions
Show diff stats
courses/templates/course/view.html
| ... | ... | @@ -151,7 +151,7 @@ |
| 151 | 151 | <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> |
| 152 | 152 | </button> |
| 153 | 153 | <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> |
| 154 | - <li><a href="javascript:void(0)" data-toggle="modal" data-target="#myModal3"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i> {% trans 'Replicate' %}</a></li> | |
| 154 | + <li><a href="{% url 'course:replicate_subject' subject.slug %}" data-toggle="modal" data-target="#myModal3"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i> {% trans 'Replicate' %}</a></li> | |
| 155 | 155 | <li><a href="javascript:delete_subject.get('{% url 'course:delete_subject' subject.slug %}','#subject','#modal_subject')" data-toggle="modal" data-target="#removeSubject"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans 'Remove' %}</a></li> |
| 156 | 156 | </ul> |
| 157 | 157 | </div> | ... | ... |
courses/templates/subject/form_view_teacher.html
| ... | ... | @@ -26,7 +26,7 @@ |
| 26 | 26 | {% professor_subject topic.subject user as dropdown_topic %} |
| 27 | 27 | {% if dropdown_topic %} |
| 28 | 28 | <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> |
| 29 | - <li><a href="javascript:void(0)" data-toggle="modal" data-target="#myModal4"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i> {% trans "Replicate" %}</a></li> | |
| 29 | + <li><a href="" data-toggle="modal" data-target="#myModal4"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i> {% trans "Replicate" %}</a></li> | |
| 30 | 30 | <li><a href="javascript:show_editation('{{topic.slug}}')"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i> {% trans "Edit" %}</a></li> |
| 31 | 31 | <li><a href="javascript:void(0)" data-toggle="modal" data-target="#removeTopic"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans "Remove" %}</a></li> |
| 32 | 32 | </ul> | ... | ... |
courses/templates/subject/index.html
| ... | ... | @@ -61,7 +61,7 @@ |
| 61 | 61 | <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> |
| 62 | 62 | </button> |
| 63 | 63 | <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> |
| 64 | - <li><a href="javascript:void(0)"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i> {% trans "Replicate" %}</a></li> | |
| 64 | + <li><a href="{% url 'course:replicate_subject' subject.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i> {% trans "Replicate" %}</a></li> | |
| 65 | 65 | <li><a href="{% url 'course:update_subject' subject.slug %}" <i class="fa fa-pencil fa-fw" aria-hidden="true"></i> {% trans "Edit" %}</a></li> |
| 66 | 66 | <li><a href="{% url 'course:delete_subject' subject.slug %}" ><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans "Remove" %}</a></li> |
| 67 | 67 | </ul> | ... | ... |
| ... | ... | @@ -0,0 +1,44 @@ |
| 1 | +{% extends 'subject/index.html' %} | |
| 2 | + | |
| 3 | +{% load static i18n permission_tags widget_tweaks %} | |
| 4 | + | |
| 5 | +{% block breadcrumbs %} | |
| 6 | + <ol class="breadcrumb"> | |
| 7 | + <li><a href="{% url 'app:index' %}">{% trans 'Home' %}</a></li> | |
| 8 | + <li class="active">{% trans 'Replicate Subject' %}</li> | |
| 9 | + </ol> | |
| 10 | +{% endblock %} | |
| 11 | + | |
| 12 | +{% block content %} | |
| 13 | +<div class="panel panel-default"> | |
| 14 | + <div class="panel-body"> | |
| 15 | + <form class="form-group " method="post" action=""> | |
| 16 | + {% csrf_token %} | |
| 17 | + {% for field in form %} | |
| 18 | + <div class="form-group {% if field.errors %} has-error{% endif %}"> | |
| 19 | + <label for="{{ field.auto_id }}" class="control-label label-static"> {{ field.label }}</label> | |
| 20 | + | |
| 21 | + {% if field.auto_id == 'id_init_date' or field.auto_id == 'id_end_date'%} | |
| 22 | + <input type="text" class="form-control date-picker" name="{{field.name}}" value="{{field.value|date:'SHORT_DATE_FORMAT'}}" min="{{now|date:'SHORT_DATE_FORMAT'}}"> | |
| 23 | + {% else %} | |
| 24 | + {% render_field field class='form-control' placeholder=field.label%} | |
| 25 | + {% endif %} | |
| 26 | + <span class="help-block">{{ field.help_text }}</span> | |
| 27 | + </div> | |
| 28 | + {% endfor %} | |
| 29 | + <div class="col-lg-offset-4 col-lg-4"> | |
| 30 | + <button type="submite" class="btn btn-raised btn-primary btn-lg btn-block">{% trans 'Update' %}</button> | |
| 31 | + </div> | |
| 32 | + </form> | |
| 33 | + | |
| 34 | + </div> | |
| 35 | + </div> | |
| 36 | + | |
| 37 | + <script type="text/javascript"> | |
| 38 | + var locale = navigator.language || navigator.userLanguage; | |
| 39 | + | |
| 40 | + $('.date-picker').datepicker({ | |
| 41 | + language: locale, | |
| 42 | + }); | |
| 43 | + </script> | |
| 44 | +{% endblock %} | |
| 0 | 45 | \ No newline at end of file | ... | ... |
courses/urls.py
| ... | ... | @@ -6,6 +6,7 @@ urlpatterns = [ |
| 6 | 6 | url(r'^all-courses/$', views.AllCoursesView.as_view(), name='all_courses'), |
| 7 | 7 | url(r'^create/$', views.CreateCourseView.as_view(), name='create'), |
| 8 | 8 | url(r'^replicate_course/(?P<slug>[\w_-]+)/$', views.ReplicateCourseView.as_view(), name='replicate_course'), |
| 9 | + url(r'^replicate_subject/(?P<slug>[\w_-]+)/$', views.ReplicateSubjectView.as_view(), name='replicate_subject'), | |
| 9 | 10 | url(r'^edit/(?P<slug>[\w_-]+)/$', views.UpdateCourseView.as_view(), name='update'), |
| 10 | 11 | url(r'^delete/(?P<slug>[\w_-]+)/$', views.DeleteCourseView.as_view(), name='delete'), |
| 11 | 12 | url(r'^subscribe/(?P<slug>[\w_-]+)/$', views.subscribe_course, name='subscribe'), | ... | ... |
courses/views.py
| 1 | -from django.shortcuts import render, get_object_or_404, redirect | |
| 1 | +from django.shortcuts import get_object_or_404 | |
| 2 | 2 | from django.views import generic |
| 3 | 3 | from django.contrib import messages |
| 4 | 4 | from django.contrib.auth.decorators import login_required |
| ... | ... | @@ -12,7 +12,7 @@ from django.db.models import Q |
| 12 | 12 | import operator |
| 13 | 13 | from functools import reduce |
| 14 | 14 | from rolepermissions.verifications import has_object_permission |
| 15 | -from django.http import HttpResponseRedirect, JsonResponse | |
| 15 | +from django.http import JsonResponse | |
| 16 | 16 | from .forms import CourseForm, UpdateCourseForm, CategoryCourseForm, SubjectForm,TopicForm,ActivityForm |
| 17 | 17 | from .models import Course, Subject, CourseCategory,Topic, SubjectCategory,Activity, CategorySubject |
| 18 | 18 | from core.decorators import log_decorator |
| ... | ... | @@ -265,7 +265,7 @@ class UpdateCourseView(LoginRequiredMixin, HasRoleMixin, LogMixin, generic.Updat |
| 265 | 265 | if has_role(self.request.user,'system_admin'): |
| 266 | 266 | courses = Course.objects.all() |
| 267 | 267 | elif has_role(self.request.user,'professor'): |
| 268 | - courses = self.request.user.courses.all() | |
| 268 | + courses = self.request.user.courses_professors.all() | |
| 269 | 269 | context['courses'] = courses |
| 270 | 270 | context['title'] = course.name |
| 271 | 271 | context['now'] = date.today() |
| ... | ... | @@ -577,6 +577,35 @@ class SubjectsView(LoginRequiredMixin, LogMixin, generic.ListView): |
| 577 | 577 | context['files'] = TopicFile.objects.filter(students__name = self.request.user.name) |
| 578 | 578 | return context |
| 579 | 579 | |
| 580 | +class ReplicateSubjectView(LoginRequiredMixin, HasRoleMixin, LogMixin, NotificationMixin,generic.edit.CreateView): | |
| 581 | + | |
| 582 | + allowed_roles = ['professor', 'system_admin'] | |
| 583 | + login_url = reverse_lazy("core:home") | |
| 584 | + redirect_field_name = 'next' | |
| 585 | + template_name = 'subject/replicate.html' | |
| 586 | + form_class = SubjectForm | |
| 587 | + success_url = reverse_lazy('course:view') | |
| 588 | + | |
| 589 | + def get_context_data(self, **kwargs): | |
| 590 | + context = super(ReplicateSubjectView, self).get_context_data(**kwargs) | |
| 591 | + subject = get_object_or_404(Subject, slug=self.kwargs.get('slug')) | |
| 592 | + | |
| 593 | + if has_role(self.request.user,'system_admin'): | |
| 594 | + subjects = Subject.objects.all() | |
| 595 | + context['subjects'] = subjects | |
| 596 | + elif has_role(self.request.user,'professor'): | |
| 597 | + subject = self.request.user.professors_subjects.all() | |
| 598 | + categorys_subjects = CategorySubject.objects.all() | |
| 599 | + | |
| 600 | + context['subject'] = subject | |
| 601 | + context['categorys_subjects'] = categorys_subjects | |
| 602 | + context['title'] = _("Replicate Subject") | |
| 603 | + context['now'] = date.today() | |
| 604 | + return context | |
| 605 | + | |
| 606 | + def get_success_url(self): | |
| 607 | + return reverse_lazy('course:view', kwargs={'slug' : self.object.slug}) | |
| 608 | + | |
| 580 | 609 | class UploadMaterialView(LoginRequiredMixin, generic.edit.CreateView): |
| 581 | 610 | login_url = reverse_lazy("core:home") |
| 582 | 611 | redirect_field_name = 'next' | ... | ... |