def parse_eft(request): if request.method != 'POST': return HttpResponseNotAllowed() eft_block = request.POST.get('eft_block', None) if not eft_block: return HttpResponseBadRequest('Empty EFT block') eft_items = eft.parse_export(eft_block) query = Type.objects.filter(typeName__in=eft_items.keys()) items = {} for item in query: for sk in item.skill_reqs.all(): try: if items[sk.skill] < sk.required_level: items[sk.skill] = sk.required_level except KeyError: items[sk.skill] = sk.required_level out = [] for item in items: out.append({ 'typeID': item.typeID, 'typeName': item.typeName, 'level': items[item], }) return HttpResponse(json.dumps(out), mimetype=JSON)
def parse_fitting(self, export): fitting = eft.parse_export(export) ship_type = None items = [] for item, quantity in fitting.items(): eve_type = Type.objects.get(typeName=item) if eve_type.categoryID == 6: # Ship category ship_type = eve_type fitting.pop(item) else: items.append((eve_type, quantity)) return ship_type, items
#------------------------------------------------------------------------------ @check_user_access() def parse_eft(request): if request.method != 'POST': return HttpResponseNotAllowed() eft_block = request.POST.get('eft_block', None) if not eft_block: return HttpResponseBadRequest('Empty EFT block') try: quantity = int(request.POST.get('quantity', 1)) except ValueError, e: return HttpResponseBadRequest(str(e)) eft_items = eft.parse_export(eft_block) query = CatalogEntry.objects.filter(typeName__in=eft_items.keys(), is_available=True) items = [] for item in query: if item.fixed_price is not None: price = item.fixed_price else: cost = item.production_cost or 0.0 surcharge = PricingPolicy.resolve_surcharge( item, request.user, cost) price = cost + surcharge items.append({ 'typeID': item.typeID, 'typeName': item.typeName,
#------------------------------------------------------------------------------ @check_user_access() def parse_eft(request): if request.method != 'POST': return HttpResponseNotAllowed() eft_block = request.POST.get('eft_block', None) if not eft_block: return HttpResponseBadRequest('Empty EFT block') try: quantity = int(request.POST.get('quantity', 1)) except ValueError, e: return HttpResponseBadRequest(str(e)) eft_items = eft.parse_export(eft_block) query = CatalogEntry.objects.filter(typeName__in=eft_items.keys(), is_available=True) items = [] for item in query: if item.fixed_price is not None: price = item.fixed_price else: cost = item.production_cost or 0.0 surcharge = PricingPolicy.resolve_surcharge(item, request.user, cost) price = cost + surcharge items.append({ 'typeID': item.typeID, 'typeName': item.typeName, 'quantity': eft_items[item.typeName] * quantity, 'price': price