def public_price(request, item_id): """ Serves URL /industry/catalog/items/<item_id>/public_price/ update the public price of the item return the price formatted as a string """ try: error = None type_id = int(item_id) supply_source_id = Setting.get('industry_default_price_source') try: buyPrices = evecentral.get_buy_prices([type_id], supply_source_id) item = get_object_or_404(CatalogEntry, typeID=type_id) if buyPrices[type_id] > 0.0 and item.public_price != buyPrices[type_id]: item.public_price = buyPrices[type_id] logger.info('New price for "%s" -> %s' % (item.typeName, print_float(buyPrices[type_id]))) item.save() except KeyError: error = 'Could not find buy-price for item: "%s"' % item if error: return HttpResponseBadRequest(error) else: return HttpResponse(print_float(item.public_price)) except ValueError: raise Http404()
def public_price(request, item_id): """ Serves URL /industry/catalog/items/<item_id>/public_price/ update the public price of the item return the price formatted as a string """ try: error = None type_id = int(item_id) supply_source_id = Setting.get('industry_default_price_source') try: buyPrices = evecentral.get_buy_prices([type_id], supply_source_id) item = get_object_or_404(CatalogEntry, typeID=type_id) if buyPrices[type_id] > 0.0 and item.public_price != buyPrices[ type_id]: item.public_price = buyPrices[type_id] logger.info('New price for "%s" -> %s' % (item.typeName, print_float(buyPrices[type_id]))) item.save() except KeyError: error = 'Could not find buy-price for item: "%s"' % item if error: return HttpResponseBadRequest(error) else: return HttpResponse(print_float(item.public_price)) except ValueError: raise Http404()
def update_price(request, supply_id): """ Serves URL /industry/catalog/supplies/<supply_id>/updateprice/ """ try: supply = get_object_or_404(Supply, typeID=int(supply_id)) except ValueError: raise Http404() buyPrices = evecentral.get_buy_prices([supply.typeID], supply.supply_source_id) if buyPrices[supply.typeID] > 0.0 and supply.price != buyPrices[supply.typeID]: supply.update_price(buyPrices[supply.typeID]) logger.info('"%s" updated price for supply "%s" (%s -> %s)' % (request.user, supply.typeName, supply.supply_source, print_float(supply.price))) return HttpResponse(print_float(supply.price))
def update_supply_prices(): supplyPrices = Supply.objects.filter(auto_update=True) for supply_source in SupplySource.objects.all(): logger.debug('Updating supply prices for %s (%d)...' % (supply_source.name,supply_source.location_id)) prices = supplyPrices.filter(supply_source=supply_source) item_ids = prices.values_list('typeID', flat=True) buyPrices = evecentral.get_buy_prices(item_ids, supply_source.location_id) #buyPrices = evemarketeer.get_buy_prices(item_ids, supply_source.location_id) for supPrice in prices: try: if buyPrices[supPrice.typeID] > 0.0 and supPrice.price != buyPrices[supPrice.typeID]: supPrice.update_price(buyPrices[supPrice.typeID]) logger.info('New price for "%s" -> %s' % (supPrice.item_admin_display(), print_float(buyPrices[supPrice.typeID]))) except KeyError: logger.info('Could not find buy-price for item: %d - skipping' % (supPrice.typeID))
def update_supply_prices(): supplyPrices = Supply.objects.filter(auto_update=True) for supply_source in SupplySource.objects.all(): logger.debug('Updating supply prices for %s (%d)...' % (supply_source.name, supply_source.location_id)) prices = supplyPrices.filter(supply_source=supply_source) item_ids = prices.values_list('typeID', flat=True) buyPrices = evecentral.get_buy_prices(item_ids, supply_source.location_id) #buyPrices = evemarketeer.get_buy_prices(item_ids, supply_source.location_id) for supPrice in prices: try: if buyPrices[ supPrice.typeID] > 0.0 and supPrice.price != buyPrices[ supPrice.typeID]: supPrice.update_price(buyPrices[supPrice.typeID]) logger.info('New price for "%s" -> %s' % (supPrice.item_admin_display(), print_float(buyPrices[supPrice.typeID]))) except KeyError: logger.info( 'Could not find buy-price for item: %d - skipping' % (supPrice.typeID))