def threads_info(self): if not self._account.is_authenticated(): return {} time_barrier = datetime.datetime.now() - datetime.timedelta(seconds=forum_settings.UNREAD_STATE_EXPIRE_TIME) return {thread.id: thread for thread in ThreadPrototype.from_query(ThreadPrototype._db_filter(updated_at__gt=time_barrier))}
def test_delete(self): category = CategoryPrototype.create(caption='cat-caption', slug='cat-slug', order=0) subcategory_1 = SubCategoryPrototype.create(category=category, caption='subcat-1-caption', order=2) subcategory_2 = SubCategoryPrototype.create(category=category, caption='subcat-2-caption', order=1) thread_1_1 = ThreadPrototype.create(subcategory_1, 'thread-1_1-caption', self.account, 'thread-1_1-text') thread_1_2 = ThreadPrototype.create(subcategory_1, 'thread-1_2-caption', self.account, 'thread-1_2-text') thread_2_1 = ThreadPrototype.create(subcategory_2, 'thread-2_1-caption', self.account, 'thread-2_1-text') subcategory_1.delete() self.assertFalse(ThreadPrototype._db_filter(id__in=(thread_1_1.id, thread_1_2.id)).exists()) self.assertTrue(ThreadPrototype._db_filter(id=thread_2_1.id).exists()) self.assertFalse(SubCategoryPrototype._db_filter(id=subcategory_1.id).exists()) self.assertTrue(SubCategoryPrototype._db_filter(id=subcategory_2.id).exists())
def threads_info(self): if not self._account.is_authenticated: return {} time_barrier = datetime.datetime.now() - datetime.timedelta( seconds=forum_settings.UNREAD_STATE_EXPIRE_TIME) return { thread.id: thread for thread in ThreadPrototype.from_query( ThreadPrototype._db_filter(updated_at__gt=time_barrier)) }