Commit af13a2484f87bacbf98d8f429db669376f6b5990
1 parent
f6a3a8e6
Exists in
master
and in
5 other branches
filter courses only teacher in teacher's template
Showing
2 changed files
with
70 additions
and
89 deletions
Show diff stats
courses/templates/course/index.html
... | ... | @@ -55,55 +55,63 @@ |
55 | 55 | |
56 | 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> 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> 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> 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> 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> 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> 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 | 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 | 115 | <div class="modal-dialog"> |
108 | 116 | <div class="modal-content"> |
109 | 117 | <div class="modal-header"> |
... | ... | @@ -111,7 +119,7 @@ |
111 | 119 | <h4 class="modal-title"></h4> |
112 | 120 | </div> |
113 | 121 | <div class="modal-body"> |
114 | - <p>Delete your Course?</p> | |
122 | + <p>Delete your course?</p> | |
115 | 123 | </div> |
116 | 124 | <div class="modal-footer"> |
117 | 125 | |
... | ... | @@ -121,35 +129,11 @@ |
121 | 129 | </div> |
122 | 130 | </div> |
123 | 131 | </div> |
124 | - | |
125 | - | |
126 | - </div> | |
127 | - <div class="group"> | |
128 | - <div class="panel panel-info"> | |
129 | 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 | 135 | {% else %} |
136 | + | |
153 | 137 | <div class="col-md-12"> |
154 | 138 | <div class="input-group"> |
155 | 139 | <div class="form-group is-empty"><input type="search" class="form-control" placeholder="Search Courses"></div> |
... | ... | @@ -161,8 +145,8 @@ |
161 | 145 | </div> |
162 | 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 | 150 | <div class="col-md-12"> |
167 | 151 | <div class="panel panel-info"> |
168 | 152 | <!--{% if course.image %} |
... | ... | @@ -172,13 +156,13 @@ |
172 | 156 | {% endif %} --> |
173 | 157 | <div class="panel-heading"> |
174 | 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 | 161 | </div> |
178 | 162 | <div class="panel-body"> |
179 | - <p><b>Course Name: </b>{{ course.name }}</p> | |
163 | + <p><b>Course Name: </b>{{ subject.name }}</p> | |
180 | 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 | 166 | <p> |
183 | 167 | <b>Description:</b> |
184 | 168 | <i> |
... | ... | @@ -187,16 +171,15 @@ |
187 | 171 | </p> |
188 | 172 | |
189 | 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 | 175 | <span class="glyphicon glyphicon-edit"></span> |
192 | 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 | 178 | <span class="glyphicon glyphicon-trash"></span> |
195 | 179 | </a> |
196 | 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 | 183 | </div> |
201 | 184 | </div> |
202 | 185 | </div> | ... | ... |
courses/views.py
... | ... | @@ -24,15 +24,13 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): |
24 | 24 | redirect_field_name = 'next' |
25 | 25 | queryset = Course.objects.all() |
26 | 26 | template_name = 'course/index.html' |
27 | - context_object_name = 'courses' | |
27 | + context_object_name = 'subjects_student' | |
28 | 28 | paginate_by = 3 |
29 | 29 | |
30 | 30 | def get_context_data(self, **kwargs): |
31 | 31 | context = super(IndexView, self).get_context_data(**kwargs) |
32 | 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 | 34 | return context |
37 | 35 | |
38 | 36 | class CreateCourseView(LoginRequiredMixin, HasRoleMixin, NotificationMixin,generic.edit.CreateView): | ... | ... |