Ejemplo n.º 1
0
 def __init__(self, *args, **kwargs):
     super(UserForm, self).__init__(*args, **kwargs)
     self.fields['place'].choices = places_storage.get_choices()
Ejemplo n.º 2
0
 def __init__(self, *args, **kwargs):
     super(UserForm, self).__init__(*args, **kwargs)
     self.fields['place_1'].choices = places_storage.get_choices()
     self.fields['place_2'].choices = places_storage.get_choices()
Ejemplo n.º 3
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.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))


class BillResource(Resource):
Ejemplo n.º 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.get_choices()) ]
Ejemplo n.º 5
0
 def __init__(self, *args, **kwargs):
     super(UserForm, self).__init__(*args, **kwargs)
     self.fields['place'].choices = places_storage.get_choices()
     self.fields['new_modifier'].choices = sorted(CITY_MODIFIERS.choices(),
                                                  key=lambda m: m[1])
Ejemplo n.º 6
0
    def choose_preferences_dialog(self, type): # pylint: disable=W0622

        mobs = None
        places = None
        friends = None
        enemies = None
        equipment_slots = None
        favorite_items = None

        all_places = places_storage.all()
        all_places.sort(key=lambda x: x.name)

        if type.is_ENERGY_REGENERATION_TYPE:
            pass

        if type.is_MOB:
            all_mobs = mobs_storage.get_available_mobs_list(level=self.hero.level)
            all_mobs = sorted(all_mobs, key=lambda x: x.name)
            mobs = split_list(all_mobs)

        elif type.is_PLACE:
            places = split_list(all_places)

        elif type.is_FRIEND:
            friends = sorted([person for person in persons_storage.filter(state=PERSON_STATE.IN_GAME)],
                             key=lambda person: person.name)

        elif type.is_ENEMY:
            enemies = sorted([person for person in persons_storage.filter(state=PERSON_STATE.IN_GAME)],
                             key=lambda person: person.name)

        elif type.is_EQUIPMENT_SLOT:
            equipment_slots = split_list(list(relations.EQUIPMENT_SLOT.records))

        elif type.is_RISK_LEVEL:
            pass

        elif type.is_ARCHETYPE:
            pass

        elif type.is_COMPANION_DEDICATION:
            pass

        elif type.is_COMPANION_EMPATHY:
            pass

        elif type.is_FAVORITE_ITEM:
            favorite_items = {slot: self.hero.equipment.get(slot)
                              for slot in relations.EQUIPMENT_SLOT.records
                              if self.hero.equipment.get(slot) is not None}

        return self.template('heroes/choose_preferences.html',
                             {'type': type,
                              'mobs': mobs,
                              'places': places,
                              'all_places': places_storage.get_choices(),
                              'places_powers': {place.id: place.total_persons_power for place in all_places},
                              'friends': friends,
                              'enemies': enemies,
                              'equipment_slots': equipment_slots,
                              'favorite_items': favorite_items,
                              'PREFERENCES_CHANGE_DELAY': datetime.timedelta(seconds=c.PREFERENCES_CHANGE_DELAY),
                              'EQUIPMENT_SLOT': relations.EQUIPMENT_SLOT,
                              'RISK_LEVEL': relations.RISK_LEVEL,
                              'COMPANION_DEDICATION': relations.COMPANION_DEDICATION,
                              'COMPANION_EMPATHY': relations.COMPANION_EMPATHY,
                              'ARCHETYPE': game_relations.ARCHETYPE} )
Ejemplo n.º 7
0
 def __init__(self, *args, **kwargs):
     super(UserForm, self).__init__(*args, **kwargs)
     self.fields['place'].choices = places_storage.get_choices()
     self.fields['new_modifier'].choices = sorted(CITY_MODIFIERS.choices(), key=lambda m: m[1])
Ejemplo n.º 8
0
    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):