当前位置: 首页>>代码示例>>Python>>正文


Python MessagePrototype.get_by_id方法代码示例

本文整理汇总了Python中the_tale.accounts.personal_messages.prototypes.MessagePrototype.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python MessagePrototype.get_by_id方法的具体用法?Python MessagePrototype.get_by_id怎么用?Python MessagePrototype.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在the_tale.accounts.personal_messages.prototypes.MessagePrototype的用法示例。


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

示例1: process

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import get_by_id [as 别名]
    def process(self):
        from the_tale.accounts.personal_messages.prototypes import MessagePrototype as PersonalMessagePrototype

        message = PersonalMessagePrototype.get_by_id(self.message_id)

        if message is None:
            return True # message can be removed by admins or with removed thread

        account = message.recipient

        if not account.personal_messages_subscription:
            return True

        if account.id == get_system_user().id or account.is_bot:
            return True

        if not account.email:
            return True

        subject = '«Сказка»: личное сообщение'

        context = {'message': message}

        html_content = jinja2.render(self.EMAIL_HTML_TEMPLATE, context)
        text_content = jinja2.render(self.EMAIL_TEXT_TEMPLATE, context)

        return logic.send_mail([account], subject, text_content, html_content)
开发者ID:,项目名称:,代码行数:29,代码来源:

示例2: test_remove_old_messages__hiden_by_recipients

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import get_by_id [as 别名]
    def test_remove_old_messages__hiden_by_recipients(self):
        message_3 = MessagePrototype.create(self.account1, self.account2, 'message 3')
        MessagePrototype.create(self.account1, self.account2, 'message 3')

        self.message.hide_from(sender=True)
        self.message_2.hide_from(recipient=True)
        message_3.hide_from(sender=True, recipient=True)

        with self.check_delta(MessagePrototype._db_count, -1):
            MessagePrototype.remove_old_messages()

        self.assertEqual(MessagePrototype.get_by_id(message_3.id), None)
开发者ID:,项目名称:,代码行数:14,代码来源:

示例3: test_remove_old_messages__system_user

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import get_by_id [as 别名]
    def test_remove_old_messages__system_user(self):

        system_user = get_system_user()

        messages = [ MessagePrototype.create(self.account1, self.account2, 'message 1'),
                     MessagePrototype.create(system_user, self.account2, 'message 2'),
                     MessagePrototype.create(self.account1, system_user, 'message 3'),
                     MessagePrototype.create(system_user, system_user, 'message 4'),

                     MessagePrototype.create(self.account1, self.account2, 'message 5'),
                     MessagePrototype.create(system_user, self.account2, 'message 6'),
                     MessagePrototype.create(self.account1, system_user, 'message 7'),
                     MessagePrototype.create(system_user, system_user, 'message 8') ]

        for message in messages[-4:]:
            message._model.created_at = datetime.datetime.now() - conf.settings.SYSTEM_MESSAGES_LEAVE_TIME
            message.save()

        with self.check_delta(MessagePrototype._db_count, -3):
            MessagePrototype.remove_old_messages()

        for message in messages[:5]:
            self.assertNotEqual(MessagePrototype.get_by_id(message.id), None)
开发者ID:,项目名称:,代码行数:25,代码来源:

示例4: test_delete_from_recipient

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import get_by_id [as 别名]
 def test_delete_from_recipient(self):
     self.request_login(self.account2.email)
     self.check_ajax_ok(self.post_ajax_json(url('accounts:messages:delete', self.message.id)))
     message = MessagePrototype.get_by_id(self.message.id)
     self.assertFalse(message.hide_from_sender)
     self.assertTrue(message.hide_from_recipient)
开发者ID:,项目名称:,代码行数:8,代码来源:


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