Beispiel #1
0
    def process_no_cmd(self):
        if self._next_templates_update_at is not None and datetime.datetime.now() > self._next_templates_update_at:
            self.logger.info('update templates errors status')
            logic.update_templates_errors()
            self._next_templates_update_at = None

        if self._next_words_update_at is not None and datetime.datetime.now() > self._next_words_update_at:
            self.logger.info('update words_usage_info')
            logic.update_words_usage_info()
            self._next_words_update_at = None
Beispiel #2
0
    def process_no_cmd(self):
        if self._next_templates_update_at is not None and datetime.datetime.now(
        ) > self._next_templates_update_at:
            self.logger.info('update templates errors status')
            logic.update_templates_errors()
            self._next_templates_update_at = None

        if self._next_words_update_at is not None and datetime.datetime.now(
        ) > self._next_words_update_at:
            self.logger.info('update words_usage_info')
            logic.update_words_usage_info()
            self._next_words_update_at = None
Beispiel #3
0
    def update_templates_errors(self):
        key = keys.LEXICON_KEY.HERO_COMMON_JOURNAL_LEVEL_UP

        TEXT = u'[hero|загл] [level] [неизвестное слово|hero|вн]'

        template = utg_templates.Template()

        template.parse(TEXT, externals=['hero'])

        verificator_1 = prototypes.Verificator(text=u'Героиня 1 w-1-ед,вн,жр,од,пол', externals={'hero': (u'героиня', u''), 'level': (1, u'')})
        verificator_2 = prototypes.Verificator(text=u'Рыцари 5 w-1-мн,вн,од,пол', externals={'hero': (u'рыцарь', u'мн'), 'level': (5, u'')})
        verificator_3 = prototypes.Verificator(text=u'Герой 2 w-1-ед,вн,мр,од,пол', externals={'hero': (u'герой', u''), 'level': (2, u'')})
        verificator_4 = prototypes.Verificator(text=u'Привидение 5 w-1-ед,вн,ср,од,пол', externals={'hero': (u'привидение', u''), 'level': (5, u'')})

        dictionary = storage.game_dictionary.item

        word = utg_words.Word.create_test_word(type=utg_relations.WORD_TYPE.ADJECTIVE, prefix=u'w-1-', only_required=True)
        word.forms[0] = u'неизвестное слово'

        dictionary.add_word(word)

        prototype_1 = prototypes.TemplatePrototype.create(key=key,
                                                        raw_template=TEXT,
                                                        utg_template=template,
                                                        verificators=[verificator_1, verificator_2, verificator_3, verificator_4],
                                                        author=self.account_1)

        prototype_2 = prototypes.TemplatePrototype.create(key=key,
                                                        raw_template=TEXT,
                                                        utg_template=template,
                                                        verificators=[],
                                                        author=self.account_1)

        prototypes.TemplatePrototype._db_filter(id=prototype_1.id).update(errors_status=relations.TEMPLATE_ERRORS_STATUS.HAS_ERRORS)
        prototypes.TemplatePrototype._db_filter(id=prototype_2.id).update(errors_status=relations.TEMPLATE_ERRORS_STATUS.NO_ERRORS)

        prototype_1.reload()
        prototype_2.reload()

        self.assertTrue(prototype_1.errors_status.is_HAS_ERRORS)
        self.assertTrue(prototype_2.errors_status.is_NO_ERRORS)

        logic.update_templates_errors()

        prototype_1.reload()
        prototype_2.reload()

        self.assertTrue(prototype_1.errors_status.is_NO_ERRORS)
        self.assertTrue(prototype_2.errors_status.is_HAS_ERRORS)
Beispiel #4
0
    def handle(self, *args, **options):

        print
        print 'UPDATE MAP'
        print

        run_django_command(['map_update_map'])

        print
        print 'UPDATE LINGUISTICS'

        linguistics_logic.sync_static_restrictions()
        linguistics_logic.update_templates_errors()
        linguistics_logic.update_words_usage_info()

        print
        print 'SYNC MARKET'
        run_django_command(['market_sync_goods'])

        print
        print 'SYNC SOCIAL CONNECTIONS'

        persons_logic.sync_social_connections()

        print
        print 'SYNC ACTUAL BILLS'

        bills_logic.update_actual_bills_for_all_accounts()

        print
        print 'REMOVE OLD SDN INFO'

        if portal_settings.SETTINGS_CDN_INFO_KEY in settings:
            del settings[portal_settings.SETTINGS_CDN_INFO_KEY]

        if portal_settings.SETTINGS_PREV_CDN_SYNC_TIME_KEY in settings:
            del settings[portal_settings.SETTINGS_PREV_CDN_SYNC_TIME_KEY]

        print
        print 'SYNC GROUPS AND PERMISSIONS'
        print

        sync_group('content group', ['cms.add_page', 'cms.change_page', 'cms.delete_page',
                                    'news.add_news', 'news.change_news', 'news.delete_news'])

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

        sync_group('bills moderators group', ['bills.moderate_bill'])

        sync_group('developers group', ['mobs.moderate_mobrecord',
                                        'artifacts.moderate_artifactrecord',
                                        'linguistics.moderate_word',
                                        'linguistics.moderate_template',
                                        'linguistics.edit_template'])

        sync_group('folclor moderation group', ['blogs.moderate_post'])

        sync_group('mobs & artifacts create group', ['mobs.create_mobrecord', 'artifacts.create_artifactrecord'])

        sync_group('accounts moderators group', ['accounts.moderate_account'])

        sync_group('collections editors group', ['collections.edit_collection',
                                                 'collections.edit_kit',
                                                 'collections.edit_item'])
        sync_group('collections moderators group', ['collections.moderate_collection',
                                                    'collections.moderate_kit',
                                                    'collections.moderate_item'])

        sync_group('achievements editors group', ['achievements.edit_achievement'])


        sync_group(linguistics_settings.MODERATOR_GROUP_NAME, ['linguistics.moderate_word',
                                                               'linguistics.moderate_template',
                                                               'linguistics.edit_template'])
        sync_group(linguistics_settings.EDITOR_GROUP_NAME, ['linguistics.moderate_word',
                                                            'linguistics.edit_template'])
Beispiel #5
0
    def handle(self, *args, **options):

        print()
        print('UPDATE MAP')
        print()

        run_django_command(['map_update_map'])

        print()
        print('UPDATE LINGUISTICS')

        linguistics_logic.sync_static_restrictions()
        linguistics_logic.update_templates_errors()
        linguistics_logic.update_words_usage_info()

        print()
        print('SYNC ACTUAL BILLS')

        bills_logic.update_actual_bills_for_all_accounts()

        print()
        print('REFRESH ATTRIBUTES')

        places_logic.refresh_all_places_attributes()
        persons_logic.refresh_all_persons_attributes()

        print()
        print('REMOVE OLD CDN INFO')

        if portal_settings.SETTINGS_CDN_INFO_KEY in settings:
            del settings[portal_settings.SETTINGS_CDN_INFO_KEY]

        if portal_settings.SETTINGS_PREV_CDN_SYNC_TIME_KEY in settings:
            del settings[portal_settings.SETTINGS_PREV_CDN_SYNC_TIME_KEY]

        print()
        print('SYNC GROUPS AND PERMISSIONS')
        print()

        sync_group('content group',
                   ['news.add_news', 'news.change_news', 'news.delete_news'])

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

        sync_group('bills moderators group', ['bills.moderate_bill'])

        sync_group('developers group', [
            'mobs.moderate_mobrecord', 'artifacts.moderate_artifactrecord',
            'linguistics.moderate_word', 'linguistics.moderate_template',
            'linguistics.edit_template'
        ])

        sync_group('folclor moderation group', ['blogs.moderate_post'])

        sync_group(
            'mobs & artifacts create group',
            ['mobs.create_mobrecord', 'artifacts.create_artifactrecord'])

        sync_group('accounts moderators group', ['accounts.moderate_account'])

        sync_group('clans moderators group', ['clans.moderate_clan'])

        sync_group('collections editors group', [
            'collections.edit_collection', 'collections.edit_kit',
            'collections.edit_item'
        ])
        sync_group('collections moderators group', [
            'collections.moderate_collection', 'collections.moderate_kit',
            'collections.moderate_item'
        ])

        sync_group('achievements editors group',
                   ['achievements.edit_achievement'])

        sync_group(linguistics_settings.MODERATOR_GROUP_NAME, [
            'linguistics.moderate_word', 'linguistics.moderate_template',
            'linguistics.edit_template'
        ])
        sync_group(linguistics_settings.EDITOR_GROUP_NAME,
                   ['linguistics.moderate_word', 'linguistics.edit_template'])