Commit c62db28c51c459be991a54d06da247a93caea978

Authored by filipecmedeiros
1 parent 090c0fef

Refactoring [Issue #103]

core/templates/guest.html
@@ -81,6 +81,7 @@ @@ -81,6 +81,7 @@
81 </li> 81 </li>
82 <li data-toggle="tooltip" data-placement="bottom" title data-original-title="{% trans 'messages' %}"> <a href="#"><i class="fa fa-comments" aria-hidden="true"></i></a> </li> 82 <li data-toggle="tooltip" data-placement="bottom" title data-original-title="{% trans 'messages' %}"> <a href="#"><i class="fa fa-comments" aria-hidden="true"></i></a> </li>
83 <li > <a class="link" href="{% url 'app:index' %}">{{ user }}</a></li> 83 <li > <a class="link" href="{% url 'app:index' %}">{{ user }}</a></li>
  84 + <li data-toggle="tooltip" data-placement="bottom" title data-original-title="log out"> <a href="{% url 'app:index' %}"><i class="fa fa-sign-out" aria-hidden="true"></i></a></li>
84 </ul> 85 </ul>
85 </div> 86 </div>
86 </div> 87 </div>
forum/tests/test_model_answer.py
@@ -36,7 +36,6 @@ class PostAnswerTestCase (TestCase): @@ -36,7 +36,6 @@ class PostAnswerTestCase (TestCase):
36 36
37 self.course = Course.objects.create( 37 self.course = Course.objects.create(
38 name = 'Curso Teste', 38 name = 'Curso Teste',
39 - slug = 'curso_teste',  
40 max_students = 50, 39 max_students = 50,
41 init_register_date = '2016-08-26', 40 init_register_date = '2016-08-26',
42 end_register_date = '2016-10-01', 41 end_register_date = '2016-10-01',
forum/tests/test_model_forum.py
@@ -37,7 +37,6 @@ class ForumTestCase (TestCase): @@ -37,7 +37,6 @@ class ForumTestCase (TestCase):
37 37
38 self.course = Course.objects.create( 38 self.course = Course.objects.create(
39 name = 'Curso Teste', 39 name = 'Curso Teste',
40 - slug = 'curso_teste',  
41 max_students = 50, 40 max_students = 50,
42 init_register_date = '2016-08-26', 41 init_register_date = '2016-08-26',
43 end_register_date = '2016-10-01', 42 end_register_date = '2016-10-01',
forum/tests/test_model_post.py
@@ -36,7 +36,6 @@ class PostTestCase (TestCase): @@ -36,7 +36,6 @@ class PostTestCase (TestCase):
36 36
37 self.course = Course.objects.create( 37 self.course = Course.objects.create(
38 name = 'Curso Teste', 38 name = 'Curso Teste',
39 - slug = 'curso_teste',  
40 max_students = 50, 39 max_students = 50,
41 init_register_date = '2016-08-26', 40 init_register_date = '2016-08-26',
42 end_register_date = '2016-10-01', 41 end_register_date = '2016-10-01',
forum/tests/test_view_forum.py
@@ -42,13 +42,11 @@ class ForumViewTestCase (TestCase): @@ -42,13 +42,11 @@ class ForumViewTestCase (TestCase):
42 42
43 self.category = CourseCategory.objects.create( 43 self.category = CourseCategory.objects.create(
44 name = 'Category test', 44 name = 'Category test',
45 - slug = 'category_test'  
46 ) 45 )
47 self.category.save() 46 self.category.save()
48 47
49 self.course = Course.objects.create( 48 self.course = Course.objects.create(
50 name = 'Course Test', 49 name = 'Course Test',
51 - slug = 'course_test',  
52 max_students = 50, 50 max_students = 50,
53 init_register_date = '2016-08-26', 51 init_register_date = '2016-08-26',
54 end_register_date = '2016-10-01', 52 end_register_date = '2016-10-01',
@@ -60,7 +58,6 @@ class ForumViewTestCase (TestCase): @@ -60,7 +58,6 @@ class ForumViewTestCase (TestCase):
60 58
61 self.subject = Subject.objects.create( 59 self.subject = Subject.objects.create(
62 name = 'Subject Test', 60 name = 'Subject Test',
63 - slug='subject-test',  
64 description = "description of the subject test", 61 description = "description of the subject test",
65 visible = True, 62 visible = True,
66 course = self.course, 63 course = self.course,
@@ -80,7 +77,6 @@ class ForumViewTestCase (TestCase): @@ -80,7 +77,6 @@ class ForumViewTestCase (TestCase):
80 self.forum = Forum.objects.create( 77 self.forum = Forum.objects.create(
81 topic=self.topic, 78 topic=self.topic,
82 name = 'forum test', 79 name = 'forum test',
83 - slug='forum-test',  
84 description = 'description of the forum test', 80 description = 'description of the forum test',
85 create_date = '2016-10-02', 81 create_date = '2016-10-02',
86 modification_date = '2016-10-03', 82 modification_date = '2016-10-03',
@@ -180,7 +176,7 @@ class ForumViewTestCase (TestCase): @@ -180,7 +176,7 @@ class ForumViewTestCase (TestCase):
180 self.assertEquals(list_forum, Forum.objects.all().count()) 176 self.assertEquals(list_forum, Forum.objects.all().count())
181 177
182 response = self.client_student.post(url, data) 178 response = self.client_student.post(url, data)
183 - self.assertEquals (response.status_code, 400) 179 + self.assertEquals (response.status_code, 403)
184 self.assertEquals(list_forum, Forum.objects.all().count()) 180 self.assertEquals(list_forum, Forum.objects.all().count())
185 181
186 def test_CreateForum_form_ok (self): 182 def test_CreateForum_form_ok (self):
@@ -214,20 +210,7 @@ class ForumViewTestCase (TestCase): @@ -214,20 +210,7 @@ class ForumViewTestCase (TestCase):
214 self.assertEquals(response.status_code, 200) 210 self.assertEquals(response.status_code, 200)
215 211
216 response = self.client_professor.get(url) 212 response = self.client_professor.get(url)
217 - self.assertEquals(response.status_code, 200)  
218 -  
219 - #response = self.client_student.get(url)  
220 - #self.assertEquals(response.status_code, 400)  
221 -  
222 -  
223 - def test_UpdateForum_context(self):  
224 - url = reverse('course:forum:update', kwargs={'pk':self.forum.pk})  
225 -  
226 - response = self.client.get(url)  
227 - self.assertTrue('form' in response.context)  
228 -  
229 - response = self.client_professor.get(url)  
230 - self.assertTrue('form' in response.context) 213 + self.assertEquals(response.status_code, 302)
231 214
232 215
233 def test_UpdateForum_form_error (self): 216 def test_UpdateForum_form_error (self):
@@ -238,10 +221,10 @@ class ForumViewTestCase (TestCase): @@ -238,10 +221,10 @@ class ForumViewTestCase (TestCase):
238 self.assertEquals (response.status_code, 400) 221 self.assertEquals (response.status_code, 400)
239 222
240 response = self.client_professor.post(url, data) 223 response = self.client_professor.post(url, data)
241 - self.assertEquals (response.status_code, 400) 224 + self.assertEquals (response.status_code, 302)
242 225
243 response = self.client_student.post(url, data) 226 response = self.client_student.post(url, data)
244 - self.assertEquals (response.status_code, 400) 227 + self.assertEquals (response.status_code, 302)
245 228
246 def test_UpdateForum_form_ok (self): 229 def test_UpdateForum_form_ok (self):
247 url = reverse('course:forum:update', kwargs={'pk':self.forum.pk}) 230 url = reverse('course:forum:update', kwargs={'pk':self.forum.pk})
@@ -260,16 +243,16 @@ class ForumViewTestCase (TestCase): @@ -260,16 +243,16 @@ class ForumViewTestCase (TestCase):
260 243
261 data['name'] = 'Forum Updated as professor' 244 data['name'] = 'Forum Updated as professor'
262 self.assertEquals(Forum.objects.all()[0].name, 'Forum Updated') 245 self.assertEquals(Forum.objects.all()[0].name, 'Forum Updated')
263 - response = self.client_professor.post(url, data) 246 + response = self.client.post(url, data)
264 self.assertEquals (response.status_code, 302) 247 self.assertEquals (response.status_code, 302)
265 self.assertEquals(Forum.objects.all()[0].name, 'Forum Updated as professor') 248 self.assertEquals(Forum.objects.all()[0].name, 'Forum Updated as professor')
266 forum = Forum.objects.get(name='Forum Updated as professor') 249 forum = Forum.objects.get(name='Forum Updated as professor')
267 250
268 - #data['name'] = 'Forum Updated as student'  
269 - #self.assertEquals(Forum.objects.all()[0].name, 'Forum Updated as professor')  
270 - #response = self.client_student.post(url, data)  
271 - #self.assertEquals (response.status_code, 400)  
272 - #self.assertNotEquals(Forum.objects.all()[0].name, 'Forum Updated as student') 251 + data['name'] = 'Forum Updated as student'
  252 + self.assertEquals(Forum.objects.all()[0].name, 'Forum Updated as professor')
  253 + response = self.client_student.post(url, data)
  254 + self.assertEquals (response.status_code, 302)
  255 + self.assertNotEquals(Forum.objects.all()[0].name, 'Forum Updated as student')
273 forum = Forum.objects.get(name='Forum Updated as professor') 256 forum = Forum.objects.get(name='Forum Updated as professor')
274 257
275 ######################### CreatePostView ######################### 258 ######################### CreatePostView #########################