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


Python MessagePrototype.create方法代码示例

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


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

示例1: process

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

        accounts_ids = AccountPrototype.live_query().filter(is_fast=False,
                                                            created_at__lt=datetime.datetime.now() - accounts_settings.RANDOM_PREMIUM_CREATED_AT_BARRIER,
                                                            active_end_at__gt=datetime.datetime.now(),
                                                            premium_end_at__lt=datetime.datetime.now()).exclude(id=self.initiator_id).values_list('id', flat=True)

        if not accounts_ids:
            return False

        account = AccountPrototype.get_by_id(random.choice(accounts_ids))

        with transaction.atomic():
            account.prolong_premium(self.days)
            account.save()

            PersonalMessagePrototype.create(get_system_user(), account, self.MESSAGE % {'days': self.days})

            self.receiver_id = account.id
            self.state = relations.RANDOM_PREMIUM_REQUEST_STATE.PROCESSED
            self.save()

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

示例2: create_remove_member_message

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import create [as 别名]
    def create_remove_member_message(self, initiator, removed_account):
        message = '''
Игрок %(clan_leader_link)s исключил вас из гильдии %(clan_link)s.
''' % {'clan_leader_link': '[url="%s"]%s[/url]' % (full_url('http', 'accounts:show', initiator.id), initiator.nick_verbose),
       'clan_link': '[url="%s"]%s[/url]' % (full_url('http', 'accounts:clans:show', self.id), self.name)}

        MessagePrototype.create(initiator, removed_account, message)
开发者ID:,项目名称:,代码行数:9,代码来源:

示例3: request_friendship

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import create [as 别名]
    def request_friendship(cls, friend_1, friend_2, text=None):
        own_request = cls._get_for(friend_1, friend_2)
        if own_request:
            if text is not None: #
                own_request._model.text = text
                own_request.save()
            return own_request

        his_request = cls._get_for(friend_2, friend_1)
        if his_request:
            his_request._confirm()
            return his_request

        model = cls._model_class.objects.create(friend_1=friend_1._model,
                                                friend_2=friend_2._model,
                                                text=text)
        prototype = cls(model=model)

        message = u'''
игрок %(account_link)s предлагает вам дружить:

%(text)s

----------
принять или отклонить предложение вы можете на этой странице: %(friends_link)s
''' % {'account_link': u'[url="%s"]%s[/url]' % (full_url('http', 'accounts:show', friend_1.id), friend_1.nick_verbose),
       'text': text,
       'friends_link': u'[url="%s"]предложения дружбы[/url]' % full_url('http', 'accounts:friends:candidates')}

        # send message from name of user, who request friendship
        # since many users try to respod to system user
        MessagePrototype.create(friend_1, friend_2, message)

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

示例4: _confirm

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import create [as 别名]
 def _confirm(self):
     MessagePrototype.create(get_system_user(),
                             self.friend_1,
                             u'игрок %(account_link)s подтвердил, что вы являетесь друзьями' %
                             {'account_link': u'[url=%s]%s[/url]' % (full_url('http', 'accounts:show', self.friend_2.id), self.friend_2.nick_verbose)})
     self._model.is_confirmed = True
     self.save()
开发者ID:Alkalit,项目名称:the-tale,代码行数:9,代码来源:prototypes.py

示例5: create_reject_request_message

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import create [as 别名]
    def create_reject_request_message(self, initiator):
        message = '''
Игрок %(clan_leader_link)s отказал вам в принятии в гильдию %(clan_link)s.
''' % {'clan_leader_link': '[url="%s"]%s[/url]' % (full_url('http', 'accounts:show', initiator.id), initiator.nick_verbose),
       'clan_link': '[url="%s"]%s[/url]' % (full_url('http', 'accounts:clans:show', self.clan.id), self.clan.name)}

        MessagePrototype.create(initiator, self.account, message)
开发者ID:,项目名称:,代码行数:9,代码来源:

示例6: portal_day_started

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import create [as 别名]
def portal_day_started(sender, **kwargs): # pylint: disable=W0613
    accounts_query = AccountPrototype.live_query().filter(active_end_at__gt=datetime.datetime.now(),
                                                          ban_game_end_at__lt=datetime.datetime.now(),
                                                          ban_forum_end_at__lt=datetime.datetime.now(),
                                                          premium_end_at__lt=datetime.datetime.now())

    accounts_number = accounts_query.count()
    if accounts_number < 1:
        return

    account_model = accounts_query[random.randint(0, accounts_number-1)]

    account = AccountPrototype(model=account_model)

    settings[portal_settings.SETTINGS_ACCOUNT_OF_THE_DAY_KEY] = str(account.id)

    environment.workers.accounts_manager.cmd_run_account_method(account_id=account.id,
                                                                method_name=AccountPrototype.prolong_premium.__name__,
                                                                data={'days': portal_settings.PREMIUM_DAYS_FOR_HERO_OF_THE_DAY})

    message = u'''
Поздравляем!

Ваш герой выбран героем дня и Вы получаете %(days)d дней подписки!
''' % {'days': portal_settings.PREMIUM_DAYS_FOR_HERO_OF_THE_DAY}

    MessagePrototype.create(get_system_user(), account, message)
开发者ID:Alkalit,项目名称:the-tale,代码行数:29,代码来源:signal_processors.py

示例7: test_index_second_page

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import create [as 别名]
    def test_index_second_page(self):
        for i in range(conf.settings.MESSAGES_ON_PAGE):
            MessagePrototype.create(self.account2, self.account1, 'test message_2_1 %d' % i)

        texts = []
        for i in range(conf.settings.MESSAGES_ON_PAGE):
            texts.append(('test message_2_1 %d' % i, 1))

        self.request_login(self.account1.email)
        self.check_html_ok(self.request_html(url('accounts:messages:')), texts=texts)
开发者ID:,项目名称:,代码行数:12,代码来源:

示例8: setUp

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import create [as 别名]
    def setUp(self):
        super(PrototypeTests, self).setUp()
        create_test_map()

        self.account1 = self.accounts_factory.create_account()
        self.account2 = self.accounts_factory.create_account()
        self.account3 = self.accounts_factory.create_account()

        self.message = MessagePrototype.create(self.account1, self.account2, 'message 1')
        self.message_2 = MessagePrototype.create(self.account1, self.account2, 'message 2')
开发者ID:,项目名称:,代码行数:12,代码来源:

示例9: reset_bans

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

    context.master_account.reset_ban_forum()
    context.master_account.reset_ban_game()

    MessagePrototype.create(logic.get_system_user(),
                            context.master_account,
                            u'С вас сняли все ограничения, наложенные ранее.')

    return dext_views.AjaxOk()
开发者ID:alexudracul,项目名称:the-tale,代码行数:12,代码来源:views.py

示例10: 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 create [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,代码来源:

示例11: increment_level

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import create [as 别名]
    def increment_level(self, send_message=False):
        from the_tale.accounts.prototypes import AccountPrototype
        from the_tale.accounts.personal_messages.prototypes import MessagePrototype
        from the_tale.accounts.logic import get_system_user

        self._model.level += 1
        self.add_message('hero_common_journal_level_up', hero=self, level=self.level)

        self.force_save_required = True

        if send_message:
            account = AccountPrototype.get_by_id(self.account_id)
            MessagePrototype.create(get_system_user(), account, text=u'Поздравляем, Ваш герой получил %d уровень!' % self.level)
开发者ID:Alkalit,项目名称:the-tale,代码行数:15,代码来源:prototypes.py

示例12: create_request_message

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import create [as 别名]
    def create_request_message(self, initiator):
        message = '''
Игрок %(account)s просит принять его в вашу гильдию:

%(text)s

----------
принять или отклонить предложение вы можете на этой странице: %(invites_link)s
''' % {'account': '[url="%s"]%s[/url]' % (full_url('http', 'accounts:show', self.account.id), self.account.nick_verbose),
       'text': self.text,
       'invites_link': '[url="%s"]Заявки в гильдию[/url]' % full_url('http', 'accounts:clans:membership:for-clan')}

        MessagePrototype.create(initiator, self.clan.get_leader(), message)
开发者ID:,项目名称:,代码行数:15,代码来源:

示例13: test_mail_send__to_system_user

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

        Message.objects.all().delete()

        PersonalMessagePrototype.create(self.account_1, get_system_user(), 'test text')

        message = MessagePrototype.get_priority_message()

        self.assertEqual(len(mail.outbox), 0)
        message.process()
        self.assertTrue(message.state.is_PROCESSED)
        self.assertEqual(len(mail.outbox), 0)
开发者ID:,项目名称:,代码行数:15,代码来源:

示例14: create_invite_message

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import create [as 别名]
    def create_invite_message(self, initiator):
        message = '''
Игрок %(clan_leader_link)s предлагает вам вступить в гильдию %(clan_link)s:

%(text)s

----------
принять или отклонить предложение вы можете на этой странице: %(invites_link)s
''' % {'clan_leader_link': '[url="%s"]%s[/url]' % (full_url('http', 'accounts:show', initiator.id), initiator.nick_verbose),
       'text': self.text,
       'clan_link': '[url="%s"]%s[/url]' % (full_url('http', 'accounts:clans:show', self.clan.id), self.clan.name),
       'invites_link': '[url="%s"]Приглашения в гильдию [/url]' % full_url('http', 'accounts:clans:membership:for-account')}

        MessagePrototype.create(initiator, self.account, message)
开发者ID:,项目名称:,代码行数:16,代码来源:

示例15: notify_about_premium_expiration

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

        current_time = datetime.datetime.now()

        message = u'''
До окончания подписки осталось: %(verbose_timedelta)s.

Вы можете продлить подписку на странице нашего %(shop_link)s.
''' % {'verbose_timedelta': verbose_timedelta(self.premium_end_at - current_time),
       'shop_link': u'[url="%s"]магазина[/url]' % full_url('http', 'shop:shop')}

        PersonalMessagePrototype.create(get_system_user(), self, message)
开发者ID:ruckysolis,项目名称:the-tale,代码行数:16,代码来源:prototypes.py


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