Commit b1fa582403e9048df3e5807eacf3de52e25bddea

Authored by Jailson Dias
1 parent 4974b066

retirando o exesso de prints

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