Ejemplo n.º 1
0
from the_tale.common.utils.decorators import login_required
from the_tale.common.utils.enum import create_enum

from the_tale.accounts.prototypes import AccountPrototype
from the_tale.accounts.views import validate_ban_forum

from . import prototypes
from . import models
from . import conf
from . import forms
from . import relations
from . import meta_relations

ORDER_BY = create_enum('ORDER_BY', (
    ('ALPHABET', 'alphabet', u'по алфавиту'),
    ('CREATED_AT', 'created_at', u'по дате создания'),
    ('RATING', 'rating', u'по рейтингу'),
))


class PostResource(Resource):
    @validate_argument('post', prototypes.PostPrototype.get_by_id,
                       'blogs.posts', u'Запись не найдена')
    def initialize(self, post=None, *args, **kwargs):
        super(PostResource, self).initialize(*args, **kwargs)
        self.post = post
        self.can_moderate_post = self.account.has_perm('blogs.moderate_post')

    @validator(
        code='blogs.posts.fast_account',
        message=u'Для выполнения этого действия необходимо завершить регистрацию'
Ejemplo n.º 2
0
from the_tale.common.postponed_tasks.prototypes import PostponedLogic, POSTPONED_TASK_LOGIC_RESULT

from the_tale.finances.bank import transaction as bank_transaction
from the_tale.finances.bank import prototypes as bank_prototypes
from the_tale.finances.bank import relations as bank_relations

from the_tale.accounts.personal_messages import prototypes as personal_messages_prototypes

from the_tale.accounts.prototypes import AccountPrototype, ChangeCredentialsTaskPrototype
from the_tale.accounts import logic
from the_tale.accounts import conf
import collections

REGISTRATION_TASK_STATE = create_enum(
    'REGISTRATION_TASK_STATE',
    (('UNPROCESSED', 0, 'ожидает обработки'), ('PROCESSED', 1, 'обработкана'),
     ('UNKNOWN_ERROR', 2, 'неизвестная ошибка')))


class RegistrationTask(PostponedLogic):

    TYPE = 'registration'

    def __init__(self,
                 account_id,
                 referer,
                 referral_of_id,
                 action_id,
                 state=REGISTRATION_TASK_STATE.UNPROCESSED):
        super(RegistrationTask, self).__init__()
        self.account_id = account_id
Ejemplo n.º 3
0
# coding: utf-8

from the_tale.common.postponed_tasks import PostponedLogic, POSTPONED_TASK_LOGIC_RESULT
from the_tale.common.utils.enum import create_enum

from the_tale.game.pvp.prototypes import Battle1x1Prototype
from the_tale.game.pvp.abilities import ABILITIES

SAY_IN_HERO_LOG_TASK_STATE = create_enum('SAY_IN_HERO_LOG_TASK_STATE', ( ('UNPROCESSED', 0, u'в очереди'),
                                                                         ('ACCOUNT_HERO_NOT_FOUND', 1, u'герой не найден'),
                                                                         ('PROCESSED', 2, u'обработана'),
                                                                         ('BATTLE_NOT_FOUND', 3, u'битва не найдена') ) )



class SayInBattleLogTask(PostponedLogic):

    TYPE = 'say-in-hero-log'

    def __init__(self, battle_id, text, state=SAY_IN_HERO_LOG_TASK_STATE.UNPROCESSED):
        super(SayInBattleLogTask, self).__init__()
        self.battle_id = battle_id
        self.text = text
        self.state = state

    def serialize(self):
        return { 'battle_id': self.battle_id,
                 'text': self.text,
                 'state': self.state}

    @property
Ejemplo n.º 4
0
from the_tale.common.postponed_tasks.prototypes import PostponedLogic, POSTPONED_TASK_LOGIC_RESULT

from the_tale.finances.bank import transaction as bank_transaction
from the_tale.finances.bank import prototypes as bank_prototypes
from the_tale.finances.bank import relations as bank_relations

from the_tale.accounts.personal_messages import prototypes as personal_messages_prototypes

from the_tale.accounts.prototypes import AccountPrototype, ChangeCredentialsTaskPrototype
from the_tale.accounts import logic
from the_tale.accounts import conf


REGISTRATION_TASK_STATE = create_enum('REGISTRATION_TASK_STATE', ( ('UNPROCESSED', 0, u'ожидает обработки'),
                                                                   ('PROCESSED', 1, u'обработкана'),
                                                                   ('UNKNOWN_ERROR', 2, u'неизвестная ошибка') ))

class RegistrationTask(PostponedLogic):

    TYPE = 'registration'

    def __init__(self, account_id, referer, referral_of_id, action_id, state=REGISTRATION_TASK_STATE.UNPROCESSED):
        super(RegistrationTask, self).__init__()
        self.account_id = account_id
        self.referer = referer
        self.referral_of_id = referral_of_id
        self.action_id = action_id
        self.state = state

    def serialize(self):
Ejemplo n.º 5
0
from the_tale.game.map.places.storage import places_storage, buildings_storage
from the_tale.game.map.places.prototypes import PlacePrototype
from the_tale.game.map.places.logic import update_nearest_cells

from the_tale.game.map.roads.storage import roads_storage, waymarks_storage
from the_tale.game.map.roads.prototypes import RoadPrototype
from the_tale.game.map.roads.logic import update_waymarks

from the_tale.game.companions import logic as companions_logic
from the_tale.game.companions import relations as companions_relations


DEFAULT_HERO_EQUIPMENT = create_enum('DEFAULT_HERO_EQUIPMENT', ( ('PANTS', 'default_pants', u'штаны'),
                                                                 ('BOOTS', 'default_boots', u'обувь'),
                                                                 ('PLATE', 'default_plate', u'доспех'),
                                                                 ('GLOVES', 'default_gloves', u'перчатки'),
                                                                 ('WEAPON', 'default_weapon', u'оружие') ))


@places_storage.postpone_version_update
@buildings_storage.postpone_version_update
@persons_storage.postpone_version_update
@waymarks_storage.postpone_version_update
@roads_storage.postpone_version_update
@mobs_storage.postpone_version_update
@artifacts_storage.postpone_version_update
def create_test_map():
    linguistics_logic.sync_static_restrictions()

    map_logic.create_test_my_info()
Ejemplo n.º 6
0
from the_tale.common.utils.decorators import login_required
from the_tale.common.utils.enum import create_enum

from the_tale.accounts.prototypes import AccountPrototype
from the_tale.accounts.views import validate_ban_forum

from . import prototypes
from . import models
from . import conf
from . import forms
from . import relations
from . import meta_relations


ORDER_BY = create_enum('ORDER_BY', (('ALPHABET', 'alphabet', u'по алфавиту'),
                                    ('CREATED_AT', 'created_at', u'по дате создания'),
                                    ('RATING', 'rating', u'по рейтингу'),))

class PostResource(Resource):

    @validate_argument('post', prototypes.PostPrototype.get_by_id, 'blogs.posts', u'Запись не найдена')
    def initialize(self, post=None, *args, **kwargs):
        super(PostResource, self).initialize(*args, **kwargs)
        self.post = post
        self.can_moderate_post = self.account.has_perm('blogs.moderate_post')

    @validator(code='blogs.posts.fast_account', message=u'Для выполнения этого действия необходимо завершить регистрацию')
    def validate_fast_account_restrictions(self, *args, **kwargs):
        return self.account.is_authenticated() and not self.account.is_fast

    @validator(code='blogs.posts.no_edit_rights', message=u'Вы не можете редактировать это произведение')
Ejemplo n.º 7
0
# coding: utf-8

from django.db import models

from the_tale.common.utils.enum import create_enum

POSTPONED_TASK_STATE = create_enum(
    'POSTPONED_TASK_STATE',
    (('WAITING', 0, 'ожидает обработки'), ('PROCESSED', 1, 'обработана'),
     ('RESETED', 2, 'сброшена'), ('ERROR', 3, 'ошибка при обработке'),
     ('EXCEPTION', 4, 'исключение при обработке'),
     ('TIMEOUT', 5, 'превышено время выполнения')))

POSTPONED_TASK_LOGIC_RESULT = create_enum(
    'POSTPONED_TASK_LOGIC_RESULT',
    (('SUCCESS', 0, 'удачное выполнение'), ('ERROR', 1, 'ошибка'),
     ('CONTINUE', 2, 'необходимо продолжить выполнение'),
     ('WAIT', 3, 'ожидает других задач')))


class PostponedTask(models.Model):

    created_at = models.DateTimeField(auto_now_add=True)

    updated_at = models.DateTimeField(auto_now=True)

    live_time = models.BigIntegerField(null=True, default=None)

    state = models.IntegerField(default=POSTPONED_TASK_STATE.WAITING,
                                db_index=True,
                                choices=POSTPONED_TASK_STATE._CHOICES)
Ejemplo n.º 8
0
# coding: utf-8

from django.db import models

from the_tale.common.utils.enum import create_enum

POSTPONED_TASK_STATE = create_enum('POSTPONED_TASK_STATE', (('WAITING', 0, 'ожидает обработки'),
                                                            ('PROCESSED', 1, 'обработана'),
                                                            ('RESETED', 2, 'сброшена'),
                                                            ('ERROR', 3, 'ошибка при обработке'),
                                                            ('EXCEPTION', 4, 'исключение при обработке'),
                                                            ('TIMEOUT', 5, 'превышено время выполнения')) )

POSTPONED_TASK_LOGIC_RESULT = create_enum('POSTPONED_TASK_LOGIC_RESULT', (('SUCCESS', 0, 'удачное выполнение'),
                                                                          ('ERROR', 1, 'ошибка'),
                                                                          ('CONTINUE', 2, 'необходимо продолжить выполнение'),
                                                                          ('WAIT', 3, 'ожидает других задач') ) )


class PostponedTask(models.Model):

    created_at = models.DateTimeField(auto_now_add=True)

    updated_at = models.DateTimeField(auto_now=True)

    live_time = models.BigIntegerField(null=True, default=None)

    state = models.IntegerField(default=POSTPONED_TASK_STATE.WAITING, db_index=True, choices=POSTPONED_TASK_STATE._CHOICES)

    comment = models.TextField(blank=True, default='')
Ejemplo n.º 9
0
from the_tale.accounts.prototypes import AccountPrototype
from the_tale.accounts.views import validate_ban_forum

from . import prototypes
from . import models
from . import conf
from . import forms
from . import relations
from . import meta_relations


ORDER_BY = create_enum(
    "ORDER_BY",
    (
        ("ALPHABET", "alphabet", "по алфавиту"),
        ("CREATED_AT", "created_at", "по дате создания"),
        ("RATING", "rating", "по голосам"),
        ("MIGHT", "might", "по рейтингу"),
    ),
)


class PostResource(Resource):
    @validate_argument("post", prototypes.PostPrototype.get_by_id, "blogs.posts", "Запись не найдена")
    def initialize(self, post=None, *args, **kwargs):
        super(PostResource, self).initialize(*args, **kwargs)
        self.post = post
        self.can_moderate_post = self.account.has_perm("blogs.moderate_post")

    @validator(
        code="blogs.posts.fast_account", message="Для выполнения этого действия необходимо завершить регистрацию"
Ejemplo n.º 10
0
# coding: utf-8

from the_tale.common.utils.enum import create_enum


ANGEL_ENERGY_REGENERATION_TYPES = create_enum('ANGEL_ENERGY_REGENERATION_TYPES',
                                              ( ('PRAY', 0, u'молитва'),
                                                ('SACRIFICE', 1, u'жертвоприношение'),
                                                ('INCENSE', 2, u'благовония'),
                                                ('SYMBOLS', 3, u'символы'),
                                                ('MEDITATION', 4, u'медитация') ))
Ejemplo n.º 11
0
from the_tale.game.map import logic as map_logic

from the_tale.game.map.places.storage import places_storage, buildings_storage
from the_tale.game.map.places.prototypes import PlacePrototype
from the_tale.game.map.places.logic import update_nearest_cells

from the_tale.game.map.roads.storage import roads_storage, waymarks_storage
from the_tale.game.map.roads.prototypes import RoadPrototype
from the_tale.game.map.roads.logic import update_waymarks

from the_tale.game.companions import logic as companions_logic
from the_tale.game.companions import relations as companions_relations

DEFAULT_HERO_EQUIPMENT = create_enum(
    'DEFAULT_HERO_EQUIPMENT', (('PANTS', 'default_pants', u'штаны'),
                               ('BOOTS', 'default_boots', u'обувь'),
                               ('PLATE', 'default_plate', u'доспех'),
                               ('GLOVES', 'default_gloves', u'перчатки'),
                               ('WEAPON', 'default_weapon', u'оружие')))


@places_storage.postpone_version_update
@buildings_storage.postpone_version_update
@persons_storage.postpone_version_update
@waymarks_storage.postpone_version_update
@roads_storage.postpone_version_update
@mobs_storage.postpone_version_update
@artifacts_storage.postpone_version_update
def create_test_map():
    linguistics_logic.sync_static_restrictions()

    map_logic.create_test_my_info()