From af13a2484f87bacbf98d8f429db669376f6b5990 Mon Sep 17 00:00:00 2001 From: Matheus Lins Date: Sat, 1 Oct 2016 17:20:25 -0300 Subject: [PATCH] filter courses only teacher in teacher's template --- courses/templates/course/index.html | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------- courses/views.py | 6 ++---- 2 files changed, 70 insertions(+), 89 deletions(-) diff --git a/courses/templates/course/index.html b/courses/templates/course/index.html index b33d36a..4a27735 100644 --- a/courses/templates/course/index.html +++ b/courses/templates/course/index.html @@ -55,55 +55,63 @@ {% if user|has_role:'professor, system_admin' %} -
- -
-
-
- -
-
-

Course Name: Computer Science

-

Duration (in semesters): 09

-

Coordinator: Alan Turing

-

- Description: - - "Lorem ipsum dolor sit amet, consecctetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." - -

- -
-
+
+ {% if subjects_student|length > 0 %} + {% for subject in subjects_teacher %} + +
+
+
+ +
+
+

Course Name: {{subject.name}}

+

Duration (in semesters): 09

+

Coordinator: {{subject.professors}}

+

+ Description: + + {{subject.description}} + +

+ +
+
+
- - + {% endfor %} + {% else %} + {% trans 'No courses found' %} + {% endif %} +
+ -
-
- -
-
-
+
{% else %} +
@@ -161,8 +145,8 @@
- {% if courses|length > 0 %} - {% for course in courses %} + {% if subjects_student|length > 0 %} + {% for subject in subjects_student %}

Course

- {{ course.category }} - {{ course.max_students }} {% trans 'students tops' %} + {{ subject.category }} + {{ subject.max_students }} {% trans 'students tops' %}
-

Course Name: {{ course.name }}

+

Course Name: {{ subject.name }}

Duration (in semesters): 09

-

Coordinator: {{course.professors}}

+

Coordinator: {{subject.professors}}

Description: @@ -187,16 +171,15 @@

{% if user|has_role:'professor, system_admin' %} - + - + {% endif %} - View Course - + View Course
diff --git a/courses/views.py b/courses/views.py index 0cb496a..7d13b1f 100644 --- a/courses/views.py +++ b/courses/views.py @@ -24,15 +24,13 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): redirect_field_name = 'next' queryset = Course.objects.all() template_name = 'course/index.html' - context_object_name = 'courses' + context_object_name = 'subjects_student' paginate_by = 3 def get_context_data(self, **kwargs): context = super(IndexView, self).get_context_data(**kwargs) context['categories'] = Category.objects.all() - - # context['professors'] = Course.objects.all().select_related('professors__name') - # super.createNotification(users= User.obejcts.all(), message="testando a notificacao em login") + context['subjects_teacher'] = Course.objects.filter(professors__name = self.request.user.name) return context class CreateCourseView(LoginRequiredMixin, HasRoleMixin, NotificationMixin,generic.edit.CreateView): -- libgit2 0.21.2