##// END OF EJS Templates
Fixed thread gallery view
neko259 -
r889:ab1b39f3 default
parent child Browse files
Show More
@@ -127,7 +127,7 b' class Thread(models.Model):'
127
127
128 query = self.replies.order_by('pub_time').prefetch_related('images')
128 query = self.replies.order_by('pub_time').prefetch_related('images')
129 if view_fields_only:
129 if view_fields_only:
130 query = query.defer('poster_user_agent', 'text_markup_type')
130 query = query.defer('poster_user_agent')
131 return query.all()
131 return query.all()
132
132
133 def get_replies_with_images(self, view_fields_only=False):
133 def get_replies_with_images(self, view_fields_only=False):
@@ -112,4 +112,25 b' class PostTests(TestCase):'
112 first_post = posts_in_second_page[0]
112 first_post = posts_in_second_page[0]
113
113
114 self.assertEqual(all_threads[settings.THREADS_PER_PAGE].id,
114 self.assertEqual(all_threads[settings.THREADS_PER_PAGE].id,
115 first_post.id) No newline at end of file
115 first_post.id)
116
117 def test_thread_replies(self):
118 """
119 Tests that the replies can be queried from a thread in all possible
120 ways.
121 """
122
123 tag = Tag.objects.create(name='test_tag')
124 opening_post = Post.objects.create_post(title='title', text='text',
125 tags=[tag])
126 thread = opening_post.get_thread()
127
128 reply1 = Post.objects.create_post(title='title', text='text', thread=thread)
129 reply2 = Post.objects.create_post(title='title', text='text', thread=thread)
130
131 replies = thread.get_replies()
132 self.assertTrue(len(replies) > 0, 'No replies found for thread.')
133
134 replies = thread.get_replies(view_fields_only=True)
135 self.assertTrue(len(replies) > 0,
136 'No replies found for thread with view fields only.')
General Comments 0
You need to be logged in to leave comments. Login now