本文整理汇总了Python中the_tale.accounts.personal_messages.prototypes.MessagePrototype类的典型用法代码示例。如果您正苦于以下问题:Python MessagePrototype类的具体用法?Python MessagePrototype怎么用?Python MessagePrototype使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MessagePrototype类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_remove_member_message
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)
示例2: request_friendship
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
示例3: process
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
示例4: create_reject_request_message
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)
示例5: _confirm
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()
示例6: portal_day_started
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)
示例7: setUp
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')
示例8: test_index_second_page
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)
示例9: reset_bans
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()
示例10: test_send_premium_expired_notifications
def test_send_premium_expired_notifications(self):
self.assertEqual(PersonalMessagePrototype._db_count(), 0)
register_user("test_user_2", "[email protected]", "111111")
register_user("test_user_3", "[email protected]", "111111")
register_user("test_user_4", "[email protected]", "111111")
account_1 = self.account
account_2 = AccountPrototype.get_by_nick("test_user_2")
account_3 = AccountPrototype.get_by_nick("test_user_3")
account_4 = AccountPrototype.get_by_nick("test_user_4")
account_1.prolong_premium(accounts_settings.PREMIUM_EXPIRED_NOTIFICATION_IN.days - 1)
account_1.save()
account_3.prolong_premium(accounts_settings.PREMIUM_EXPIRED_NOTIFICATION_IN.days - 1)
account_3.save()
account_4.prolong_premium(accounts_settings.PREMIUM_EXPIRED_NOTIFICATION_IN.days + 1)
account_4.save()
zero_time = datetime.datetime.fromtimestamp(0)
self.assertEqual(account_1._model.premium_expired_notification_send_at, zero_time)
self.assertEqual(account_2._model.premium_expired_notification_send_at, zero_time)
self.assertEqual(account_3._model.premium_expired_notification_send_at, zero_time)
self.assertEqual(account_4._model.premium_expired_notification_send_at, zero_time)
AccountPrototype.send_premium_expired_notifications()
account_1.reload()
account_2.reload()
account_3.reload()
account_4.reload()
self.assertNotEqual(account_1._model.premium_expired_notification_send_at, zero_time)
self.assertEqual(account_2._model.premium_expired_notification_send_at, zero_time)
self.assertNotEqual(account_3._model.premium_expired_notification_send_at, zero_time)
self.assertEqual(account_4._model.premium_expired_notification_send_at, zero_time)
current_time = datetime.datetime.now()
self.assertTrue(
current_time - datetime.timedelta(seconds=60)
< account_1._model.premium_expired_notification_send_at
< current_time
)
self.assertTrue(
current_time - datetime.timedelta(seconds=60)
< account_3._model.premium_expired_notification_send_at
< current_time
)
self.assertEqual(PersonalMessagePrototype._db_count(), 2)
示例11: increment_level
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)
示例12: create_request_message
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)
示例13: test_mail_send__to_system_user
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)
示例14: create_invite_message
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)
示例15: notify_about_premium_expiration
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)