Exemplo n.º 1
0
class CharacterClassFilter(django_filters2.FilterSet):
    character_class__name = django_filters2.CharFilter(lookup_type='icontains',
                                                       label='Class name')
    character_class__prestige = django_filters2.BooleanFilter()
    rulebook__slug = django_filters2.ChoiceFilter(label='Rulebook',
                                                  choices=rulebook_choices())
    rulebook__dnd_edition__slug = django_filters2.MultipleChoiceFilter(
        choices=edition_choices(unknown_entry=False),
        label='Edition',
    )
    required_bab = django_filters2.RangeFilter(
        label='Required Base Attack (range)', )
    skill_points = django_filters2.RangeFilter(
        label='Skill points/level (range)', )
    class_features = django_filters2.CharFilter(
        label='Class feature',
        lookup_type='icontains',
    )
    hit_die = django_filters2.RangeFilter(label='Hit die (range)', )

    class Meta:
        model = CharacterClass
        fields = [
            'character_class__name',
            'rulebook__slug',
            'rulebook__dnd_edition__slug',
            'character_class__prestige',
            'required_bab',
            'skill_points',
            'class_features',
            'hit_die',
        ]
Exemplo n.º 2
0
class SpellFilterAdmin(SpellFilter):
    verified = django_filters2.BooleanFilter()

    class Meta:
        model = SpellFilter.Meta.model
        fields = [
            'verified',
        ] + SpellFilter.Meta.fields
Exemplo n.º 3
0
class SkillFilter(django_filters2.FilterSet):
    name = django_filters2.CharFilter(lookup_type='icontains')
    trained_only = django_filters2.BooleanFilter()
    armor_check_penalty = django_filters2.BooleanFilter()
    base_skill = django_filters2.ChoiceFilter(choices=(
        ('', 'Unknown'),
        ('STR', 'STR'),
        ('CON', 'CON'),
        ('DEX', 'DEX'),
        ('INT', 'INT'),
        ('WIS', 'WIS'),
        ('CHA', 'CHA'),
        ('None', 'None'),
    ))

    class Meta:
        model = Skill
        fields = ['name', 'trained_only', 'armor_check_penalty', 'base_skill']
Exemplo n.º 4
0
class SpellFilter(django_filters2.FilterSet):
    school_choices = [(school.slug, school.name)
                      for school in SpellSchool.objects.all()]
    school_choices.insert(0, ('', 'Unknown'))

    sub_school_choices = [(sub_school.slug, sub_school.name)
                          for sub_school in SpellSubSchool.objects.all()]
    sub_school_choices.insert(0, ('', 'Unknown'))

    descriptor_choices = [(descriptor.slug, descriptor.name)
                          for descriptor in SpellDescriptor.objects.all()]
    descriptor_choices.insert(0, ('', 'Unknown'))

    name = django_filters2.CharFilter(lookup_type='icontains',
                                      label='Spell name')
    # noinspection PyShadowingBuiltins
    range = django_filters2.CharFilter(lookup_type='icontains', )
    casting_time = django_filters2.CharFilter(lookup_type='icontains', )
    spell_resistance = django_filters2.CharFilter(lookup_type='icontains', )
    area = django_filters2.CharFilter(lookup_type='icontains')
    duration = django_filters2.CharFilter(lookup_type='icontains')
    saving_throw = django_filters2.CharFilter(lookup_type='icontains')

    school__slug = django_filters2.ChoiceFilter(choices=school_choices,
                                                label='School')
    sub_school__slug = django_filters2.ChoiceFilter(choices=sub_school_choices,
                                                    label='Sub-school')
    descriptors__slug = django_filters2.ChoiceFilter(
        choices=descriptor_choices, label='Descriptor')
    verbal_component = django_filters2.BooleanFilter()
    somatic_component = django_filters2.BooleanFilter()
    material_component = django_filters2.BooleanFilter()
    arcane_focus_component = django_filters2.BooleanFilter()
    divine_focus_component = django_filters2.BooleanFilter()
    xp_component = django_filters2.BooleanFilter()

    rulebook__dnd_edition__slug = django_filters2.MultipleChoiceFilter(
        choices=edition_choices(unknown_entry=False),
        label='Edition',
    )
    rulebook__slug = django_filters2.ChoiceFilter(label='Rulebook',
                                                  choices=rulebook_choices())
    description = django_filters2.CharFilter(lookup_type='icontains', )
    class_levels__slug = django_filters2.ChoiceFilter(
        choices=character_class_casting_choices(),
        help_text='Shows only classes with own spell lists',
        label='Class',
        grouped=True,
    )
    spellclasslevel__level = django_filters2.MultipleChoiceFilter(
        choices=spell_level_choices(),
        label='Level for class',
        help_text='Use ctrl to select more levels!',
        grouped=True,
    )
    domain_levels__slug = django_filters2.ChoiceFilter(
        choices=domain_choices(),
        label='Domain',
        grouped=True,
    )
    spelldomainlevel__level = django_filters2.MultipleChoiceFilter(
        choices=spell_level_choices(),
        label='Level for domain',
        help_text='Use ctrl to select more levels!',
        grouped=True,
    )

    class Meta:
        model = Spell
        fields = [
            'name',
            'range',
            'spell_resistance',
            'area',
            'duration',
            'saving_throw',
            'casting_time',
            'school__slug',
            'sub_school__slug',
            'descriptors__slug',
            'verbal_component',
            'somatic_component',
            'material_component',
            'arcane_focus_component',
            'divine_focus_component',
            'xp_component',
            'rulebook__slug',
            'rulebook__dnd_edition__slug',
            'description',
            'class_levels__slug',
            'spellclasslevel__level',
            'domain_levels__slug',
            'spelldomainlevel__level',
        ]