Exemple #1
0
class WordsIndexFilter(list_filter.ListFilter):
    ELEMENTS = [
        list_filter.reset_element(),
        list_filter.static_element('автор:', attribute='contributor'),
        list_filter.filter_element('поиск:',
                                   attribute='filter',
                                   default_value=None),
        list_filter.choice_element(
            'часть речи:',
            attribute='type',
            choices=[(None, 'все')] +
            list(relations.ALLOWED_WORD_TYPE.select('value', 'text'))),
        list_filter.choice_element(
            'состояние:',
            attribute='state',
            choices=[(None, 'все')] +
            list(relations.WORD_STATE.select('value', 'text'))),
        list_filter.choice_element(
            'сортировать:',
            attribute='order_by',
            choices=relations.INDEX_ORDER_BY.select('value', 'text'),
            default_value=relations.INDEX_ORDER_BY.UPDATED_AT.value),
        list_filter.static_element('количество:',
                                   attribute='count',
                                   default_value=0)
    ]
Exemple #2
0
class TemplatesIndexFilter(list_filter.ListFilter):
    ELEMENTS = [
        list_filter.reset_element(),
        list_filter.static_element('автор:', attribute='contributor'),
        list_filter.filter_element('поиск:',
                                   attribute='filter',
                                   default_value=None),
        list_filter.choice_element(
            'состояние:',
            attribute='state',
            choices=[(None, 'все')] +
            list(relations.TEMPLATE_STATE.select('value', 'text'))),
        list_filter.choice_element(
            'наличие ошибок:',
            attribute='errors_status',
            choices=[(None, 'все')] +
            list(relations.TEMPLATE_ERRORS_STATUS.select('value', 'text'))),
        list_filter.choice_element(
            'ограничение:',
            attribute='restriction',
            choices=storage.restrictions_storage.get_form_choices),
        list_filter.choice_element(
            'сортировать:',
            attribute='order_by',
            choices=relations.INDEX_ORDER_BY.select('value', 'text'),
            default_value=relations.INDEX_ORDER_BY.UPDATED_AT.value),
        list_filter.static_element('количество:',
                                   attribute='count',
                                   default_value=0)
    ]
Exemple #3
0
class IndexFilter(list_filter.ListFilter):
    ELEMENTS = [
        list_filter.reset_element(),
        list_filter.choice_element('город:',
                                   attribute='place',
                                   choices=lambda x: [(None, 'все')] +
                                   places_storage.places.get_choices()),
        list_filter.choice_element('мастер:',
                                   attribute='person',
                                   choices=lambda x: [(None, 'все')] +
                                   persons_objects.Person.form_choices())
    ]
Exemple #4
0
class IndexFilter(list_filter.ListFilter):
    ELEMENTS = [
        list_filter.reset_element(),
        list_filter.choice_element(u'город:',
                                   attribute='place',
                                   choices=lambda x: [(None, u'все')] +
                                   places_storage.places.get_choices())
    ]
Exemple #5
0
class IndexFilter(list_filter.ListFilter):
    ELEMENTS = [
        list_filter.reset_element(),
        list_filter.choice_element(u'сортировать по:',
                                   attribute='order_by',
                                   choices=ORDER_BY.select('value', 'text'),
                                   default_value=ORDER_BY.NAME.value)
    ]
Exemple #6
0
class LotsIndexFilter(list_filter.ListFilter):
    ELEMENTS = [
        list_filter.reset_element(),
        list_filter.filter_element(u'поиск:',
                                   attribute='filter',
                                   default_value=None),
        list_filter.choice_element(
            u'сортировать:',
            attribute='order_by',
            choices=relations.INDEX_ORDER_BY.select('value', 'text'),
            default_value=relations.INDEX_ORDER_BY.DATE_DOWN.value),
        list_filter.choice_element(u'группа:',
                                   attribute='group',
                                   choices=filter_groups_choices,
                                   default_value=None),
        list_filter.static_element(u'количество:',
                                   attribute='count',
                                   default_value=0)
    ]
Exemple #7
0
 class Filter(list_filter.ListFilter):
     ELEMENTS = [
         list_filter.reset_element(),
         list_filter.filter_element(u'поиск:',
                                    attribute='filter',
                                    default_value=None),
         list_filter.choice_element(u'отправитель:',
                                    attribute='sender',
                                    choices=[(None, u'все')] +
                                    [(account.id, account.nick)
                                     for account in senders]),
         list_filter.static_element(u'количество:',
                                    attribute='count',
                                    default_value=0)
     ]
Exemple #8
0
guide_resource.add_processor(accounts_views.CurrentAccountProcessor())
guide_resource.add_processor(utils_views.FakeResourceProcessor())

########################################
# filters
########################################


class INDEX_ORDER(DjangoEnum):
    records = (("RARITY", 0, "по редкости"), ("NAME", 1, "по имени"))


CARDS_FILTER = [
    list_filter.reset_element(),
    list_filter.choice_element(
        "редкость:", attribute="rarity", choices=[(None, "все")] + list(relations.RARITY.select("value", "text"))
    ),
    list_filter.choice_element(
        "доступность:",
        attribute="availability",
        choices=[(None, "все")] + list(relations.AVAILABILITY.select("value", "text")),
    ),
    list_filter.choice_element(
        "сортировка:",
        attribute="order_by",
        choices=list(INDEX_ORDER.select("value", "text")),
        default_value=INDEX_ORDER.RARITY.value,
    ),
]

Exemple #9
0
guide_resource.add_processor(accounts_views.CurrentAccountProcessor())
guide_resource.add_processor(utils_views.FakeResourceProcessor())

########################################
# filters
########################################


class INDEX_ORDER(DjangoEnum):
    records = (('RARITY', 0, u'по редкости'), ('NAME', 1, u'по имени'))


CARDS_FILTER = [
    list_filter.reset_element(),
    list_filter.choice_element(u'редкость:',
                               attribute='rarity',
                               choices=[(None, u'все')] +
                               list(relations.RARITY.select('value', 'text'))),
    list_filter.choice_element(
        u'доступность:',
        attribute='availability',
        choices=[(None, u'все')] +
        list(relations.AVAILABILITY.select('value', 'text'))),
    list_filter.choice_element(u'сортировка:',
                               attribute='order_by',
                               choices=list(INDEX_ORDER.select(
                                   'value', 'text')),
                               default_value=INDEX_ORDER.RARITY.value)
]


class CardsFilter(list_filter.ListFilter):
Exemple #10
0
from the_tale.game.map.relations import TERRAIN

from . import relations
from . import effects
from . import meta_relations
from . import logic
from . import storage
from .forms import ArtifactRecordForm, ModerateArtifactRecordForm


EFFECTS_CHOICES = sorted(relations.ARTIFACT_EFFECT.select('value', 'text'),
                         key=lambda v: v[1])

BASE_INDEX_FILTERS = [list_filter.reset_element(),
                      list_filter.choice_element('экипировка:', attribute='type', choices=[(None, 'все')] + list(relations.ARTIFACT_TYPE.select('value', 'text'))),
                      list_filter.choice_element('сила:', attribute='power_type', choices=[(None, 'все')] + list(relations.ARTIFACT_POWER_TYPE.select('value', 'text'))),
                      list_filter.choice_element('эффекты:', attribute='effect', choices=[(None, 'все')] + EFFECTS_CHOICES),
                      list_filter.choice_element('сортировка:',
                                                 attribute='order_by',
                                                 choices=[(None, 'все')] + list(relations.INDEX_ORDER_TYPE.select('value', 'text')),
                                                 default_value=relations.INDEX_ORDER_TYPE.BY_NAME.value) ]

MODERATOR_INDEX_FILTERS = list(BASE_INDEX_FILTERS)
MODERATOR_INDEX_FILTERS.append(list_filter.choice_element('состояние:',
                                                          attribute='state',
                                                          choices=list(relations.ARTIFACT_RECORD_STATE.select('value', 'text')),
                                                          default_value=relations.ARTIFACT_RECORD_STATE.ENABLED.value))


class BaseIndexFilter(list_filter.ListFilter):
Exemple #11
0
from the_tale.game.map.relations import TERRAIN

from . import relations
from . import effects
from . import meta_relations
from .prototypes import ArtifactRecordPrototype
from .storage import artifacts_storage
from .forms import ArtifactRecordForm, ModerateArtifactRecordForm


EFFECTS_CHOICES = sorted(relations.ARTIFACT_EFFECT.select('value', 'text'),
                         key=lambda v: v[1])

BASE_INDEX_FILTERS = [list_filter.reset_element(),
                      list_filter.choice_element('экипировка:', attribute='type', choices=[(None, 'все')] + list(relations.ARTIFACT_TYPE.select('value', 'text'))),
                      list_filter.choice_element('сила:', attribute='power_type', choices=[(None, 'все')] + list(relations.ARTIFACT_POWER_TYPE.select('value', 'text'))),
                      list_filter.choice_element('эффекты:', attribute='effect', choices=[(None, 'все')] + EFFECTS_CHOICES),
                      list_filter.choice_element('сортировка:',
                                                 attribute='order_by',
                                                 choices=[(None, 'все')] + list(relations.INDEX_ORDER_TYPE.select('value', 'text')),
                                                 default_value=relations.INDEX_ORDER_TYPE.BY_NAME.value) ]

MODERATOR_INDEX_FILTERS = list(BASE_INDEX_FILTERS)
MODERATOR_INDEX_FILTERS.append(list_filter.choice_element('состояние:',
                                                          attribute='state',
                                                          choices=list(relations.ARTIFACT_RECORD_STATE.select('value', 'text')),
                                                          default_value=relations.ARTIFACT_RECORD_STATE.ENABLED.value))

class BaseIndexFilter(list_filter.ListFilter):
    ELEMENTS = BASE_INDEX_FILTERS
Exemple #12
0
from the_tale.game.heroes.prototypes import HeroPrototype

from the_tale.game.map.places.storage import places_storage

from .prototypes import BillPrototype, VotePrototype
from .conf import bills_settings
from .models import Bill, Vote
from .bills import BILLS_BY_ID
from .relations import VOTED_TYPE, VOTE_TYPE, BILL_STATE, BILL_TYPE
from . import meta_relations


BASE_INDEX_FILTERS = [list_filter.reset_element(),
                      list_filter.static_element(u'автор:', attribute='owner'),
                      list_filter.choice_element(u'состояние:', attribute='state', choices=[(None, u'все'),
                                                                                            (BILL_STATE.VOTING.value, u'голосование'),
                                                                                            (BILL_STATE.ACCEPTED.value, u'принятые'),
                                                                                            (BILL_STATE.REJECTED.value, u'отклонённые') ]),
                      list_filter.choice_element(u'тип:', attribute='bill_type', choices=[(None, u'все')] + list(BILL_TYPE.select('value', 'text'))),
                      list_filter.choice_element(u'город:', attribute='place', choices=lambda x: [(None, u'все')] + places_storage.get_choices()) ]

LOGINED_INDEX_FILTERS = BASE_INDEX_FILTERS + [list_filter.choice_element(u'голосование:', attribute='voted', choices=[(None, u'все')] + list(VOTED_TYPE.select('value', 'text'))),]

class UnloginedIndexFilter(list_filter.ListFilter):
    ELEMENTS = BASE_INDEX_FILTERS

class LoginedIndexFilter(list_filter.ListFilter):
    ELEMENTS = LOGINED_INDEX_FILTERS


def argument_to_bill_type(value): return BILL_TYPE(int(value))
def argument_to_bill_state(value): return BILL_STATE(int(value))
Exemple #13
0
########################################

INDEX_TYPE = list_filter.filter_relation(beings_relations.TYPE)
INDEX_DEDICATION = list_filter.filter_relation(relations.DEDICATION)
INDEX_ABILITIES = list_filter.filter_relation(abilities_effects.ABILITIES,
                                              sort_key=lambda r: r.text)


class INDEX_ORDER(DjangoEnum):
    records = (('RARITY', 0, 'по редкости'), ('NAME', 1, 'по имени'))


BASE_INDEX_FILTERS = [
    list_filter.reset_element(),
    list_filter.choice_element('тип:',
                               attribute='type',
                               default_value=INDEX_TYPE.FILTER_ALL.value,
                               choices=INDEX_TYPE.filter_choices()),
    list_filter.choice_element('самоотверженность:',
                               attribute='dedication',
                               default_value=INDEX_DEDICATION.FILTER_ALL.value,
                               choices=INDEX_DEDICATION.filter_choices()),
    list_filter.choice_element('особенность:',
                               attribute='ability',
                               default_value=INDEX_ABILITIES.FILTER_ALL.value,
                               choices=INDEX_ABILITIES.filter_choices()),
    list_filter.choice_element('сортировка:',
                               attribute='order_by',
                               choices=list(INDEX_ORDER.select(
                                   'value', 'text')),
                               default_value=INDEX_ORDER.RARITY.value)
]
Exemple #14
0
from the_tale.game.heroes import logic as heroes_logic

from .prototypes import BillPrototype, VotePrototype
from .conf import bills_settings
from .models import Bill, Vote
from .bills import BILLS_BY_ID
from .relations import VOTED_TYPE, VOTE_TYPE, BILL_STATE, BILL_TYPE
from . import meta_relations

BASE_INDEX_FILTERS = [
    list_filter.reset_element(),
    list_filter.static_element('автор:', attribute='owner'),
    list_filter.choice_element('состояние:',
                               attribute='state',
                               choices=[
                                   (None, 'все'),
                                   (BILL_STATE.VOTING.value, 'голосование'),
                                   (BILL_STATE.ACCEPTED.value, 'принятые'),
                                   (BILL_STATE.REJECTED.value, 'отклонённые')
                               ]),
    list_filter.choice_element('тип:',
                               attribute='bill_type',
                               choices=[(None, 'все')] + sorted(
                                   (BILL_TYPE.select('value', 'text')),
                                   key=lambda element: element[1])),
    list_filter.choice_element('город:',
                               attribute='place',
                               choices=lambda x: [(None, 'все')] +
                               places_storage.places.get_choices())
]

LOGINED_INDEX_FILTERS = BASE_INDEX_FILTERS + [
Exemple #15
0
from . import conf
from . import logic


class POWER_TYPE_FILTER(DjangoEnum):
    records = (('ALL', 0, 'всё'), ('PERSONAL', 1, 'ближний круг'),
               ('CROWD', 2, 'народное'))


HISTORY_FILTERS = [
    list_filter.reset_element(),
    list_filter.static_element('игрок:', attribute='account'),
    list_filter.choice_element('тип влияния:',
                               attribute='power_type',
                               choices=POWER_TYPE_FILTER.select(
                                   'value', 'text'),
                               default_value=POWER_TYPE_FILTER.ALL.value),
    list_filter.choice_element('город:',
                               attribute='place',
                               choices=lambda x: [(None, 'все')] +
                               places_storage.places.get_choices()),
    list_filter.choice_element('мастер:',
                               attribute='person',
                               choices=lambda x: [(None, 'все')] +
                               persons_objects.Person.form_choices())
]


class HistoryFilter(list_filter.ListFilter):
    ELEMENTS = HISTORY_FILTERS
Exemple #16
0
from the_tale.game.map.relations import TERRAIN

from the_tale.game import relations as game_relations

from .relations import MOB_RECORD_STATE, INDEX_ORDER_TYPE
from .prototypes import MobRecordPrototype
from .storage import mobs_storage
from .forms import MobRecordForm, ModerateMobRecordForm
from . import meta_relations

BASE_INDEX_FILTERS = [
    list_filter.reset_element(),
    list_filter.choice_element(
        'тип:',
        attribute='type',
        choices=[(None, 'все')] +
        sorted(list(game_relations.BEING_TYPE.select('value', 'text')),
               key=lambda x: x[1])),
    list_filter.choice_element(
        'архетип:',
        attribute='archetype',
        choices=[(None, 'все')] +
        sorted(list(game_relations.ARCHETYPE.select('value', 'text')),
               key=lambda x: x[1])),
    list_filter.choice_element(
        'территория:',
        attribute='terrain',
        choices=[(None, 'все')] +
        sorted(list(TERRAIN.select('value', 'text')), key=lambda x: x[1])),
    list_filter.choice_element('сортировка:',
                               attribute='order_by',
Exemple #17
0
from the_tale.common.utils.decorators import login_required


from the_tale.game.map.relations import TERRAIN

from the_tale.game import relations as game_relations

from .relations import MOB_RECORD_STATE, INDEX_ORDER_TYPE
from .prototypes import MobRecordPrototype
from .storage import mobs_storage
from .forms import MobRecordForm, ModerateMobRecordForm
from . import meta_relations


BASE_INDEX_FILTERS = [list_filter.reset_element(),
                      list_filter.choice_element('тип:', attribute='type', choices=[(None, 'все')] + sorted(list(game_relations.BEING_TYPE.select('value', 'text')), key=lambda x: x[1])),
                      list_filter.choice_element('архетип:', attribute='archetype', choices=[(None, 'все')] + sorted(list(game_relations.ARCHETYPE.select('value', 'text')), key=lambda x: x[1])),
                      list_filter.choice_element('территория:', attribute='terrain', choices=[(None, 'все')] + sorted(list(TERRAIN.select('value', 'text')), key=lambda x: x[1])),
                      list_filter.choice_element('сортировка:',
                                                 attribute='order_by',
                                                 choices=INDEX_ORDER_TYPE.select('value', 'text'),
                                                 default_value=INDEX_ORDER_TYPE.BY_NAME.value) ]

MODERATOR_INDEX_FILTERS = BASE_INDEX_FILTERS + [list_filter.choice_element('состояние:',
                                                                           attribute='state',
                                                                           default_value=MOB_RECORD_STATE.ENABLED.value,
                                                                           choices=MOB_RECORD_STATE.select('value', 'text'))]


class UnloginedIndexFilter(list_filter.ListFilter):
    ELEMENTS = BASE_INDEX_FILTERS
Exemple #18
0
########################################
# filters
########################################

INDEX_TYPE = list_filter.filter_relation(relations.TYPE)
INDEX_DEDICATION = list_filter.filter_relation(relations.DEDICATION)
INDEX_ABILITIES = list_filter.filter_relation(abilities_effects.ABILITIES, sort_key=lambda r: r.text)

class INDEX_ORDER(DjangoEnum):
    records = ( ('RARITY', 0, u'по редкости'),
                ('NAME', 1, u'по имени') )

BASE_INDEX_FILTERS = [list_filter.reset_element(),
                      list_filter.choice_element(u'тип:',
                                                 attribute='type',
                                                 default_value=INDEX_TYPE.FILTER_ALL.value,
                                                 choices=INDEX_TYPE.filter_choices()),
                      list_filter.choice_element(u'самоотверженность:',
                                                 attribute='dedication',
                                                 default_value=INDEX_DEDICATION.FILTER_ALL.value,
                                                 choices=INDEX_DEDICATION.filter_choices()),
                      list_filter.choice_element(u'особенность:',
                                                 attribute='ability',
                                                 default_value=INDEX_ABILITIES.FILTER_ALL.value,
                                                 choices=INDEX_ABILITIES.filter_choices()),
                       list_filter.choice_element(u'сортировка:',
                                                  attribute='order_by',
                                                  choices=list(INDEX_ORDER.select('value', 'text')),
                                                  default_value=INDEX_ORDER.RARITY.value) ]

MODERATOR_INDEX_FILTERS = BASE_INDEX_FILTERS + [list_filter.choice_element(u'состояние:',
Exemple #19
0
 class Filter(list_filter.ListFilter):
     ELEMENTS = [list_filter.reset_element(),
                 list_filter.filter_element('поиск:', attribute='filter', default_value=None),
                 list_filter.choice_element('получатель:', attribute='recipient', choices=[(None, 'все')] + [(account.id, account.nick) for account in recipients] ),
                 list_filter.static_element('количество:', attribute='count', default_value=0) ]
Exemple #20
0
resource.add_processor(heroes_views.CurrentHeroProcessor())

guide_resource = dext_views.Resource(name='cards')
guide_resource.add_processor(accounts_views.CurrentAccountProcessor())
guide_resource.add_processor(utils_views.FakeResourceProcessor())

########################################
# filters
########################################

class INDEX_ORDER(DjangoEnum):
    records = ( ('RARITY', 0, u'по редкости'),
                ('NAME', 1, u'по имени') )

CARDS_FILTER = [list_filter.reset_element(),
                list_filter.choice_element(u'редкость:', attribute='rarity', choices=[(None, u'все')] + list(relations.RARITY.select('value', 'text'))),
                list_filter.choice_element(u'доступность:', attribute='availability', choices=[(None, u'все')] + list(relations.AVAILABILITY.select('value', 'text'))),
                list_filter.choice_element(u'сортировка:',
                                           attribute='order_by',
                                           choices=list(INDEX_ORDER.select('value', 'text')),
                                           default_value=INDEX_ORDER.RARITY.value)]

class CardsFilter(list_filter.ListFilter):
    ELEMENTS = CARDS_FILTER



########################################
# views
########################################
Exemple #21
0
from .prototypes import BillPrototype, VotePrototype
from .conf import bills_settings
from .models import Bill, Vote
from .bills import BILLS_BY_ID
from .relations import VOTED_TYPE, VOTE_TYPE, BILL_STATE, BILL_TYPE
from . import meta_relations


BASE_INDEX_FILTERS = [
    list_filter.reset_element(),
    list_filter.static_element(u"автор:", attribute="owner"),
    list_filter.choice_element(
        u"состояние:",
        attribute="state",
        choices=[
            (None, u"все"),
            (BILL_STATE.VOTING.value, u"голосование"),
            (BILL_STATE.ACCEPTED.value, u"принятые"),
            (BILL_STATE.REJECTED.value, u"отклонённые"),
        ],
    ),
    list_filter.choice_element(
        u"тип:", attribute="bill_type", choices=[(None, u"все")] + list(BILL_TYPE.select("value", "text"))
    ),
    list_filter.choice_element(
        u"город:", attribute="place", choices=lambda x: [(None, u"все")] + places_storage.places.get_choices()
    ),
]

LOGINED_INDEX_FILTERS = BASE_INDEX_FILTERS + [
    list_filter.choice_element(
        u"голосование:", attribute="voted", choices=[(None, u"все")] + list(VOTED_TYPE.select("value", "text"))