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', 'activation', 'property', 'synergy_prerequisite', ).prefetch_related('aura_schools', 'required_feats', 'required_spells'), pk=item_id) assert isinstance(item, Item) if (item.slug != item_slug or str(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(request, 'dnd/items/item_detail.html', context={'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, '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),},)
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), )
def _thousands_separator(value): return int_with_commas(value)