Commit af13a2484f87bacbf98d8f429db669376f6b5990

Authored by Matheus Lins
1 parent f6a3a8e6

filter courses only teacher in teacher's template

courses/templates/course/index.html
@@ -55,55 +55,63 @@ @@ -55,55 +55,63 @@
55 55
56 {% if user|has_role:'professor, system_admin' %} 56 {% if user|has_role:'professor, system_admin' %}
57 57
58 -<div class="col-md-12">  
59 - <!-- Put your content here! -->  
60 - <div class="panel-group ui-accordion ui-widget ui-helper-reset ui-sortable" id="accordion" role="tablist" aria-multiselectable="false">  
61 - <div class="group">  
62 - <div class="panel panel-info">  
63 - <div class="panel-heading headingOne ui-sortable-handle" role="tab">  
64 - <div class="row">  
65 - <div class="col-xs-9 col-md-10 titleTopic">  
66 - <a role="button" data-toggle="collapse" data-parent="#accordion" href=".collapseOne" aria-expanded="false" aria-controls="collapseOne" class="collapsed">  
67 - <h4>Course 1</h4>  
68 - </a>  
69 - </div>  
70 - <div class="col-xs-4 col-md-2" id="divMoreActions">  
71 - <div class="btn-group">  
72 - <button type="button" class="btn btn-default btn-sm eye" data-toggle="tooltip" data-placement="bottom" title="Visible">  
73 - <i class="fa fa-eye fa-2x" aria-hidden="true"></i>  
74 - </button>  
75 -  
76 - </div>  
77 - <div class="btn-group">  
78 - <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">  
79 - <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i>  
80 - </button>  
81 - <ul class="dropdown-menu" aria-labelledby="moreActions">  
82 - <li><a href="http://127.0.0.1:8080/html/screens/users/teacher/course_detail_teacher.html"><i class="fa fa-angle-double-right fa-fw" aria-hidden="true"></i>&nbsp; Access</a></li>  
83 - <li><a href="javascript:void(0)" data-toggle="modal" data-target="#myModal4"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>&nbsp; Replicate</a></li>  
84 - <li><a href="javascript:void(0)" data-toggle="modal" data-target="#removeCourse"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>&nbsp; Remove</a></li>  
85 - </ul>  
86 - </div>  
87 - </div>  
88 - </div>  
89 - </div>  
90 - <div class="panel-collapse collapseOne collapse in" role="tabpanel" aria-labelledby="headingOne" aria-expanded="true" aria-hidden="false" tabindex="0">  
91 - <div class="panel-body">  
92 - <p><b>Course Name: </b>Computer Science</p>  
93 - <p><b>Duration (in semesters): </b>09</p>  
94 - <p><b>Coordinator: </b>Alan Turing</p>  
95 - <p>  
96 - <b>Description:</b>  
97 - <i>  
98 - "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."  
99 - </i>  
100 - </p>  
101 -  
102 - </div>  
103 - </div> 58 + <div class="col-md-12">
  59 + {% if subjects_student|length > 0 %}
  60 + {% for subject in subjects_teacher %}
  61 + <!-- Put your content here! -->
  62 + <div class="panel-group ui-accordion ui-widget ui-helper-reset ui-sortable" id="accordion" role="tablist" aria-multiselectable="false">
  63 + <div class="group">
  64 + <div class="panel panel-info">
  65 + <div class="panel-heading headingOne ui-sortable-handle" role="tab">
  66 + <div class="row">
  67 + <div class="col-xs-9 col-md-10 titleTopic">
  68 + <a role="button" data-toggle="collapse" data-parent="#accordion" href=".collapseOne" aria-expanded="false" aria-controls="collapseOne" class="collapsed">
  69 + <h4>{{subject.name}}</h4>
  70 + </a>
  71 + </div>
  72 + <div class="col-xs-4 col-md-2" id="divMoreActions">
  73 + <div class="btn-group">
  74 + <button type="button" class="btn btn-default btn-sm eye" data-toggle="tooltip" data-placement="bottom" title="Visible">
  75 + <i class="fa fa-eye fa-2x" aria-hidden="true"></i>
  76 + </button>
  77 +
  78 + </div>
  79 + <div class="btn-group">
  80 + <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  81 + <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i>
  82 + </button>
  83 + <ul class="dropdown-menu" aria-labelledby="moreActions">
  84 + <li><a href="http://127.0.0.1:8080/html/screens/users/teacher/course_detail_teacher.html"><i class="fa fa-angle-double-right fa-fw" aria-hidden="true"></i>&nbsp; Access</a></li>
  85 + <li><a href="javascript:void(0)" data-toggle="modal" data-target="#myModal4"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>&nbsp; Replicate</a></li>
  86 + <li><a href="javascript:void(0)" data-toggle="modal" data-target="#removeCourse"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>&nbsp; Remove</a></li>
  87 + </ul>
  88 + </div>
  89 + </div>
  90 + </div>
  91 + </div>
  92 + <div class="panel-collapse collapseOne collapse in" role="tabpanel" aria-labelledby="headingOne" aria-expanded="true" aria-hidden="false" tabindex="0">
  93 + <div class="panel-body">
  94 + <p><b>Course Name: </b>{{subject.name}}</p>
  95 + <p><b>Duration (in semesters): </b>09</p>
  96 + <p><b>Coordinator: </b>{{subject.professors}}</p>
  97 + <p>
  98 + <b>Description:</b>
  99 + <i>
  100 + {{subject.description}}
  101 + </i>
  102 + </p>
  103 +
  104 + </div>
  105 + </div>
  106 + </div>
104 </div> 107 </div>
105 -  
106 - <div class="modal" id="removeCourse"> 108 + </div>
  109 + {% endfor %}
  110 + {% else %}
  111 + {% trans 'No courses found' %}
  112 + {% endif %}
  113 + <div class="group">
  114 + <div class="modal" id="removeCourse">
107 <div class="modal-dialog"> 115 <div class="modal-dialog">
108 <div class="modal-content"> 116 <div class="modal-content">
109 <div class="modal-header"> 117 <div class="modal-header">
@@ -111,7 +119,7 @@ @@ -111,7 +119,7 @@
111 <h4 class="modal-title"></h4> 119 <h4 class="modal-title"></h4>
112 </div> 120 </div>
113 <div class="modal-body"> 121 <div class="modal-body">
114 - <p>Delete your Course?</p> 122 + <p>Delete your course?</p>
115 </div> 123 </div>
116 <div class="modal-footer"> 124 <div class="modal-footer">
117 125
@@ -121,35 +129,11 @@ @@ -121,35 +129,11 @@
121 </div> 129 </div>
122 </div> 130 </div>
123 </div> 131 </div>
124 -  
125 -  
126 - </div>  
127 - <div class="group">  
128 - <div class="panel panel-info">  
129 </div> 132 </div>
130 -  
131 -<div class="modal" id="removeCourse2">  
132 - <div class="modal-dialog">  
133 - <div class="modal-content">  
134 - <div class="modal-header">  
135 - <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>  
136 - <h4 class="modal-title"></h4>  
137 - </div>  
138 - <div class="modal-body">  
139 - <p>Delete your course?</p>  
140 - </div>  
141 - <div class="modal-footer">  
142 -  
143 - <a href="http://127.0.0.1:8080/html/screens/users/profile_user.html" target="_self"><button type="button" class="btn btn-primary">Confirm</button></a>  
144 -  
145 - </div>  
146 - </div>  
147 - </div>  
148 -</div></div>  
149 - </div>  
150 - </div> 133 + </div>
151 134
152 {% else %} 135 {% else %}
  136 +
153 <div class="col-md-12"> 137 <div class="col-md-12">
154 <div class="input-group"> 138 <div class="input-group">
155 <div class="form-group is-empty"><input type="search" class="form-control" placeholder="Search Courses"></div> 139 <div class="form-group is-empty"><input type="search" class="form-control" placeholder="Search Courses"></div>
@@ -161,8 +145,8 @@ @@ -161,8 +145,8 @@
161 </div> 145 </div>
162 </div> 146 </div>
163 147
164 - {% if courses|length > 0 %}  
165 - {% for course in courses %} 148 + {% if subjects_student|length > 0 %}
  149 + {% for subject in subjects_student %}
166 <div class="col-md-12"> 150 <div class="col-md-12">
167 <div class="panel panel-info"> 151 <div class="panel panel-info">
168 <!--{% if course.image %} 152 <!--{% if course.image %}
@@ -172,13 +156,13 @@ @@ -172,13 +156,13 @@
172 {% endif %} --> 156 {% endif %} -->
173 <div class="panel-heading"> 157 <div class="panel-heading">
174 <h3 class="panel-title">Course</h3> 158 <h3 class="panel-title">Course</h3>
175 - <span class="label label-info">{{ course.category }}</span>  
176 - <span class="label label-warning">{{ course.max_students }} {% trans 'students tops' %}</span> 159 + <span class="label label-info">{{ subject.category }}</span>
  160 + <span class="label label-warning">{{ subject.max_students }} {% trans 'students tops' %}</span>
177 </div> 161 </div>
178 <div class="panel-body"> 162 <div class="panel-body">
179 - <p><b>Course Name: </b>{{ course.name }}</p> 163 + <p><b>Course Name: </b>{{ subject.name }}</p>
180 <p><b>Duration (in semesters): </b>09</p> 164 <p><b>Duration (in semesters): </b>09</p>
181 - <p><b>Coordinator: </b>{{course.professors}}</p> 165 + <p><b>Coordinator: </b>{{subject.professors}}</p>
182 <p> 166 <p>
183 <b>Description:</b> 167 <b>Description:</b>
184 <i> 168 <i>
@@ -187,16 +171,15 @@ @@ -187,16 +171,15 @@
187 </p> 171 </p>
188 172
189 {% if user|has_role:'professor, system_admin' %} 173 {% if user|has_role:'professor, system_admin' %}
190 - <a href="{% url 'course:update' course.slug %}" class="btn btn-sm btn-primary"> 174 + <a href="{% url 'course:update' subject.slug %}" class="btn btn-sm btn-primary">
191 <span class="glyphicon glyphicon-edit"></span> 175 <span class="glyphicon glyphicon-edit"></span>
192 </a> 176 </a>
193 - <a href="{% url 'course:delete' course.slug %}" class="btn btn-sm btn-danger"> 177 + <a href="{% url 'course:delete' subject.slug %}" class="btn btn-sm btn-danger">
194 <span class="glyphicon glyphicon-trash"></span> 178 <span class="glyphicon glyphicon-trash"></span>
195 </a> 179 </a>
196 {% endif %} 180 {% endif %}
197 181
198 - <a href="{% url 'course:view' course.slug %}" class="btn btn-raised btn-default center-block">View Course</a>  
199 - 182 + <a href="{% url 'course:view' subject.slug %}" class="btn btn-raised btn-default center-block">View Course</a>
200 </div> 183 </div>
201 </div> 184 </div>
202 </div> 185 </div>
courses/views.py
@@ -24,15 +24,13 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): @@ -24,15 +24,13 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView):
24 redirect_field_name = 'next' 24 redirect_field_name = 'next'
25 queryset = Course.objects.all() 25 queryset = Course.objects.all()
26 template_name = 'course/index.html' 26 template_name = 'course/index.html'
27 - context_object_name = 'courses' 27 + context_object_name = 'subjects_student'
28 paginate_by = 3 28 paginate_by = 3
29 29
30 def get_context_data(self, **kwargs): 30 def get_context_data(self, **kwargs):
31 context = super(IndexView, self).get_context_data(**kwargs) 31 context = super(IndexView, self).get_context_data(**kwargs)
32 context['categories'] = Category.objects.all() 32 context['categories'] = Category.objects.all()
33 -  
34 - # context['professors'] = Course.objects.all().select_related('professors__name')  
35 - # super.createNotification(users= User.obejcts.all(), message="testando a notificacao em login") 33 + context['subjects_teacher'] = Course.objects.filter(professors__name = self.request.user.name)
36 return context 34 return context
37 35
38 class CreateCourseView(LoginRequiredMixin, HasRoleMixin, NotificationMixin,generic.edit.CreateView): 36 class CreateCourseView(LoginRequiredMixin, HasRoleMixin, NotificationMixin,generic.edit.CreateView):