• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python prototypes.ThreadPrototype类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中the_tale.forum.prototypes.ThreadPrototype的典型用法代码示例。如果您正苦于以下问题:Python ThreadPrototype类的具体用法?Python ThreadPrototype怎么用?Python ThreadPrototype使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ThreadPrototype类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: update

    def update(self, form):

        Vote.objects.filter(bill_id=self.id).delete()

        VotePrototype.create(self.owner, self, VOTE_TYPE.FOR)

        self.data.initialize_with_user_data(form)

        self._model.updated_at = datetime.datetime.now()
        self._model.caption = form.c.caption
        self._model.rationale = form.c.rationale
        self._model.approved_by_moderator = False
        self._model.chronicle_on_accepted = form.c.chronicle_on_accepted

        self.recalculate_votes()

        self.save()

        ActorPrototype.update_actors(self, self.data.actors)

        thread = ThreadPrototype(self._model.forum_thread)
        thread.caption = form.c.caption
        thread.save()

        text = u'[url="%s%s"]Законопроект[/url] был отредактирован, все голоса сброшены.' % (project_settings.SITE_URL,
                                                                                             reverse('game:bills:show', args=[self.id]) )

        PostPrototype.create(thread,
                             get_system_user(),
                             self.bill_info_text(text),
                             technical=True)

        signals.bill_edited.send(self.__class__, bill=self)
开发者ID:Alkalit,项目名称:the-tale,代码行数:33,代码来源:prototypes.py


示例2: threads_info

    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))}
开发者ID:Alkalit,项目名称:the-tale,代码行数:7,代码来源:read_state.py


示例3: setUp

    def setUp(self):
        super(TestModeration, self).setUp()
        create_test_map()
        register_user('main_user', '[email protected]', '111111')
        register_user('moderator', '[email protected]', '111111')
        register_user('second_user', '[email protected]', '111111')

        self.main_account = AccountPrototype.get_by_nick('main_user')
        self.moderator = AccountPrototype.get_by_nick('moderator')
        self.second_account = AccountPrototype.get_by_nick('second_user')

        group = sync_group(forum_settings.MODERATOR_GROUP_NAME, ['forum.moderate_post', 'forum.moderate_thread'])

        group.user_set.add(self.moderator._model)

        self.client = client.Client()

        self.category = CategoryPrototype.create(caption='cat-caption', slug='cat-slug', order=0)
        self.subcategory = SubCategoryPrototype.create(category=self.category, caption='subcat-caption', order=0)
        self.subcategory2 = SubCategoryPrototype.create(category=self.category, caption='subcat2-caption', order=1, closed=True)
        self.thread = ThreadPrototype.create(self.subcategory, 'thread-caption', self.main_account, 'thread-text')
        self.post = PostPrototype.create(self.thread, self.main_account, 'post-text')
        self.post2 = PostPrototype.create(self.thread, self.main_account, 'post2-text')
        self.post5 = PostPrototype.create(self.thread, self.main_account, 'post5-text', technical=True)

        self.thread2 = ThreadPrototype.create(self.subcategory, 'thread2-caption', self.main_account, 'thread2-text')
        self.post3 = PostPrototype.create(self.thread2, self.main_account, 'post3-text')
        self.post4 = PostPrototype.create(self.thread2, self.second_account, 'post4-text')

        self.thread3 = ThreadPrototype.create(self.subcategory, 'thread3-caption', self.second_account, 'thread3-text')
开发者ID:Alkalit,项目名称:the-tale,代码行数:30,代码来源:test_moderation.py


示例4: __init__

    def __init__(self, accounts_factory):
        self.account_1 = accounts_factory.create_account()
        self.account_2 = accounts_factory.create_account()

        # cat1
        # |-subcat1
        # | |-thread1
        # | | |-post1
        # | |-thread2
        # |-subcat2
        # cat2
        # | subcat3
        # | |- thread3
        # cat3

        self.cat_1 = CategoryPrototype.create(caption='cat1-caption', slug='cat1-slug', order=0)
        # to test, that subcat.id not correlate with order
        self.subcat_2 = SubCategoryPrototype.create(category=self.cat_1, caption='subcat2-caption', order=1, closed=True)
        self.subcat_1 = SubCategoryPrototype.create(category=self.cat_1, caption='subcat1-caption', order=0)
        self.cat_2 = CategoryPrototype.create(caption='cat2-caption', slug='cat2-slug', order=0)
        self.subcat_3 = SubCategoryPrototype.create(category=self.cat_2, caption='subcat3-caption', order=0)
        self.cat_3 = CategoryPrototype.create(caption='cat3-caption', slug='cat3-slug', order=0)

        self.thread_1 = ThreadPrototype.create(self.subcat_1, 'thread1-caption', self.account_1, 'thread1-text')
        self.thread_2 = ThreadPrototype.create(self.subcat_1, 'thread2-caption', self.account_1, 'thread2-text')
        self.thread_3 = ThreadPrototype.create(self.subcat_3, 'thread3-caption', self.account_1, 'thread3-text')

        self.post_1 = PostPrototype.create(self.thread_1, self.account_1, 'post1-text')

        # create test clan and clean it's forum artifacts
        self.clan_category = CategoryPrototype.create(caption='category-1', slug=clans_settings.FORUM_CATEGORY_SLUG, order=0)
        self.clan_1 = ClanPrototype.create(self.account_1, abbr='abbr1', name='name1', motto='motto', description='description')
开发者ID:,项目名称:,代码行数:32,代码来源:


示例5: __init__

    def __init__(self):
        register_user('forum_user', '[email protected]', '111111')
        register_user('forum_user_2', '[email protected]', '111111')

        self.account_1 = AccountPrototype.get_by_nick('forum_user')
        self.account_2 = AccountPrototype.get_by_nick('forum_user_2')

        # cat1
        # |-subcat1
        # | |-thread1
        # | | |-post1
        # | |-thread2
        # |-subcat2
        # cat2
        # | subcat3
        # | |- thread3
        # cat3

        self.cat_1 = CategoryPrototype.create(caption='cat1-caption', slug='cat1-slug', order=0)
        # to test, that subcat.id not correlate with order
        self.subcat_2 = SubCategoryPrototype.create(category=self.cat_1, caption='subcat2-caption', order=1, closed=True)
        self.subcat_1 = SubCategoryPrototype.create(category=self.cat_1, caption='subcat1-caption', order=0)
        self.cat_2 = CategoryPrototype.create(caption='cat2-caption', slug='cat2-slug', order=0)
        self.subcat_3 = SubCategoryPrototype.create(category=self.cat_2, caption='subcat3-caption', order=0)
        self.cat_3 = CategoryPrototype.create(caption='cat3-caption', slug='cat3-slug', order=0)

        self.thread_1 = ThreadPrototype.create(self.subcat_1, 'thread1-caption', self.account_1, 'thread1-text')
        self.thread_2 = ThreadPrototype.create(self.subcat_1, 'thread2-caption', self.account_1, 'thread2-text')
        self.thread_3 = ThreadPrototype.create(self.subcat_3, 'thread3-caption', self.account_1, 'thread3-text')

        self.post_1 = PostPrototype.create(self.thread_1, self.account_1, 'post1-text')

        # create test clan and clean it's forum artifacts
        self.clan_category = CategoryPrototype.create(caption='category-1', slug=clans_settings.FORUM_CATEGORY_SLUG, order=0)
        self.clan_1 = ClanPrototype.create(self.account_1, abbr=u'abbr1', name=u'name1', motto=u'motto', description=u'description')
开发者ID:Alkalit,项目名称:the-tale,代码行数:35,代码来源:helpers.py


示例6: test_loggined_create_thread_page__banned

    def test_loggined_create_thread_page__banned(self):
        old_threads_number = ThreadPrototype._db_count()
        self.request_login('[email protected]')
        response = self.client.post(url('forum:subcategories:create-thread', self.subcategory.id),
                                    {'caption': 'thread5-caption', 'text': 'thread5-text'})
        self.check_ajax_error(response, 'common.ban_forum')

        self.assertEqual(old_threads_number, ThreadPrototype._db_count())
开发者ID:Alkalit,项目名称:the-tale,代码行数:8,代码来源:test_moderation.py


示例7: test_post_created_at_turn

    def test_post_created_at_turn(self):
        current_turn = TimePrototype.get_current_time()

        current_turn.increment_turn()
        current_turn.increment_turn()

        ThreadPrototype.create(self.subcategory, 'thread-2-caption', self.account, 'thread-2-text')

        self.assertEqual(PostPrototype._db_latest().created_at_turn, current_turn.turn_number)
开发者ID:,项目名称:,代码行数:9,代码来源:


示例8: test_second_page

    def test_second_page(self):
        texts = [self.thread1.caption,
                 self.thread2.caption,
                 (self.thread3.caption, 0)]
        for i in xrange(forum_settings.THREADS_ON_PAGE):
            caption = 'thread-x-%d-caption' % i
            ThreadPrototype.create(self.subcat1, caption, self.account, 'thread-text')
            texts.append((caption, 0))

        self.check_html_ok(self.request_html(url('forum:subcategories:show', self.subcat1.id, page=2)), texts=texts)
开发者ID:Alkalit,项目名称:the-tale,代码行数:10,代码来源:test_requests.py


示例9: remove

    def remove(self, initiator):
        self.set_remove_initiator(initiator)
        self.state = BILL_STATE.REMOVED
        self.save()

        thread = ThreadPrototype(self._model.forum_thread)
        thread.caption = thread.caption + u" [удалён]"
        thread.save()

        PostPrototype.create(thread, get_system_user(), u"Законопроект был удалён", technical=True)

        signals.bill_removed.send(self.__class__, bill=self)
开发者ID:lshestov,项目名称:the-tale,代码行数:12,代码来源:prototypes.py


示例10: decline

    def decline(self, moderator):
        self.state = relations.POST_STATE.DECLINED
        self.moderator_id = moderator.id
        self.save()

        thread = ForumThreadPrototype(self._model.forum_thread)
        thread.caption = thread.caption + u' [удалён]'
        thread.save()

        ForumPostPrototype.create(thread,
                                  get_system_user(),
                                  u'Произведение было удалено',
                                  technical=True)
开发者ID:ruckysolis,项目名称:the-tale,代码行数:13,代码来源:prototypes.py


示例11: setUp

    def setUp(self):
        super(SubcategoryPrototypeUpdateTests, self).setUp()

        create_test_map()

        self.account = self.accounts_factory.create_account()
        self.checked_account = self.accounts_factory.create_account()

        self.category = CategoryPrototype.create(caption='cat-caption', slug='cat-slug', order=0)
        self.subcategory = SubCategoryPrototype.create(category=self.category, caption='subcat-caption', order=2)

        self.thread_1 = ThreadPrototype.create(self.subcategory, 'thread-1-caption', self.account, 'thread-1-text')
        self.thread_2 = ThreadPrototype.create(self.subcategory, 'thread-2-caption', self.account, 'thread-2-text')
开发者ID:,项目名称:,代码行数:13,代码来源:


示例12: get_subcategory

    def get_subcategory(self, page=1):

        threads_query = Thread.objects.filter(subcategory=self.subcategory._model)

        url_builder = UrlBuilder(reverse('forum:subcategories:show', args=[self.subcategory.id]), arguments={'page': page})

        page -= 1

        paginator = Paginator(page, threads_query.count(), forum_settings.THREADS_ON_PAGE, url_builder)

        if paginator.wrong_page_number:
            return self.redirect(paginator.last_page_url, permanent=False)

        thread_from, thread_to = paginator.page_borders(page)

        threads = ThreadPrototype.from_query(threads_query.select_related().order_by('-important', '-updated_at')[thread_from:thread_to])

        important_threads = sorted([t for t in threads if t.important], key=lambda t: t.caption)
        threads = [t for t in threads if not t.important]

        read_state = ReadState(account=self.account)

        if self.account.is_authenticated:
            SubCategoryReadInfoPrototype.read_subcategory(subcategory=self.subcategory, account=self.account)

        return self.template('forum/subcategory.html',
                             {'category': self.category,
                              'subcategory': self.subcategory,
                              'can_create_thread': can_create_thread(self.account, self.subcategory),
                              'paginator': paginator,
                              'can_subscribe': self.account.is_authenticated and not self.account.is_fast,
                              'has_subscription': SubscriptionPrototype.has_subscription(self.account, subcategory=self.subcategory),
                              'threads': threads,
                              'important_threads': important_threads,
                              'read_state': read_state } )
开发者ID:,项目名称:,代码行数:35,代码来源:


示例13: create

    def create(cls, author, caption, text):

        model = models.Post.objects.create(author=author._model,
                                    caption=caption,
                                    text=text,
                                    state=relations.POST_STATE.ACCEPTED,
                                    created_at_turn=game_prototypes.TimePrototype.get_current_turn_number(),
                                    votes=1)

        thread = ForumThreadPrototype.create(ForumSubCategoryPrototype.get_by_uid(conf.settings.FORUM_CATEGORY_UID),
                                             caption=caption,
                                             author=get_system_user(),
                                             text=u'обсуждение [url="%s%s"]произведения[/url]' % (project_settings.SITE_URL,
                                                                                                  reverse('blogs:posts:show', args=[model.id])),
                                             markup_method=MARKUP_METHOD.POSTMARKUP)

        model.forum_thread = thread._model
        model.save()

        post = cls(model)

        VotePrototype.create(post, author)

        for tag_id in conf.settings.DEFAULT_TAGS:
            models.Tagged.objects.create(post_id=post.id, tag_id=tag_id)

        return post
开发者ID:ruckysolis,项目名称:the-tale,代码行数:27,代码来源:prototypes.py


示例14: create

    def create(cls, owner, caption, rationale, bill, chronicle_on_accepted):

        model = Bill.objects.create(owner=owner._model,
                                    type=bill.type,
                                    caption=caption,
                                    rationale=rationale,
                                    created_at_turn=TimePrototype.get_current_turn_number(),
                                    technical_data=s11n.to_json(bill.serialize()),
                                    state=BILL_STATE.VOTING,
                                    chronicle_on_accepted=chronicle_on_accepted,
                                    votes_for=1) # author always wote for bill

        bill_prototype = cls(model)

        text = u'Обсуждение [url="%s%s"]закона[/url]' % (project_settings.SITE_URL,
                                                         reverse('game:bills:show', args=[model.id]) )

        thread = ThreadPrototype.create(SubCategoryPrototype.get_by_uid(bills_settings.FORUM_CATEGORY_UID),
                                        caption=caption,
                                        author=get_system_user(),
                                        text=bill_prototype.bill_info_text(text),
                                        technical=True,
                                        markup_method=MARKUP_METHOD.POSTMARKUP)

        model.forum_thread = thread._model
        model.save()

        ActorPrototype.update_actors(bill_prototype, bill_prototype.data.actors)

        VotePrototype.create(owner, bill_prototype, VOTE_TYPE.FOR)

        signals.bill_created.send(sender=cls, bill=bill_prototype)

        return bill_prototype
开发者ID:Alkalit,项目名称:the-tale,代码行数:34,代码来源:prototypes.py


示例15: setUp

    def setUp(self):
        super(SubcategoryPrototypeUpdateTests, self).setUp()

        create_test_map()

        register_user('test_user', '[email protected]', '111111')
        register_user('checked_user', '[email protected]', '111111')

        self.account = AccountPrototype.get_by_nick('test_user')
        self.checked_account = AccountPrototype.get_by_nick('checked_user')

        self.category = CategoryPrototype.create(caption='cat-caption', slug='cat-slug', order=0)
        self.subcategory = SubCategoryPrototype.create(category=self.category, caption='subcat-caption', order=2)

        self.thread_1 = ThreadPrototype.create(self.subcategory, 'thread-1-caption', self.account, 'thread-1-text')
        self.thread_2 = ThreadPrototype.create(self.subcategory, 'thread-2-caption', self.account, 'thread-2-text')
开发者ID:Alkalit,项目名称:the-tale,代码行数:16,代码来源:test_prototypes.py


示例16: setUp

    def setUp(self):
        super(ReadStateTests, self).setUp()
        create_test_map()

        register_user("user_1", "[email protected]", "111111")
        register_user("user_2", "[email protected]", "111111")

        self.account = AccountPrototype.get_by_nick("user_1")
        self.account_2 = AccountPrototype.get_by_nick("user_2")

        category = CategoryPrototype.create(caption="cat-caption", slug="cat-slug", order=0)
        self.subcategory = SubCategoryPrototype.create(category=category, caption="subcat-caption", order=0)
        self.subcategory_2 = SubCategoryPrototype.create(category=category, caption="subcat-2-caption", order=0)

        self.thread = ThreadPrototype.create(self.subcategory, "thread1-caption", self.account_2, "thread-text")
        self.thread_2 = ThreadPrototype.create(self.subcategory, "thread2-caption", self.account_2, "thread-2-text")
        self.thread_3 = ThreadPrototype.create(self.subcategory_2, "thread2-caption", self.account, "thread-2-text")
开发者ID:lshestov,项目名称:the-tale,代码行数:17,代码来源:test_read_state.py


示例17: test_last_forum_posts_with_permissions

    def test_last_forum_posts_with_permissions(self):
        granted_account = self.accounts_factory.create_account()
        wrong_account = self.accounts_factory.create_account()

        restricted_subcategory = SubCategoryPrototype.create(category=self.category, caption='subcat2-caption', order=1, restricted=True)

        PermissionPrototype.create(granted_account, restricted_subcategory)

        restricted_thread = ThreadPrototype.create(restricted_subcategory, 'thread-restricted-caption', self.account, 'thread-text')

        self.assertEqual(set(t.id for t in ThreadPrototype.get_last_threads(account=None, limit=3)),
                         set([self.thread.id]))

        self.assertEqual(set(t.id for t in ThreadPrototype.get_last_threads(account=granted_account, limit=3)),
                         set([self.thread.id, restricted_thread.id]))

        self.assertEqual(set(t.id for t in ThreadPrototype.get_last_threads(account=wrong_account, limit=3)),
                         set([self.thread.id]))
开发者ID:,项目名称:,代码行数:18,代码来源:


示例18: test_importans_threads_on_first_page

    def test_importans_threads_on_first_page(self):
        texts = [self.thread1.caption,
                 (self.thread2.caption, 0),
                 (self.thread3.caption, 0)]

        self.thread2._model.important = True
        self.thread2.save()

        for i in xrange(forum_settings.THREADS_ON_PAGE):
            caption = 'thread-x-%d-caption' % i
            ThreadPrototype.create(self.subcat1, caption, self.account, 'thread-text')
            if i != 0:
                texts.append((caption, 0))
            else:
                texts.append(caption)

        self.check_html_ok(self.request_html(url('forum:subcategories:show', self.subcat1.id, page=2)), texts=texts)

        self.check_html_ok(self.request_html(url('forum:subcategories:show', self.subcat1.id, page=1)), texts=[self.thread2.caption])
开发者ID:Alkalit,项目名称:the-tale,代码行数:19,代码来源:test_requests.py


示例19: setUp

    def setUp(self):
        super(NewForumThreadTests, self).setUp()
        create_test_map()

        register_user('user_1', '[email protected]', '111111')
        self.account_1 = AccountPrototype.get_by_nick('user_1')

        self.category = CategoryPrototype.create(caption='cat-caption', slug='cat-slug', order=0)
        self.subcategory = SubCategoryPrototype.create(category=self.category, caption='subcat-caption', order=0)
        self.thread = ThreadPrototype.create(self.subcategory, 'thread_1-caption', self.account_1, 'thread-text')

        self.message = MessagePrototype.get_priority_message()
开发者ID:Alkalit,项目名称:the-tale,代码行数:12,代码来源:test_new_forum_thread.py


示例20: test_last_forum_posts_with_permissions

    def test_last_forum_posts_with_permissions(self):

        register_user('granted_user', '[email protected]', '111111')
        register_user('wrong_user', '[email protected]', '111111')


        granted_account = AccountPrototype.get_by_nick('granted_user')
        wrong_account = AccountPrototype.get_by_nick('wrong_user')

        restricted_subcategory = SubCategoryPrototype.create(category=self.category, caption='subcat2-caption', order=1, restricted=True)

        PermissionPrototype.create(granted_account, restricted_subcategory)

        restricted_thread = ThreadPrototype.create(restricted_subcategory, 'thread-restricted-caption', self.account, 'thread-text')

        self.assertEqual(set(t.id for t in ThreadPrototype.get_last_threads(account=None, limit=3)),
                         set([self.thread.id]))

        self.assertEqual(set(t.id for t in ThreadPrototype.get_last_threads(account=granted_account, limit=3)),
                         set([self.thread.id, restricted_thread.id]))

        self.assertEqual(set(t.id for t in ThreadPrototype.get_last_threads(account=wrong_account, limit=3)),
                         set([self.thread.id]))
开发者ID:Alkalit,项目名称:the-tale,代码行数:23,代码来源:test_prototypes.py



注:本文中的the_tale.forum.prototypes.ThreadPrototype类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python prototypes.ArtifactRecordPrototype类代码示例发布时间:2022-05-27
下一篇:
Python prototypes.SubCategoryReadInfoPrototype类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap