예제 #1
0
파일: views.py 프로젝트: illiptic/dndtools
def item_detail(request, rulebook_slug, rulebook_id, item_slug, item_id):
    item = get_object_or_404(
        Item.objects.select_related(
            "rulebook",
            "rulebook__dnd_edition",
            "body_slot",
            "aura",
            "spellschool_set",
            "activation",
            "required_feats",
            "required_spells",
            "property",
            "synergy_prerequisite",
        ),
        pk=item_id,
    )
    assert isinstance(item, Item)

    if item.slug != item_slug or unicode(item.rulebook.id) != rulebook_id or item.rulebook.slug != rulebook_slug:
        return permanent_redirect_object(request, item)

    required_feats = item.required_feats.select_related("rulebook").all()
    required_spells = item.required_spells.select_related("rulebook").all()

    cost_to_create = item.cost_to_create
    # calculate CTC
    if not cost_to_create:
        if item.price_gp and not item.price_bonus:
            cost_to_create = "%s gp, %s XP, %d day(s)" % (
                int_with_commas(ceil(item.price_gp / 2.0)),
                int_with_commas(ceil(item.price_gp / 25.0)),
                ceil(item.price_gp / 1000.0),
            )
        elif not item.price_gp and item.price_bonus:
            cost_to_create = "Varies"

    return render_to_response(
        "dnd/items/item_detail.html",
        {
            "item": item,
            "aura_schools": item.aura_schools.all(),
            "required_feats": required_feats,
            "required_spells": required_spells,
            "cost_to_create": cost_to_create,
            "rulebook": item.rulebook,
            "request": request,
            # enum
            "ItemType": Item.ItemType,
            "i_like_it_url": request.build_absolute_uri(),
            "inaccurate_url": request.build_absolute_uri(),
            "display_3e_warning": is_3e_edition(item.rulebook.dnd_edition),
        },
        context_instance=RequestContext(request),
    )
예제 #2
0
파일: views.py 프로젝트: illiptic/dndtools
def item_detail_mobile(request, rulebook_slug, rulebook_id, item_slug,
                       item_id):
    item = get_object_or_404(Item.objects.select_related(
        'rulebook',
        'rulebook__dnd_edition',
        'body_slot',
        'aura',
        'spellschool_set',
        'activation',
        'required_feats',
        'required_spells',
        'property',
        'synergy_prerequisite',
    ),
                             pk=item_id)
    assert isinstance(item, Item)

    if (item.slug != item_slug or unicode(item.rulebook.id) != rulebook_id
            or item.rulebook.slug != rulebook_slug):
        return permanent_redirect_object_mobile(request, item)

    required_feats = item.required_feats.select_related('rulebook').all()
    required_spells = item.required_spells.select_related('rulebook').all()

    cost_to_create = item.cost_to_create
    # calculate CTC
    if not cost_to_create:
        if item.price_gp and not item.price_bonus:
            cost_to_create = "%s gp, %s XP, %d day(s)" % (int_with_commas(
                ceil(item.price_gp /
                     2.0)), int_with_commas(ceil(
                         item.price_gp / 25.0)), ceil(item.price_gp / 1000.0))
        elif not item.price_gp and item.price_bonus:
            cost_to_create = "Varies"

    return render_to_response(
        'dnd/mobile/items/item_detail.html',
        {
            'item': item,
            'aura_schools': item.aura_schools.all(),
            'required_feats': required_feats,
            'required_spells': required_spells,
            'cost_to_create': cost_to_create,
            'rulebook': item.rulebook,
            'request': request,
            # enum
            'ItemType': Item.ItemType,
            'i_like_it_url': request.build_absolute_uri(),
            'inaccurate_url': request.build_absolute_uri(),
            'display_3e_warning': is_3e_edition(item.rulebook.dnd_edition),
        },
        context_instance=RequestContext(request),
    )
예제 #3
0
def item_detail_mobile(request, rulebook_slug, rulebook_id, item_slug, item_id):
    item = get_object_or_404(Item.objects.select_related(
        'rulebook', 'rulebook__dnd_edition', 'body_slot', 'aura', 'spellschool_set',
        'activation', 'required_feats', 'required_spells', 'property', 'synergy_prerequisite',
    ), pk=item_id)
    assert isinstance(item, Item)

    if (item.slug != item_slug or
                unicode(item.rulebook.id) != rulebook_id or
                item.rulebook.slug != rulebook_slug):
        return permanent_redirect_object_mobile(request, item)

    required_feats = item.required_feats.select_related('rulebook').all()
    required_spells = item.required_spells.select_related('rulebook').all()

    cost_to_create = item.cost_to_create
    # calculate CTC
    if not cost_to_create:
        if item.price_gp and not item.price_bonus:
            cost_to_create = "%s gp, %s XP, %d day(s)" % (
                int_with_commas(ceil(item.price_gp / 2.0)), int_with_commas(ceil(item.price_gp / 25.0)),
                ceil(item.price_gp / 1000.0))
        elif not item.price_gp and item.price_bonus:
            cost_to_create = "Varies"

    return render_to_response('dnd/mobile/items/item_detail.html',
                              {
                                  'item': item,
                                  'aura_schools': item.aura_schools.all(),
                                  'required_feats': required_feats,
                                  'required_spells': required_spells,
                                  'cost_to_create': cost_to_create,
                                  'rulebook': item.rulebook,
                                  'request': request,
                                  # enum
                                  'ItemType': Item.ItemType,
                                  'i_like_it_url': request.build_absolute_uri(),
                                  'inaccurate_url': request.build_absolute_uri(),
                                  'display_3e_warning': is_3e_edition(item.rulebook.dnd_edition),
                              },
                              context_instance=RequestContext(request), )
예제 #4
0
def _thousands_separator(value):
    return int_with_commas(value)
예제 #5
0
def _thousands_separator(value):
    return int_with_commas(value)