Example #1
0
def race_list_by_rulebook_mobile(request):
    rulebook_list = Rulebook.objects.select_related('dnd_edition').all()

    paginator = DndMobilePaginator(rulebook_list, request)

    return render(request, 'dnd/mobile/races/race_list_by_rulebook.html', context=
      {'rulebook_list': paginator.items(), 'paginator': paginator,},)
Example #2
0
def feat_category_list_mobile(request):
    feat_category_list = FeatCategory.objects.all()

    paginator = DndMobilePaginator(feat_category_list, request)

    return render(request, 'dnd/mobile/feats/feat_category_list.html', context=
      {'feat_category_list': paginator.items(), 'paginator': paginator,},)
Example #3
0
def edition_list_mobile(request):
    edition_list = DndEdition.objects.all()

    paginator = DndMobilePaginator(edition_list, request)

    return render(request, 'dnd/mobile/rulebooks/edition_list.html', context={
      'edition_list': paginator.items(), 'paginator': paginator,},)
Example #4
0
def monsters_in_rulebook_mobile(request, rulebook_slug, rulebook_id):
    rulebook = get_object_or_404(Rulebook, pk=rulebook_id)
    if not rulebook.slug == rulebook_slug:
        return permanent_redirect_view(request,
                                       monsters_in_rulebook_mobile,
                                       kwargs={
                                           'rulebook_slug': rulebook.slug,
                                           'rulebook_id': rulebook_id,
                                       })

    monster_list = rulebook.monster_set.select_related(
        'rulebook', 'rulebook__dnd_edition', 'school').all()

    paginator = DndMobilePaginator(monster_list, request)

    return render_to_response(
        'dnd/mobile/monsters/monsters_in_rulebook.html',
        {
            'rulebook': rulebook,
            'monster_list': paginator.items(),
            'paginator': paginator,
            'request': request,
            'display_3e_warning': is_3e_edition(rulebook.dnd_edition),
        },
        context_instance=RequestContext(request),
    )
Example #5
0
def spell_domain_detail_mobile(request, spell_domain_slug, rulebook_slug=None, rulebook_id=None):
    # fetch the class
    spell_domain = get_object_or_404(Domain.objects.prefetch_related(
        'variant', 'variant__rulebook'), slug=spell_domain_slug)

    # fetch primary variant, this is independent of rulebook selected
    try:
        primary_variant = DomainVariant.objects.select_related('rulebook__dnd_edition',).prefetch_related('rulebook').filter(
            domain=spell_domain,
        ).order_by('-rulebook__dnd_edition__core', '-rulebook__published')[0]
    except Exception:
        primary_variant = None

    # if rulebook is supplied, select find this variant
    if rulebook_slug and rulebook_id:
        # use canonical link in head as this is more or less duplicated content
        use_canonical_link = True
        selected_variant = get_object_or_404(
            DomainVariant.objects.select_related('domain', 'rulebook__dnd_edition').prefetch_related('rulebook'),
            domain__slug=spell_domain_slug,
            rulebook__pk=rulebook_id)

        # possible malformed/changed slug
        if rulebook_slug != selected_variant.rulebook.slug:
            return permanent_redirect_object_mobile(request, selected_variant)

        # selected variant is primary! Redirect to canonical url
        if selected_variant == primary_variant:
            return permanent_redirect_view(
                request, spell_domain_detail, kwargs={
                    'spell_domain_slug': spell_domain_slug}
            )
    else:
        # this is canonical, no need to specify it
        use_canonical_link = False
        selected_variant = primary_variant

    other_variants = [
        variant
        for variant
        in spell_domain.variant.select_related('rulebook__dnd_edition', 'domain').prefetch_related('rulebook').all()
        if variant != selected_variant
    ]

    if selected_variant:
        display_3e_warning = is_3e_edition(selected_variant.rulebook.dnd_edition)
    else:
        display_3e_warning = False

    spell_list = spell_domain.spell_set.select_related('rulebook__dnd_edition', 'school').prefetch_related('rulebook').all()

    paginator = DndMobilePaginator(spell_list, request)

    return render(request, 'dnd/mobile/spells/spell_domain_detail.html', context={'spell_domain': spell_domain,
      'spell_list': paginator.items(), 'paginator': paginator, 'i_like_it_url': request.build_absolute_uri(),
      'inaccurate_url': request.build_absolute_uri(), 'selected_variant': selected_variant,
      'other_variants': other_variants, 'use_canonical_link': use_canonical_link,
      'display_3e_warning': display_3e_warning, },)
Example #6
0
def spell_school_detail_mobile(request, spell_school_slug):
    spell_school = get_object_or_404(SpellSchool, slug=spell_school_slug)

    spell_list = spell_school.spell_set.select_related('rulebook__dnd_edition', 'school').prefetch_related('rulebook').all()

    paginator = DndMobilePaginator(spell_list, request)

    return render(request, 'dnd/mobile/spells/spell_school_detail.html', context={'spell_school': spell_school,
      'spell_list': paginator.items(), 'paginator': paginator, 'i_like_it_url': request.build_absolute_uri(),
      'inaccurate_url': request.build_absolute_uri(), },)
Example #7
0
def edition_list_mobile(request):
    edition_list = DndEdition.objects.all()

    paginator = DndMobilePaginator(edition_list, request)

    return render_to_response(
        "dnd/mobile/rulebooks/edition_list.html",
        {"edition_list": paginator.items(), "paginator": paginator, "request": request},
        context_instance=RequestContext(request),
    )
Example #8
0
def spell_list_by_rulebook_mobile(request):
    rulebook_list = Rulebook.objects.select_related("dnd_edition").all()

    paginator = DndMobilePaginator(rulebook_list, request)

    return render_to_response(
        "dnd/mobile/spells/spell_list_by_rulebook.html",
        {"request": request, "rulebook_list": paginator.items(), "paginator": paginator},
        context_instance=RequestContext(request),
    )
Example #9
0
def feat_category_detail_mobile(request, category_slug):
    feat_category = get_object_or_404(FeatCategory, slug=category_slug)
    feat_list = feat_category.feat_set.select_related('rulebook',
                                                      'rulebook__dnd_edition').all()

    paginator = DndMobilePaginator(feat_list, request)

    return render(request, 'dnd/mobile/feats/feat_category_detail.html', context=
      {'feat_category': feat_category, 'feat_list': paginator.items(), 'paginator': paginator,
       'i_like_it_url': request.build_absolute_uri(), 'inaccurate_url': request.build_absolute_uri(), },)
Example #10
0
def feat_category_list_mobile(request):
    feat_category_list = FeatCategory.objects.all()

    paginator = DndMobilePaginator(feat_category_list, request)

    return render_to_response('dnd/mobile/feats/feat_category_list.html',
                              {
                                  'feat_category_list': paginator.items(),
                                  'paginator': paginator,
                                  'request': request, }, context_instance=RequestContext(request), )
Example #11
0
def language_index_mobile(request):
    f = LanguageFilter(request.GET, queryset=Language.objects.distinct())

    paginator = DndMobilePaginator(f.qs, request)

    form_submitted = 1 if '_filter' in request.GET else 0

    return render(request, 'dnd/mobile/languages/language_index.html', context=
      {'language_list': paginator.items(), 'paginator': paginator,
       'filter': f, 'form_submitted': form_submitted,},)
Example #12
0
def feat_index_mobile(request):
    f = FeatFilter(request.GET, queryset=Feat.objects.select_related(
        'rulebook', 'rulebook__dnd_edition').distinct())

    form_submitted = 1 if '_filter' in request.GET else 0

    paginator = DndMobilePaginator(f.qs, request)

    return render(request, 'dnd/mobile/feats/feat_index.html', context={'feat_list': paginator.items(),
      'paginator': paginator, 'filter': f, 'form_submitted': form_submitted,},)
Example #13
0
def skills_list_by_rulebook_mobile(request):
    rulebook_list = Rulebook.objects.select_related('dnd_edition').all()

    paginator = DndMobilePaginator(rulebook_list, request)

    return render_to_response('dnd/mobile/skills/skills_list_by_rulebook.html',
                              {
                                  'request': request,
                                  'rulebook_list': paginator.items(),
                                  'paginator': paginator,
                              }, context_instance=RequestContext(request), )
Example #14
0
def spell_list_by_rulebook_mobile(request):
    rulebook_list = Rulebook.objects.select_related('dnd_edition').all()

    paginator = DndMobilePaginator(rulebook_list, request)

    return render_to_response('dnd/mobile/spells/spell_list_by_rulebook.html',
                              {
                                  'request': request,
                                  'rulebook_list': paginator.items(),
                                  'paginator': paginator,
                              }, context_instance=RequestContext(request), )
Example #15
0
def rulebook_list_mobile(request):
    f = RulebookFilter(request.GET, queryset=Rulebook.objects.select_related(
        'dnd_edition'))

    form_submitted = 1 if '_filter' in request.GET else 0

    paginator = DndMobilePaginator(f.qs, request)

    return render(request, 'dnd/mobile/rulebooks/rulebook_list.html', context={
      'rulebook_list': paginator.items(), 'paginator': paginator, 'filter': f,
      'form_submitted': form_submitted,},)
Example #16
0
def spell_descriptor_list_mobile(request):
    f = SpellDescriptorFilter(request.GET,
                              queryset=SpellDescriptor.objects.all())

    paginator = DndMobilePaginator(f.qs, request)

    form_submitted = 1 if '_filter' in request.GET else 0

    return render(request, 'dnd/mobile/spells/spell_descriptor_list.html', context=
      {'spell_descriptor_list': paginator.items(), 'paginator': paginator, 'filter': f,
       'form_submitted': form_submitted,},)
Example #17
0
def edition_detail_mobile(request, edition_slug, edition_id):
    dnd_edition = get_object_or_404(DndEdition, id=edition_id)
    if dnd_edition.slug != edition_slug:
        return permanent_redirect_object_mobile(request, dnd_edition)

    rulebook_list = dnd_edition.rulebook_set.select_related('dnd_edition').all()

    paginator = DndMobilePaginator(rulebook_list, request)

    return render(request, 'dnd/mobile/rulebooks/edition_detail.html', context=
      {'dnd_edition': dnd_edition, 'rulebook_list': paginator.items(), 'paginator': paginator,
       'i_like_it_url': request.build_absolute_uri(), 'inaccurate_url': request.build_absolute_uri(),
       'display_3e_warning': is_3e_edition(dnd_edition),},)
Example #18
0
def character_class_list_mobile(request):
    f = CharacterClassFilter(
        request.GET,
        queryset=CharacterClassVariant.objects.select_related(
            'rulebook', 'rulebook__dnd_edition', 'character_class')
    )

    form_submitted = 1 if '_filter' in request.GET else 0

    paginator = DndMobilePaginator(f.qs, request)

    return render(request, 'dnd/mobile/character_classes/character_class_list.html', context=
      {'character_class_list': paginator.items(), 'paginator': paginator, 'filter': f,
       'form_submitted': form_submitted,},)
Example #19
0
def edition_list_mobile(request):
    edition_list = DndEdition.objects.all()

    paginator = DndMobilePaginator(edition_list, request)

    return render_to_response(
        'dnd/mobile/rulebooks/edition_list.html',
        {
            'edition_list': paginator.items(),
            'paginator': paginator,
            'request': request,
        },
        context_instance=RequestContext(request),
    )
Example #20
0
def feat_category_list_mobile(request):
    feat_category_list = FeatCategory.objects.all()

    paginator = DndMobilePaginator(feat_category_list, request)

    return render_to_response(
        'dnd/mobile/feats/feat_category_list.html',
        {
            'feat_category_list': paginator.items(),
            'paginator': paginator,
            'request': request,
        },
        context_instance=RequestContext(request),
    )
Example #21
0
def spell_domain_list_mobile(request):
    f = SpellDomainFilter(request.GET, queryset=Domain.objects.all())

    paginator = DndMobilePaginator(f.qs, request)

    form_submitted = 1 if '_filter' in request.GET else 0

    return render_to_response('dnd/mobile/spells/spell_domain_list.html',
                              {
                                  'request': request,
                                  'spell_domain_list': paginator.items(),
                                  'paginator': paginator,
                                  'filter': f,
                                  'form_submitted': form_submitted,
                              }, context_instance=RequestContext(request), )
Example #22
0
def skill_list_mobile(request):
    f = SkillFilter(request.GET, queryset=Skill.objects.all())

    form_submitted = 1 if '_filter' in request.GET else 0

    paginator = DndMobilePaginator(f.qs, request)

    return render_to_response('dnd/mobile/skills/skill_list.html',
                              {
                                  'request': request,
                                  'skill_list': paginator.items(),
                                  'paginator': paginator,
                                  'filter': f,
                                  'form_submitted': form_submitted,
                              }, context_instance=RequestContext(request), )
Example #23
0
def monster_index_mobile(request):
    f = MonsterFilter(request.GET, queryset=Monster.objects.select_related(
        'rulebook', 'rulebook__dnd_edition', 'school').distinct())

    paginator = DndMobilePaginator(f.qs, request)

    form_submitted = 1 if '_filter' in request.GET else 0

    return render_to_response('dnd/mobile/monsters/monster_index.html',
                              {
                                  'request': request,
                                  'monster_list': paginator.items(),
                                  'paginator': paginator,
                                  'filter': f,
                                  'form_submitted': form_submitted,
                              }, context_instance=RequestContext(request), )
Example #24
0
def language_detail_mobile(request, language_slug):
    language = get_object_or_404(
        Language.objects,
        slug=language_slug,
    )
    assert isinstance(language, Language)

    race_list = Race.objects.filter(
        Q(automatic_languages=language)
        | Q(bonus_languages=language)).select_related(
            'rulebook').distinct().all()

    paginator = DndMobilePaginator(race_list, request)

    return render_to_response(
        'dnd/mobile/languages/language_detail.html',
        {
            'language': language,
            'paginator': paginator,
            'race_list': race_list,
            'i_like_it_url': request.build_absolute_uri(),
            'inaccurate_url': request.build_absolute_uri(),
        },
        context_instance=RequestContext(request),
    )
Example #25
0
def character_class_spells_mobile(request, character_class_slug, level):
    character_class = get_object_or_404(CharacterClass,
                                        slug=character_class_slug)

    spell_list = Spell.objects.filter(
        spellclasslevel__character_class=character_class.id,
        spellclasslevel__level=level).select_related(
        'rulebook',
        'rulebook__dnd_edition',
        'school')

    paginator = DndMobilePaginator(spell_list, request)

    return render(request, 'dnd/mobile/character_classes/character_class_spells.html', context=
      {'character_class': character_class, 'spell_list': paginator.items(), 'paginator': paginator,
       'level': level,},)
Example #26
0
def spell_index_mobile(request):
    f = SpellFilter(request.GET, queryset=Spell.objects.select_related(
        'rulebook', 'rulebook__dnd_edition', 'school').distinct())

    paginator = DndMobilePaginator(f.qs, request)

    form_submitted = 1 if '_filter' in request.GET else 0

    return render_to_response('dnd/mobile/spells/spell_index.html',
                              {
                                  'request': request,
                                  'spell_list': paginator.items(),
                                  'paginator': paginator,
                                  'filter': f,
                                  'form_submitted': form_submitted,
                              }, context_instance=RequestContext(request), )
Example #27
0
def races_in_rulebook_mobile(request, rulebook_slug, rulebook_id):
    rulebook = get_object_or_404(Rulebook, pk=rulebook_id)
    if not rulebook.slug == rulebook_slug:
        return permanent_redirect_view(request, 'dnd:mobile:races:races_in_rulebook_mobile',
                                       kwargs={
                                           'rulebook_slug': rulebook.slug,
                                           'rulebook_id': rulebook_id, })

    race_list = rulebook.race_set.select_related(
        'rulebook', 'rulebook__dnd_edition').all()

    paginator = DndMobilePaginator(race_list, request)

    return render(request, 'dnd/mobile/races/races_in_rulebook.html', context=
      {'rulebook': rulebook, 'race_list': paginator.items(), 'paginator': paginator,
       'display_3e_warning': is_3e_edition(rulebook.dnd_edition),},)
Example #28
0
def item_index_mobile(request):
    f = ItemFilter(request.GET, queryset=Item.objects.select_related(
        'rulebook', 'rulebook__dnd_edition', 'body_slot', 'property').distinct())

    paginator = DndMobilePaginator(f.qs, request)

    form_submitted = 1 if '_filter' in request.GET else 0

    return render_to_response('dnd/mobile/items/item_index.html',
                              {
                                  'request': request,
                                  'item_list': paginator.items(),
                                  'paginator': paginator,
                                  'filter': f,
                                  'form_submitted': form_submitted,
                              }, context_instance=RequestContext(request), )
Example #29
0
def spell_school_detail_mobile(request, spell_school_slug):
    spell_school = get_object_or_404(SpellSchool, slug=spell_school_slug)

    spell_list = spell_school.spell_set.select_related(
        'rulebook', 'rulebook__dnd_edition', 'school').all()

    paginator = DndMobilePaginator(spell_list, request)

    return render_to_response('dnd/mobile/spells/spell_school_detail.html',
                              {
                                  'spell_school': spell_school,
                                  'spell_list': paginator.items(),
                                  'paginator': paginator,
                                  'request': request,
                                  'i_like_it_url': request.build_absolute_uri(),
                                  'inaccurate_url': request.build_absolute_uri(), },
                              context_instance=RequestContext(request), )
Example #30
0
def skill_list_mobile(request):
    f = SkillFilter(request.GET, queryset=Skill.objects.all())

    form_submitted = 1 if '_filter' in request.GET else 0

    paginator = DndMobilePaginator(f.qs, request)

    return render(request, 'dnd/mobile/skills/skill_list.html', context={'skill_list': paginator.items(),
      'paginator': paginator, 'filter': f, 'form_submitted': form_submitted,},)
Example #31
0
def rulebook_list_mobile(request):
    f = RulebookFilter(request.GET, queryset=Rulebook.objects.select_related("dnd_edition"))

    form_submitted = 1 if "_filter" in request.GET else 0

    paginator = DndMobilePaginator(f.qs, request)

    return render_to_response(
        "dnd/mobile/rulebooks/rulebook_list.html",
        {
            "request": request,
            "rulebook_list": paginator.items(),
            "paginator": paginator,
            "filter": f,
            "form_submitted": form_submitted,
        },
        context_instance=RequestContext(request),
    )
Example #32
0
def spell_descriptor_list_mobile(request):
    f = SpellDescriptorFilter(request.GET, queryset=SpellDescriptor.objects.all())

    paginator = DndMobilePaginator(f.qs, request)

    form_submitted = 1 if "_filter" in request.GET else 0

    return render_to_response(
        "dnd/mobile/spells/spell_descriptor_list.html",
        {
            "request": request,
            "spell_descriptor_list": paginator.items(),
            "paginator": paginator,
            "filter": f,
            "form_submitted": form_submitted,
        },
        context_instance=RequestContext(request),
    )
Example #33
0
def deity_list_mobile(request):
    f = DeityFilter(request.GET, queryset=Deity.objects.all())

    form_submitted = 1 if '_filter' in request.GET else 0

    paginator = DndMobilePaginator(f.qs, request)

    return render_to_response(
        'dnd/mobile/deities/deity_list.html',
        {
            'request': request,
            'deity_list': paginator.items(),
            'paginator': paginator,
            'filter': f,
            'form_submitted': form_submitted,
        },
        context_instance=RequestContext(request),
    )
Example #34
0
def language_index_mobile(request):
    f = LanguageFilter(request.GET, queryset=Language.objects.distinct())

    paginator = DndMobilePaginator(f.qs, request)

    form_submitted = 1 if "_filter" in request.GET else 0

    return render_to_response(
        "dnd/mobile/languages/language_index.html",
        {
            "request": request,
            "language_list": paginator.items(),
            "paginator": paginator,
            "filter": f,
            "form_submitted": form_submitted,
        },
        context_instance=RequestContext(request),
    )
Example #35
0
def deity_list_mobile(request):
    f = DeityFilter(request.GET, queryset=Deity.objects.all())

    form_submitted = 1 if "_filter" in request.GET else 0

    paginator = DndMobilePaginator(f.qs, request)

    return render_to_response(
        "dnd/mobile/deities/deity_list.html",
        {
            "request": request,
            "deity_list": paginator.items(),
            "paginator": paginator,
            "filter": f,
            "form_submitted": form_submitted,
        },
        context_instance=RequestContext(request),
    )
Example #36
0
def language_index_mobile(request):
    f = LanguageFilter(request.GET, queryset=Language.objects.distinct())

    paginator = DndMobilePaginator(f.qs, request)

    form_submitted = 1 if '_filter' in request.GET else 0

    return render_to_response(
        'dnd/mobile/languages/language_index.html',
        {
            'request': request,
            'language_list': paginator.items(),
            'paginator': paginator,
            'filter': f,
            'form_submitted': form_submitted,
        },
        context_instance=RequestContext(request),
    )
Example #37
0
def spell_index_mobile(request):
    f = SpellFilter(request.GET, queryset=Spell.objects.select_related(
            'rulebook', 'rulebook__dnd_edition', 'school').distinct())

    paginator = DndMobilePaginator(f.qs, request)

    form_submitted = 1 if '_filter' in request.GET else 0

    return render(request, 'dnd/mobile/spells/spell_index.html', context={'spell_list': paginator.items(),
      'paginator': paginator, 'filter': f, 'form_submitted': form_submitted,},)
Example #38
0
def spell_sub_school_detail_mobile(request, spell_sub_school_slug):
    spell_sub_school = get_object_or_404(SpellSubSchool, slug=spell_sub_school_slug)

    spell_list = spell_sub_school.spell_set.select_related("rulebook", "rulebook__dnd_edition", "school").all()

    paginator = DndMobilePaginator(spell_list, request)

    return render_to_response(
        "dnd/mobile/spells/spell_sub_school_detail.html",
        {
            "spell_sub_school": spell_sub_school,
            "spell_list": paginator.items(),
            "paginator": paginator,
            "request": request,
            "i_like_it_url": request.build_absolute_uri(),
            "inaccurate_url": request.build_absolute_uri(),
        },
        context_instance=RequestContext(request),
    )
Example #39
0
def race_type_index_mobile(request):
    f = RaceTypeFilter(request.GET, queryset=RaceType.objects.distinct())

    paginator = DndMobilePaginator(f.qs, request)

    form_submitted = 1 if '_filter' in request.GET else 0

    return render(request, 'dnd/mobile/races/race_type_index.html', context={'race_type_list': paginator.items(),
      'paginator': paginator, 'filter': f, 'BaseSaveType': RaceType.BaseSaveType,
      'BaseAttackType': RaceType.BaseAttackType, 'form_submitted': form_submitted,},)
Example #40
0
def rulebook_list_mobile(request):
    f = RulebookFilter(request.GET,
                       queryset=Rulebook.objects.select_related('dnd_edition'))

    form_submitted = 1 if '_filter' in request.GET else 0

    paginator = DndMobilePaginator(f.qs, request)

    return render_to_response(
        'dnd/mobile/rulebooks/rulebook_list.html',
        {
            'request': request,
            'rulebook_list': paginator.items(),
            'paginator': paginator,
            'filter': f,
            'form_submitted': form_submitted,
        },
        context_instance=RequestContext(request),
    )
Example #41
0
def feat_category_detail_mobile(request, category_slug):
    feat_category = get_object_or_404(FeatCategory, slug=category_slug)
    feat_list = feat_category.feat_set.select_related(
        'rulebook', 'rulebook__dnd_edition').all()

    paginator = DndMobilePaginator(feat_list, request)

    return render_to_response(
        'dnd/mobile/feats/feat_category_detail.html',
        {
            'feat_category': feat_category,
            'feat_list': paginator.items(),
            'paginator': paginator,
            'request': request,
            'i_like_it_url': request.build_absolute_uri(),
            'inaccurate_url': request.build_absolute_uri(),
        },
        context_instance=RequestContext(request),
    )
Example #42
0
def race_type_index_mobile(request):
    f = RaceTypeFilter(request.GET, queryset=RaceType.objects.distinct())

    paginator = DndMobilePaginator(f.qs, request)

    form_submitted = 1 if '_filter' in request.GET else 0

    return render_to_response(
        'dnd/mobile/races/race_type_index.html',
        {
            'request': request,
            'race_type_list': paginator.items(),
            'paginator': paginator,
            'filter': f,
            'BaseSaveType': RaceType.BaseSaveType,  # enums
            'BaseAttackType': RaceType.BaseAttackType,  # enums
            'form_submitted': form_submitted,
        },
        context_instance=RequestContext(request),
    )
Example #43
0
def spell_index_mobile(request):
    f = SpellFilter(
        request.GET, queryset=Spell.objects.select_related("rulebook", "rulebook__dnd_edition", "school").distinct()
    )

    paginator = DndMobilePaginator(f.qs, request)

    form_submitted = 1 if "_filter" in request.GET else 0

    return render_to_response(
        "dnd/mobile/spells/spell_index.html",
        {
            "request": request,
            "spell_list": paginator.items(),
            "paginator": paginator,
            "filter": f,
            "form_submitted": form_submitted,
        },
        context_instance=RequestContext(request),
    )
Example #44
0
def character_class_list_mobile(request):
    f = CharacterClassFilter(
        request.GET,
        queryset=CharacterClassVariant.objects.select_related(
            'rulebook', 'rulebook__dnd_edition', 'character_class'))

    form_submitted = 1 if '_filter' in request.GET else 0

    paginator = DndMobilePaginator(f.qs, request)

    return render_to_response(
        'dnd/mobile/character_classes/character_class_list.html',
        {
            'character_class_list': paginator.items(),
            'paginator': paginator,
            'request': request,
            'filter': f,
            'form_submitted': form_submitted,
        },
        context_instance=RequestContext(request),
    )
Example #45
0
def item_index_mobile(request):
    f = ItemFilter(request.GET,
                   queryset=Item.objects.select_related(
                       'rulebook', 'rulebook__dnd_edition', 'body_slot',
                       'property').distinct())

    paginator = DndMobilePaginator(f.qs, request)

    form_submitted = 1 if '_filter' in request.GET else 0

    return render_to_response(
        'dnd/mobile/items/item_index.html',
        {
            'request': request,
            'item_list': paginator.items(),
            'paginator': paginator,
            'filter': f,
            'form_submitted': form_submitted,
        },
        context_instance=RequestContext(request),
    )
Example #46
0
def character_class_spells_mobile(request, character_class_slug, level):
    character_class = get_object_or_404(CharacterClass,
                                        slug=character_class_slug)

    spell_list = Spell.objects.filter(
        spellclasslevel__character_class=character_class.id,
        spellclasslevel__level=level).select_related('rulebook',
                                                     'rulebook__dnd_edition',
                                                     'school')

    paginator = DndMobilePaginator(spell_list, request)

    return render_to_response(
        'dnd/mobile/character_classes/character_class_spells.html',
        {
            'character_class': character_class,
            'spell_list': paginator.items(),
            'paginator': paginator,
            'level': level,
            'request': request,
        },
        context_instance=RequestContext(request),
    )
Example #47
0
def edition_detail_mobile(request, edition_slug, edition_id):
    dnd_edition = get_object_or_404(DndEdition, id=edition_id)
    if dnd_edition.slug != edition_slug:
        return permanent_redirect_object_mobile(request, dnd_edition)

    rulebook_list = dnd_edition.rulebook_set.select_related(
        'dnd_edition').all()

    paginator = DndMobilePaginator(rulebook_list, request)

    return render_to_response(
        'dnd/mobile/rulebooks/edition_detail.html',
        {
            'dnd_edition': dnd_edition,
            'request': request,
            'rulebook_list': paginator.items(),
            'paginator': paginator,
            'i_like_it_url': request.build_absolute_uri(),
            'inaccurate_url': request.build_absolute_uri(),
            'display_3e_warning': is_3e_edition(dnd_edition),
        },
        context_instance=RequestContext(request),
    )
Example #48
0
def race_type_detail_mobile(request, race_type_slug):
    race_type = get_object_or_404(
        RaceType.objects,
        slug=race_type_slug,
    )
    assert isinstance(race_type, RaceType)

    race_list = race_type.race_set.all()

    paginator = DndMobilePaginator(race_list, request)

    return render_to_response(
        'dnd/mobile/races/race_type_detail.html',
        {
            'race_type': race_type,
            'paginator': paginator,
            'race_list': race_list,
            'BaseSaveType': RaceType.BaseSaveType,  # enums
            'BaseAttackType': RaceType.BaseAttackType,  # enums
            'i_like_it_url': request.build_absolute_uri(),
            'inaccurate_url': request.build_absolute_uri(),
        },
        context_instance=RequestContext(request),
    )
Example #49
0
def spell_domain_detail_mobile(request, spell_domain_slug, rulebook_slug=None, rulebook_id=None):
    # fetch the domain
    spell_domain = get_object_or_404(Domain.objects.select_related(
        'domain_variant', 'domain_variant__rulebook'), slug=spell_domain_slug)

    # fetch primary variant, this is independent of rulebook selected
    try:
        primary_variant = DomainVariant.objects.select_related(
            'rulebook', 'rulebook__dnd_edition',
        ).filter(
            domain=spell_domain,
        ).order_by('-rulebook__dnd_edition__core', '-rulebook__published')[0]
    except Exception:
        primary_variant = None

    # if rulebook is supplied, select find this variant
    if rulebook_slug and rulebook_id:
        # use canonical link in head as this is more or less duplicated content
        selected_variant = get_object_or_404(
            DomainVariant.objects.select_related(
                'domain', 'rulebook', 'rulebook__dnd_edition'),
            domain__slug=spell_domain_slug,
            rulebook__pk=rulebook_id)

        # possible malformed/changed slug
        if rulebook_slug != selected_variant.rulebook.slug:
            return permanent_redirect_object_mobile(request, selected_variant)

        # selected variant is primary! Redirect to canonical url
        if selected_variant == primary_variant:
            return permanent_redirect_view(
                request, spell_domain_detail_mobile, kwargs={
                    'spell_domain_slug': spell_domain_slug}
            )
    else:
        # this is canonical, no need to specify it
        selected_variant = primary_variant

    other_variants = [
        variant
        for variant
        in spell_domain.domainvariant_set.select_related(
            'rulebook', 'rulebook__dnd_edition', 'spell_domain').all()
        if variant != selected_variant
    ]

    if selected_variant:
        display_3e_warning = is_3e_edition(selected_variant.rulebook.dnd_edition)
    else:
        display_3e_warning = False

    spell_list = spell_domain.spell_set.select_related(
        'rulebook', 'rulebook__dnd_edition', 'school').all()

    paginator = DndMobilePaginator(spell_list, request)

    return render_to_response('dnd/mobile/spells/spell_domain_detail.html',
                              {
                                  'spell_domain': spell_domain,
                                  'spell_list': paginator.items(),
                                  'paginator': paginator,
                                  'request': request,
                                  'i_like_it_url': request.build_absolute_uri(),
                                  'inaccurate_url': request.build_absolute_uri(),
                                  'selected_variant': selected_variant,
                                  'other_variants': other_variants,
                                  'display_3e_warning': display_3e_warning,},
                              context_instance=RequestContext(request), )