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


Python logic.get_system_user函数代码示例

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


在下文中一共展示了get_system_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: remove_old_messages

    def remove_old_messages(cls):
        cls._db_filter(hide_from_sender=True, hide_from_recipient=True).delete()

        system_user = get_system_user()

        cls._db_filter(recipient=system_user.id, created_at__lt=datetime.datetime.now() - conf.settings.SYSTEM_MESSAGES_LEAVE_TIME).delete()
        cls._db_filter(sender=system_user.id, created_at__lt=datetime.datetime.now() - conf.settings.SYSTEM_MESSAGES_LEAVE_TIME).delete()
开发者ID:Alkalit,项目名称:the-tale,代码行数:7,代码来源:prototypes.py

示例3: setUp

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

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account()
        self.account_3 = self.accounts_factory.create_account()

        self.news = news_logic.create_news(caption='news-caption', description='news-description', content='news-content')

        news_logic.send_mails(self.news)

        self.message = MessagePrototype.get_priority_message()

        # enshure that system user exists
        accounts_logic.get_system_user()
开发者ID:Alkalit,项目名称:the-tale,代码行数:16,代码来源:test_news.py

示例4: process

    def process(self, main_task, storage=None): # pylint: disable=R0911

        if self.step.is_UNPROCESSED:

            account = accounts_prototypes.AccountPrototype.get_by_id(self.account_id)

            system_user = accounts_logic.get_system_user()

            if account.is_ban_forum:
                main_task.comment = 'account is banned'
                self.state = self.STATE.BANNED
                return POSTPONED_TASK_LOGIC_RESULT.ERROR

            accounts = accounts_prototypes.AccountPrototype.get_list_by_id(self.recipients)

            for recipient in accounts:

                if recipient.id == system_user.id:
                    main_task.comment = 'system user'
                    self.state = self.STATE.SYSTEM_USER
                    return POSTPONED_TASK_LOGIC_RESULT.ERROR

                if recipient.is_fast:
                    main_task.comment = 'fast user'
                    self.state = self.STATE.FAST_USER
                    return POSTPONED_TASK_LOGIC_RESULT.ERROR

            for recipient in accounts_prototypes.AccountPrototype.get_list_by_id(self.recipients):
                prototypes.MessagePrototype.create(account, recipient, self.message)

            self.step = self.STEP.PROCESSED
            return POSTPONED_TASK_LOGIC_RESULT.SUCCESS
开发者ID:Jazzis18,项目名称:the-tale,代码行数:32,代码来源:postponed_tasks.py

示例5: 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

示例6: 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
开发者ID:ruckysolis,项目名称:the-tale,代码行数:25,代码来源:prototypes.py

示例7: 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

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

示例9: _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()
开发者ID:Alkalit,项目名称:the-tale,代码行数:7,代码来源:prototypes.py

示例10: request_dialog

    def request_dialog(self, friend):

        if friend.id == get_system_user().id:
            return self.auto_error('friends.request_dialog.system_user', u'Вы не можете пригласить в друзья системного пользователя')

        return self.template('friends/request_dialog.html',
                             {'friend': friend,
                              'form': RequestForm()})
开发者ID:Jazzis18,项目名称:the-tale,代码行数:8,代码来源:views.py

示例11: test_mail_send__to_system_user

    def test_mail_send__to_system_user(self):
        from the_tale.accounts.logic import get_system_user

        SubscriptionPrototype.create(get_system_user(), subcategory=self.subcategory)
        self.assertEqual(len(mail.outbox), 0)
        self.message.process()
        self.assertTrue(self.message.state.is_PROCESSED)
        self.assertEqual(len(mail.outbox), 0)
开发者ID:Alkalit,项目名称:the-tale,代码行数:8,代码来源:test_new_forum_thread.py

示例12: request_dialog

    def request_dialog(self, friend):

        if friend.id == get_system_user().id:
            return self.auto_error(
                "friends.request_dialog.system_user", "Вы не можете пригласить в друзья системного пользователя"
            )

        return self.template("friends/request_dialog.html", {"friend": friend, "form": RequestForm()})
开发者ID:Tiendil,项目名称:the-tale,代码行数:8,代码来源:views.py

示例13: remove_friendship

    def remove_friendship(cls, initiator, friend):
        request = cls.get_for_bidirectional(initiator, friend)

        if request is None: return

        if request.is_confirmed:
            MessagePrototype.create(get_system_user(),
                                    friend,
                                    u'игрок %(account_link)s удалил вас из списка друзей' %
                                    {'account_link': u'[url="%s"]%s[/url]' % (full_url('http', 'accounts:show', initiator.id), initiator.nick_verbose)})
        else:
            MessagePrototype.create(get_system_user(),
                                    friend,
                                    u'игрок %(account_link)s отказался добавить вас в список друзей' %
                                    {'account_link': u'[url="%s"]%s[/url]' % (full_url('http', 'accounts:show', initiator.id), initiator.nick_verbose)})

        request.remove()

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

示例14: increment_level

    def increment_level(self, send_message=False):
        self.level += 1

        self.add_message('hero_common_journal_level_up', hero=self, level=self.level)

        self.force_save_required = True

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

示例15: check_recipients

def check_recipients(recipients_form):
    system_user = accounts_logic.get_system_user()

    if system_user.id in recipients_form.c.recipients:
        raise dext_views.ViewError(code='system_user', message=u'Нельзя отправить сообщение системному пользователю')

    if accounts_models.Account.objects.filter(is_fast=True, id__in=recipients_form.c.recipients).exists():
        raise dext_views.ViewError(code='fast_account', message=u'Нельзя отправить сообщение пользователю, не завершившему регистрацию')

    if accounts_models.Account.objects.filter(id__in=recipients_form.c.recipients).count() != len(recipients_form.c.recipients):
        raise dext_views.ViewError(code='unexisted_account', message=u'Вы пытаетесь отправить сообщение несуществующему пользователю')
开发者ID:Jazzis18,项目名称:the-tale,代码行数:11,代码来源:views.py


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