Commit dc2ad35becc02271bf9101acd007cd8a14711c57
1 parent
f38bdc9f
Exists in
master
and in
5 other branches
updatins course forms
Showing
3 changed files
with
16 additions
and
6 deletions
Show diff stats
courses/forms.py
1 | - | ||
2 | from django import forms | 1 | from django import forms |
3 | from django.utils.translation import ugettext_lazy as _ | 2 | from django.utils.translation import ugettext_lazy as _ |
4 | from .models import Category, Course, Subject, Topic, ActivityFile, Activity | 3 | from .models import Category, Course, Subject, Topic, ActivityFile, Activity |
courses/templates/topic/index.html
@@ -74,7 +74,7 @@ | @@ -74,7 +74,7 @@ | ||
74 | <div class="panel panel-default"> | 74 | <div class="panel panel-default"> |
75 | <div class="panel-body"> | 75 | <div class="panel-body"> |
76 | {% for activit in activitys %} | 76 | {% for activit in activitys %} |
77 | - <form class="form-horizontal"> | 77 | + <form class="form-horizontal" enctype='multipart/form-data'>{% csrf_token %} |
78 | <fieldset> | 78 | <fieldset> |
79 | <legend>{{activit.name}}</legend> | 79 | <legend>{{activit.name}}</legend> |
80 | 80 | ||
@@ -107,9 +107,15 @@ | @@ -107,9 +107,15 @@ | ||
107 | <input type="number" step="0.01"> | 107 | <input type="number" step="0.01"> |
108 | </div> | 108 | </div> |
109 | {% else %} | 109 | {% else %} |
110 | - <div class="col-md-4"> | ||
111 | - <input type="file" name="arquivos" class="btn btn-success" multiple/> | 110 | + <div class="col-md-4"> |
111 | + <input type="hidden" name="id" value=""> | ||
112 | + <input type="hidden" name="student" value=""> | ||
113 | + <div class="form-group {% if form.pdf.errors %} has-error {% endif %}"> | ||
114 | + <label for="id_pdf">PDF</label> | ||
115 | + {{form.pdf}} | ||
112 | </div> | 116 | </div> |
117 | + <button type="submit" class="btn btn-success" id="send_button">Enviar</button> | ||
118 | + </div> | ||
113 | {% endif %} | 119 | {% endif %} |
114 | </div> | 120 | </div> |
115 | </div> | 121 | </div> |
courses/views.py
@@ -11,7 +11,7 @@ from rolepermissions.verifications import has_role | @@ -11,7 +11,7 @@ from rolepermissions.verifications import has_role | ||
11 | from django.db.models import Q | 11 | from django.db.models import Q |
12 | from rolepermissions.verifications import has_object_permission | 12 | from rolepermissions.verifications import has_object_permission |
13 | 13 | ||
14 | -from .forms import CourseForm, UpdateCourseForm, CategoryForm, SubjectForm,TopicForm | 14 | +from .forms import CourseForm, UpdateCourseForm, CategoryForm, SubjectForm,TopicForm,ActivityForm |
15 | from .models import Course, Subject, Category,Topic, SubjectCategory,Activity | 15 | from .models import Course, Subject, Category,Topic, SubjectCategory,Activity |
16 | from core.mixins import NotificationMixin | 16 | from core.mixins import NotificationMixin |
17 | from users.models import User | 17 | from users.models import User |
@@ -292,12 +292,17 @@ class TopicsView(LoginRequiredMixin, generic.ListView): | @@ -292,12 +292,17 @@ class TopicsView(LoginRequiredMixin, generic.ListView): | ||
292 | context = super(TopicsView, self).get_context_data(**kwargs) | 292 | context = super(TopicsView, self).get_context_data(**kwargs) |
293 | activitys = Activity.objects.filter(topic__name = topic.name) | 293 | activitys = Activity.objects.filter(topic__name = topic.name) |
294 | students_activit = User.objects.filter(activities = Activity.objects.all()) | 294 | students_activit = User.objects.filter(activities = Activity.objects.all()) |
295 | + # page_user = User.objects.get(id= self.kwargs['user_id']) | ||
295 | context['topic'] = topic | 296 | context['topic'] = topic |
296 | context['subject'] = topic.subject | 297 | context['subject'] = topic.subject |
297 | context['activitys'] = activitys | 298 | context['activitys'] = activitys |
298 | context['students_activit'] = students_activit | 299 | context['students_activit'] = students_activit |
300 | + context['form'] = ActivityForm | ||
301 | + # context['user_activity_id'] = Activity.objects.filter(students__id = self.kwargs['students_id']) | ||
302 | + # context['page_user'] = page_user | ||
299 | return context | 303 | return context |
300 | 304 | ||
305 | + | ||
301 | class CreateTopicView(LoginRequiredMixin, HasRoleMixin, NotificationMixin, generic.edit.CreateView): | 306 | class CreateTopicView(LoginRequiredMixin, HasRoleMixin, NotificationMixin, generic.edit.CreateView): |
302 | 307 | ||
303 | allowed_roles = ['professor', 'system_admin'] | 308 | allowed_roles = ['professor', 'system_admin'] |
@@ -342,7 +347,7 @@ class UpdateTopicView(LoginRequiredMixin, HasRoleMixin, generic.UpdateView): | @@ -342,7 +347,7 @@ class UpdateTopicView(LoginRequiredMixin, HasRoleMixin, generic.UpdateView): | ||
342 | return super(UpdateTopicView, self).dispatch(*args, **kwargs) | 347 | return super(UpdateTopicView, self).dispatch(*args, **kwargs) |
343 | 348 | ||
344 | def get_object(self, queryset=None): | 349 | def get_object(self, queryset=None): |
345 | - return get_object_or_404(Topic, slug = self.kwargs.get('slug')) | 350 | + return get_object_or_404(Topic, slug = self.kwargs.get('slug')) |
346 | 351 | ||
347 | def get_success_url(self): | 352 | def get_success_url(self): |
348 | return reverse_lazy('course:view_subject', kwargs={'slug' : self.object.subject.slug}) | 353 | return reverse_lazy('course:view_subject', kwargs={'slug' : self.object.subject.slug}) |