Commit b1fa582403e9048df3e5807eacf3de52e25bddea
1 parent
4974b066
Exists in
master
and in
5 other branches
retirando o exesso de prints
Showing
12 changed files
with
24 additions
and
52 deletions
Show diff stats
core/decorators.py
@@ -48,16 +48,15 @@ def log_decorator(log_action = '', log_resource = ''): | @@ -48,16 +48,15 @@ def log_decorator(log_action = '', log_resource = ''): | ||
48 | 48 | ||
49 | 49 | ||
50 | def notification_decorator(read = False, message = '', actor = None, users = [], not_action='', not_resource='', resource_link=''): | 50 | def notification_decorator(read = False, message = '', actor = None, users = [], not_action='', not_resource='', resource_link=''): |
51 | - | 51 | + |
52 | def _notification_decorator(view_function): | 52 | def _notification_decorator(view_function): |
53 | 53 | ||
54 | def _decorator(request, *args, **kwargs): | 54 | def _decorator(request, *args, **kwargs): |
55 | #Do something before the call | 55 | #Do something before the call |
56 | - | 56 | + |
57 | response = view_function(request, *args, **kwargs) | 57 | response = view_function(request, *args, **kwargs) |
58 | action = Action.objects.filter(name = not_action) | 58 | action = Action.objects.filter(name = not_action) |
59 | resource = Resource.objects.filter(name = not_resource) | 59 | resource = Resource.objects.filter(name = not_resource) |
60 | - print(resource_link) | ||
61 | if action.exists(): | 60 | if action.exists(): |
62 | action = action[0] | 61 | action = action[0] |
63 | else: | 62 | else: |
@@ -68,7 +67,6 @@ def notification_decorator(read = False, message = '', actor = None, users = [], | @@ -68,7 +67,6 @@ def notification_decorator(read = False, message = '', actor = None, users = [], | ||
68 | resource = resource[0] | 67 | resource = resource[0] |
69 | else: | 68 | else: |
70 | resource = Resource(name = not_resource, url= resource_link) | 69 | resource = Resource(name = not_resource, url= resource_link) |
71 | - print(resource) | ||
72 | resource.save() | 70 | resource.save() |
73 | 71 | ||
74 | action_resource = Action_Resource.objects.filter(action = action, resource = resource) | 72 | action_resource = Action_Resource.objects.filter(action = action, resource = resource) |
@@ -82,11 +80,11 @@ def notification_decorator(read = False, message = '', actor = None, users = [], | @@ -82,11 +80,11 @@ def notification_decorator(read = False, message = '', actor = None, users = [], | ||
82 | for user in users: | 80 | for user in users: |
83 | notification = Notification(user=user, actor= actor, message=message, action_resource= action_resource) | 81 | notification = Notification(user=user, actor= actor, message=message, action_resource= action_resource) |
84 | notification.save() | 82 | notification.save() |
85 | - | ||
86 | - | 83 | + |
84 | + | ||
87 | #Do something after the call | 85 | #Do something after the call |
88 | return response | 86 | return response |
89 | 87 | ||
90 | return wraps(view_function)(_decorator) | 88 | return wraps(view_function)(_decorator) |
91 | - | ||
92 | - return _notification_decorator | ||
93 | \ No newline at end of file | 89 | \ No newline at end of file |
90 | + | ||
91 | + return _notification_decorator |
core/mixins.py
@@ -47,7 +47,6 @@ class NotificationMixin(object): | @@ -47,7 +47,6 @@ class NotificationMixin(object): | ||
47 | def createNotification(self, message='', actor=None, users = User.objects.all(), resource_slug='' ,action_name = '', resource_name='', resource_link=''): #the default will be a broadcast | 47 | def createNotification(self, message='', actor=None, users = User.objects.all(), resource_slug='' ,action_name = '', resource_name='', resource_link=''): #the default will be a broadcast |
48 | action = Action.objects.filter(name = action_name) | 48 | action = Action.objects.filter(name = action_name) |
49 | resource = Resource.objects.filter(slug = resource_slug) | 49 | resource = Resource.objects.filter(slug = resource_slug) |
50 | - print(message) | ||
51 | if action.exists(): | 50 | if action.exists(): |
52 | action = action[0] | 51 | action = action[0] |
53 | else: | 52 | else: |
@@ -76,5 +75,4 @@ class NotificationMixin(object): | @@ -76,5 +75,4 @@ class NotificationMixin(object): | ||
76 | def dispatch(self, request, *args, **kwargs): | 75 | def dispatch(self, request, *args, **kwargs): |
77 | """ | 76 | """ |
78 | Not quite sure how to do about it""" | 77 | Not quite sure how to do about it""" |
79 | - print("testing IF IT REACHES HERE") | ||
80 | - return super(NotificationMixin, self).dispatch(request, *args, **kwargs) | ||
81 | \ No newline at end of file | 78 | \ No newline at end of file |
79 | + return super(NotificationMixin, self).dispatch(request, *args, **kwargs) |
core/views.py
@@ -102,7 +102,7 @@ def processNotification(self, notificationId): | @@ -102,7 +102,7 @@ def processNotification(self, notificationId): | ||
102 | def getNotifications(request): | 102 | def getNotifications(request): |
103 | context = {} | 103 | context = {} |
104 | if request.user.is_authenticated: | 104 | if request.user.is_authenticated: |
105 | - | 105 | + |
106 | steps = int(request.GET['steps']) | 106 | steps = int(request.GET['steps']) |
107 | amount = int(request.GET['amount']) | 107 | amount = int(request.GET['amount']) |
108 | notifications = Notification.objects.filter(user= request.user, read=False).order_by('-datetime')[steps:steps+amount] | 108 | notifications = Notification.objects.filter(user= request.user, read=False).order_by('-datetime')[steps:steps+amount] |
@@ -110,18 +110,6 @@ def getNotifications(request): | @@ -110,18 +110,6 @@ def getNotifications(request): | ||
110 | else: #go to login page | 110 | else: #go to login page |
111 | return HttpResponse('teste') | 111 | return HttpResponse('teste') |
112 | 112 | ||
113 | - | 113 | + |
114 | html = render_to_string("notifications.html", context) | 114 | html = render_to_string("notifications.html", context) |
115 | - print(html) | ||
116 | return HttpResponse(html) | 115 | return HttpResponse(html) |
117 | - | ||
118 | - | ||
119 | - | ||
120 | - | ||
121 | -# class LoginClass(LoginView): | ||
122 | -# template_name='index.html' | ||
123 | -# | ||
124 | -# def get_context_data(self, **kwargs): | ||
125 | -# context = super(LoginClass,self).get_context_data(**kwargs) | ||
126 | -# print ("deu certo") | ||
127 | -# return context |
courses/templates/category/create.html
courses/templates/category/delete.html
courses/templates/category/index.html
courses/templates/category/update.html
courses/templates/category/view.html
courses/tests/test_topic.py
@@ -85,7 +85,6 @@ class TopicTestCase(TestCase): | @@ -85,7 +85,6 @@ class TopicTestCase(TestCase): | ||
85 | 85 | ||
86 | def test_topic_update(self): | 86 | def test_topic_update(self): |
87 | self.client.login(username='professor', password='testing') | 87 | self.client.login(username='professor', password='testing') |
88 | - print (self.subject.topics.all()) | ||
89 | url = reverse('course:update_topic',kwargs={'slug':self.subject.topics.all()[0].slug}) | 88 | url = reverse('course:update_topic',kwargs={'slug':self.subject.topics.all()[0].slug}) |
90 | data = { | 89 | data = { |
91 | "name": 'new name', | 90 | "name": 'new name', |
courses/views.py
@@ -40,9 +40,9 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): | @@ -40,9 +40,9 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): | ||
40 | else: | 40 | else: |
41 | list_courses = Course.objects.filter(students__name = self.request.user.name) | 41 | list_courses = Course.objects.filter(students__name = self.request.user.name) |
42 | categorys_courses = CourseCategory.objects.filter(course_category__students__name = self.request.user.name).distinct() | 42 | categorys_courses = CourseCategory.objects.filter(course_category__students__name = self.request.user.name).distinct() |
43 | - | 43 | + |
44 | courses_category = Course.objects.filter(category__name = self.request.GET.get('category')) | 44 | courses_category = Course.objects.filter(category__name = self.request.GET.get('category')) |
45 | - | 45 | + |
46 | none = None | 46 | none = None |
47 | q = self.request.GET.get('category', None) | 47 | q = self.request.GET.get('category', None) |
48 | if q is None: | 48 | if q is None: |
@@ -58,7 +58,7 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): | @@ -58,7 +58,7 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): | ||
58 | list_courses = paginator.page(1) | 58 | list_courses = paginator.page(1) |
59 | except EmptyPage: | 59 | except EmptyPage: |
60 | list_courses = paginator.page(paginator.num_pages) | 60 | list_courses = paginator.page(paginator.num_pages) |
61 | - | 61 | + |
62 | context['courses_category'] = courses_category | 62 | context['courses_category'] = courses_category |
63 | context['list_courses'] = list_courses | 63 | context['list_courses'] = list_courses |
64 | context['categorys_courses'] = categorys_courses | 64 | context['categorys_courses'] = categorys_courses |
@@ -74,7 +74,6 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): | @@ -74,7 +74,6 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): | ||
74 | object_list = Course.objects.filter(name__icontains = name) | 74 | object_list = Course.objects.filter(name__icontains = name) |
75 | else: | 75 | else: |
76 | object_list = Course.objects.all() | 76 | object_list = Course.objects.all() |
77 | - print(object_list) | ||
78 | return object_list | 77 | return object_list |
79 | 78 | ||
80 | class CreateCourseView(LoginRequiredMixin, HasRoleMixin, NotificationMixin,generic.edit.CreateView): | 79 | class CreateCourseView(LoginRequiredMixin, HasRoleMixin, NotificationMixin,generic.edit.CreateView): |
@@ -159,7 +158,6 @@ class DeleteCourseView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView): | @@ -159,7 +158,6 @@ class DeleteCourseView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView): | ||
159 | elif has_role(self.request.user,'professor'): | 158 | elif has_role(self.request.user,'professor'): |
160 | courses = self.request.user.courses.all() | 159 | courses = self.request.user.courses.all() |
161 | context['courses'] = courses | 160 | context['courses'] = courses |
162 | - print (courses,"jdhksjbjs") | ||
163 | context['title'] = course.name | 161 | context['title'] = course.name |
164 | 162 | ||
165 | return context | 163 | return context |
@@ -198,15 +196,15 @@ class CourseView(LoginRequiredMixin, NotificationMixin, generic.DetailView): | @@ -198,15 +196,15 @@ class CourseView(LoginRequiredMixin, NotificationMixin, generic.DetailView): | ||
198 | categorys_subjects = CategorySubject.objects.filter(subject_category__professors__name = self.request.user.name).distinct() | 196 | categorys_subjects = CategorySubject.objects.filter(subject_category__professors__name = self.request.user.name).distinct() |
199 | else: | 197 | else: |
200 | categorys_subjects = CategorySubject.objects.filter(subject_category__students__name = self.request.user.name).distinct() | 198 | categorys_subjects = CategorySubject.objects.filter(subject_category__students__name = self.request.user.name).distinct() |
201 | - | 199 | + |
202 | subjects_category = Subject.objects.filter(category__name = self.request.GET.get('category')) | 200 | subjects_category = Subject.objects.filter(category__name = self.request.GET.get('category')) |
203 | - | 201 | + |
204 | none = None | 202 | none = None |
205 | q = self.request.GET.get('category', None) | 203 | q = self.request.GET.get('category', None) |
206 | if q is None: | 204 | if q is None: |
207 | none = True | 205 | none = True |
208 | context['none'] = none | 206 | context['none'] = none |
209 | - | 207 | + |
210 | context['subjects_category'] = subjects_category | 208 | context['subjects_category'] = subjects_category |
211 | context['categorys_subjects'] = categorys_subjects | 209 | context['categorys_subjects'] = categorys_subjects |
212 | context['courses'] = courses | 210 | context['courses'] = courses |
@@ -329,14 +327,14 @@ class SubjectsView(LoginRequiredMixin, generic.ListView): | @@ -329,14 +327,14 @@ class SubjectsView(LoginRequiredMixin, generic.ListView): | ||
329 | else: | 327 | else: |
330 | context['files'] = TopicFile.objects.filter(students__name = self.request.user.name) | 328 | context['files'] = TopicFile.objects.filter(students__name = self.request.user.name) |
331 | return context | 329 | return context |
332 | - | 330 | + |
333 | class UploadMaterialView(LoginRequiredMixin, generic.edit.CreateView): | 331 | class UploadMaterialView(LoginRequiredMixin, generic.edit.CreateView): |
334 | - login_url = reverse_lazy("core:home") | 332 | + login_url = reverse_lazy("core:home") |
335 | redirect_field_name = 'next' | 333 | redirect_field_name = 'next' |
336 | 334 | ||
337 | template_name = 'files/create_file.html' | 335 | template_name = 'files/create_file.html' |
338 | form_class = FileForm | 336 | form_class = FileForm |
339 | - | 337 | + |
340 | def form_invalid(self, form): | 338 | def form_invalid(self, form): |
341 | context = super(UploadMaterialView, self).form_invalid(form) | 339 | context = super(UploadMaterialView, self).form_invalid(form) |
342 | context.status_code = 400 | 340 | context.status_code = 400 |
@@ -345,7 +343,7 @@ class UploadMaterialView(LoginRequiredMixin, generic.edit.CreateView): | @@ -345,7 +343,7 @@ class UploadMaterialView(LoginRequiredMixin, generic.edit.CreateView): | ||
345 | 343 | ||
346 | def get_success_url(self): | 344 | def get_success_url(self): |
347 | self.success_url = reverse('course:view_subject', args = (self.object.slug, )) | 345 | self.success_url = reverse('course:view_subject', args = (self.object.slug, )) |
348 | - | 346 | + |
349 | return self.success_url | 347 | return self.success_url |
350 | 348 | ||
351 | class TopicsView(LoginRequiredMixin, generic.ListView): | 349 | class TopicsView(LoginRequiredMixin, generic.ListView): |
exam/views.py
@@ -67,7 +67,6 @@ class ViewExam(LoginRequiredMixin,generic.DetailView): | @@ -67,7 +67,6 @@ class ViewExam(LoginRequiredMixin,generic.DetailView): | ||
67 | context['answers'] = answers | 67 | context['answers'] = answers |
68 | context['keys'] = keys | 68 | context['keys'] = keys |
69 | 69 | ||
70 | - print (context) | ||
71 | return context | 70 | return context |
72 | 71 | ||
73 | 72 | ||
@@ -170,7 +169,6 @@ class UpdateExam(LoginRequiredMixin,HasRoleMixin,generic.UpdateView): | @@ -170,7 +169,6 @@ class UpdateExam(LoginRequiredMixin,HasRoleMixin,generic.UpdateView): | ||
170 | 169 | ||
171 | answers = {} | 170 | answers = {} |
172 | for answer in exam.answers.all(): | 171 | for answer in exam.answers.all(): |
173 | - # print (key.answer) | ||
174 | answers[answer.order] = answer.answer | 172 | answers[answer.order] = answer.answer |
175 | 173 | ||
176 | keys = sorted(answers) | 174 | keys = sorted(answers) |
poll/views.py
@@ -34,7 +34,6 @@ class ViewPoll(LoginRequiredMixin,generic.DetailView): | @@ -34,7 +34,6 @@ class ViewPoll(LoginRequiredMixin,generic.DetailView): | ||
34 | context['subject'] = poll.topic.subject | 34 | context['subject'] = poll.topic.subject |
35 | context['subjects'] = poll.topic.subject.course.subjects.all() | 35 | context['subjects'] = poll.topic.subject.course.subjects.all() |
36 | answered = AnswersStudent.objects.filter(poll = poll, student=self.request.user) | 36 | answered = AnswersStudent.objects.filter(poll = poll, student=self.request.user) |
37 | - print (answered) | ||
38 | if answered.count()<1: | 37 | if answered.count()<1: |
39 | context['status'] = False | 38 | context['status'] = False |
40 | else: | 39 | else: |
@@ -144,12 +143,8 @@ class UpdatePoll(LoginRequiredMixin,HasRoleMixin,generic.UpdateView): | @@ -144,12 +143,8 @@ class UpdatePoll(LoginRequiredMixin,HasRoleMixin,generic.UpdateView): | ||
144 | context['course'] = poll.topic.subject.course | 143 | context['course'] = poll.topic.subject.course |
145 | context['subject'] = poll.topic.subject | 144 | context['subject'] = poll.topic.subject |
146 | context['subjects'] = poll.topic.subject.course.subjects.all() | 145 | context['subjects'] = poll.topic.subject.course.subjects.all() |
147 | - | ||
148 | - print (self.request.user) | ||
149 | - | ||
150 | answers = {} | 146 | answers = {} |
151 | for answer in poll.answers.all(): | 147 | for answer in poll.answers.all(): |
152 | - # print (key.answer) | ||
153 | answers[answer.order] = answer.answer | 148 | answers[answer.order] = answer.answer |
154 | 149 | ||
155 | keys = sorted(answers) | 150 | keys = sorted(answers) |
@@ -215,7 +210,6 @@ class AnswerStudentPoll(LoginRequiredMixin,generic.CreateView): | @@ -215,7 +210,6 @@ class AnswerStudentPoll(LoginRequiredMixin,generic.CreateView): | ||
215 | 210 | ||
216 | def get_context_data(self, **kwargs): | 211 | def get_context_data(self, **kwargs): |
217 | context = super(AnswerStudentPoll, self).get_context_data(**kwargs) | 212 | context = super(AnswerStudentPoll, self).get_context_data(**kwargs) |
218 | - print (self.kwargs.get('slug')) | ||
219 | poll = get_object_or_404(Poll, slug = self.kwargs.get('slug')) | 213 | poll = get_object_or_404(Poll, slug = self.kwargs.get('slug')) |
220 | context['poll'] = poll | 214 | context['poll'] = poll |
221 | context['topic'] = poll.topic | 215 | context['topic'] = poll.topic |
@@ -223,7 +217,6 @@ class AnswerStudentPoll(LoginRequiredMixin,generic.CreateView): | @@ -223,7 +217,6 @@ class AnswerStudentPoll(LoginRequiredMixin,generic.CreateView): | ||
223 | context['subject'] = poll.topic.subject | 217 | context['subject'] = poll.topic.subject |
224 | context['subjects'] = poll.topic.subject.course.subjects.all() | 218 | context['subjects'] = poll.topic.subject.course.subjects.all() |
225 | 219 | ||
226 | - print (self.request.method) | ||
227 | answers = {} | 220 | answers = {} |
228 | for answer in poll.answers.all(): | 221 | for answer in poll.answers.all(): |
229 | answers[answer.order] = answer.answer | 222 | answers[answer.order] = answer.answer |