Esempio n. 1
0
def silo_data(request, pos_id):
    try:
        params = extract_datatable_params(request)
        pos_id = int(pos_id)
    except:
        return HttpResponseBadRequest()
    pos = get_object_or_404(POS, item_id=pos_id)
    #silo's are actually the moon mins. this is just the quickest way
    #using the Assets table. might make this work properly at some point.
    silos = Asset.objects.filter(closest_object_id=pos.moon_id,
                                 flag=constants.SILO_TYPEID)
    silo_table = []
    for silo in silos:
        mineral = Type.objects.get(typeID=silo.eve_type_id)
        if pos.fuel_type_id == constants.GALLENTE_FUEL_BLOCK_TYPEID:
            remaining_vol = (constants.SILO_VOLUME * 2.0) - silo.volume
            remaining_per = int(
                (1.0 * silo.volume / (constants.SILO_VOLUME * 2.0)) * 100)
        elif pos.fuel_type_id == constants.AMARR_FUEL_BLOCK_TYPEID:
            remaining_vol = (constants.SILO_VOLUME * 1.5) - silo.volume
            remaining_per = int(
                (1.0 * silo.volume / (constants.SILO_VOLUME * 1.5)) * 100)
        else:
            remaining_vol = constants.SILO_VOLUME - silo.volume
            remaining_per = int(
                (1.0 * silo.volume / (constants.SILO_VOLUME)) * 100)
        if mineral.typeID in constants.COMPLEX_REACTIONS:
            hours_to_full = remaining_vol / (
                mineral.volume * constants.COMPLEX_REACTIONS[mineral.typeID])
        elif mineral.typeID in constants.SIMPLE_REACTIONS:
            hours_to_full = remaining_vol / (mineral.volume * 200)
        elif mineral.typeID in constants.UNREFINED:
            hours_to_full = remaining_vol / (mineral.volume * 1)
        else:
            hours_to_full = remaining_vol / (mineral.volume * 100)

        silo_div = '<div class="progress"><div class="bar" style="width: '
        silo_div += str(remaining_per) + '%;"><span style="color:black;">'
        silo_div += print_duration(seconds=hours_to_full * 3600, verbose=False)
        silo_div += '</span></div></div>'
        silo_table.append([
            silo.eve_type_id,
            mineral.typeName,
            silo.quantity,
            silo_div,
            #print_duration(seconds=hours_to_full * 3600, verbose=False)
        ])
    silo_count = silos.count()
    json_data = {
        "sEcho": params.sEcho,
        "iTotalRecords": silo_count,
        "iTotalDisplayRecords": silo_count,
        "aaData": silo_table,
    }
    return HttpResponse(json.dumps(json_data))
Esempio n. 2
0
def silo_data(request, pos_id):
    try:
        params = extract_datatable_params(request)
        pos_id = int(pos_id)
    except:
        return HttpResponseBadRequest()
    pos = get_object_or_404(POS, item_id=pos_id)
    #silo's are actually the moon mins. this is just the quickest way
    #using the Assets table. might make this work properly at some point.
    silos = Asset.objects.filter(closest_object_id = pos.moon_id,
                                 flag = constants.SILO_TYPEID)
    silo_table = []
    for silo in silos:
        mineral = Type.objects.get(typeID = silo.eve_type_id)
        if pos.fuel_type_id == constants.GALLENTE_FUEL_BLOCK_TYPEID:
            remaining_vol = (constants.SILO_VOLUME * 2.0) - silo.volume
            remaining_per = int((1.0 * silo.volume / (constants.SILO_VOLUME * 2.0)) * 100)
        elif pos.fuel_type_id == constants.AMARR_FUEL_BLOCK_TYPEID:
            remaining_vol = (constants.SILO_VOLUME * 1.5) - silo.volume
            remaining_per = int((1.0 * silo.volume / (constants.SILO_VOLUME * 1.5)) * 100)
        else:
            remaining_vol = constants.SILO_VOLUME - silo.volume
            remaining_per = int((1.0 * silo.volume / (constants.SILO_VOLUME)) * 100)
        if mineral.typeID in constants.COMPLEX_REACTIONS:
            hours_to_full = remaining_vol / (mineral.volume * constants.COMPLEX_REACTIONS[mineral.typeID])
        elif mineral.typeID in constants.SIMPLE_REACTIONS:
            hours_to_full = remaining_vol / (mineral.volume * 200)
        elif mineral.typeID in constants.UNREFINED:
            hours_to_full = remaining_vol / (mineral.volume * 1)
        else:
            hours_to_full = remaining_vol / (mineral.volume * 100)

        silo_div = '<div class="progress"><div class="bar" style="width: '
        silo_div += str(remaining_per)+'%;"><span style="color:black;">'
        silo_div += print_duration(seconds=hours_to_full * 3600, verbose=False)
        silo_div += '</span></div></div>'
        silo_table.append([
            silo.eve_type_id,
            mineral.typeName,
            silo.quantity,
            silo_div,
            #print_duration(seconds=hours_to_full * 3600, verbose=False)
        ])
    silo_count = silos.count()
    json_data = {
        "sEcho"                 : params.sEcho,
        "iTotalRecords"         : silo_count,
        "iTotalDisplayRecords"  : silo_count,
        "aaData"                : silo_table,
    }
    return HttpResponse(json.dumps(json_data))
Esempio n. 3
0
def fuel_data(request, pos_id):
    try:
        params = extract_datatable_params(request)
        pos_id = int(pos_id)
    except:
        return HttpResponseBadRequest()

    pos = get_object_or_404(POS, item_id=pos_id)

    fuelTypeIDs = (
        pos.fuel_type_id,
        constants.STRONTIUM_CLATHRATES_TYPEID,
    )

    fuelTable = []
    for type_id in fuelTypeIDs:
        try:
            fuel = pos.fuel_levels.filter(type_id=type_id).latest()
            quantity = fuel.current_fuel()
            consumption = fuel.consumption
        except FuelLevel.DoesNotExist:
            quantity = 0
            consumption = 0
        if consumption == 0:
            timeLeft = '-'
        else:
            hoursLeft = int(quantity / consumption)
            timeLeft = print_duration(seconds=hoursLeft * 3600, verbose=False)

        fuelTable.append([
            type_id,
            Type.objects.get(typeID=type_id).typeName,
            print_fuel_quantity(quantity),
            '%d / hour' % consumption,
            '%d / day' % (consumption * 24),
            timeLeft,
        ])

    json_data = {
        "sEcho": params.sEcho,
        "iTotalRecords": len(fuelTypeIDs),
        "iTotalDisplayRecords": len(fuelTypeIDs),
        "aaData": fuelTable
    }
    return HttpResponse(json.dumps(json_data))
Esempio n. 4
0
def fuel_data(request, pos_id):
    try:
        params = extract_datatable_params(request)
        pos_id = int(pos_id)
    except:
        return HttpResponseBadRequest()

    pos = get_object_or_404(POS, item_id=pos_id)

    fuelTypeIDs = (
        pos.fuel_type_id,
        constants.STRONTIUM_CLATHRATES_TYPEID,
    )

    fuelTable = []
    for type_id in fuelTypeIDs:
        try:
            fuel = pos.fuel_levels.filter(type_id=type_id).latest()
            quantity = fuel.current_fuel()
            consumption = fuel.consumption
        except FuelLevel.DoesNotExist:
            quantity = 0
            consumption = 0
        if consumption == 0:
            timeLeft = '-'
        else:
            hoursLeft = int(quantity / consumption)
            timeLeft = print_duration(seconds=hoursLeft * 3600, verbose=False)

        fuelTable.append([
            type_id,
            Type.objects.get(typeID=type_id).typeName,
            print_fuel_quantity(quantity),
            '%d / hour' % consumption,
            '%d / day' % (consumption * 24),
            timeLeft,
        ])

    json_data = {
        "sEcho" : params.sEcho,
        "iTotalRecords" : len(fuelTypeIDs),
        "iTotalDisplayRecords" : len(fuelTypeIDs),
        "aaData" : fuelTable
    }
    return HttpResponse(json.dumps(json_data))
Esempio n. 5
0
def getFuelValue(pos, fuelTypeID, displayMode):
    try:
        fuel = pos.fuel_levels.filter(type_id=fuelTypeID).latest()
        quantity = fuel.current_fuel()
        consumption = fuel.consumption
    except FuelLevel.DoesNotExist:
        quantity = 0
        consumption = 0
    if displayMode == 'quantities':
        value = print_fuel_quantity(quantity)
    else:
        if consumption == 0:
            value = '-'
        else:
            hoursLeft = int(quantity / consumption)

            if displayMode == 'hours':
                value = '%dh' % hoursLeft
            elif displayMode == 'hours_int':
                value = hoursLeft
            else:
                value = print_duration(seconds=hoursLeft * 3600, verbose=False)
    return value
Esempio n. 6
0
        query = query.filter(assignee=request.user)
    elif assignment == 'unassigned':
        query = query.filter(assignee__isnull=True)

    if params.search:
        matching_items = Type.objects.filter(typeName__icontains=params.search)
        matching_ids = list(matching_items.values_list('typeID', flat=True)[:100])
        search_args = Q(assignee__username__icontains=params.search)
        search_args |= Q(item_id__in=matching_ids)
        query = query.filter(search_args).distinct()

    filtered = query.count()
    data = []
    for job in query[params.first_id:params.last_id]:
        if job.duration:
            duration = print_duration(job.duration, verbose=False)
        else:
            duration = '-'
        activity_icon = '<img src="%sindustry/img/%s.png" title="%s"/>' % (settings.STATIC_URL,
                                                                           job.activity_text.lower(),
                                                                           job.activity_text)
        data.append([
            'Job #%d' % job.id,
            job.state,
            job.id,
            job.order.permalink(shop=False),
            job.assignee_permalink(),
            duration,
            activity_icon,
            print_integer(round(job.runs)),
            job.item.typeName,
Esempio n. 7
0
    elif assignment == 'unassigned':
        query = query.filter(assignee__isnull=True)

    if params.search:
        matching_items = Type.objects.filter(typeName__icontains=params.search)
        matching_ids = list(
            matching_items.values_list('typeID', flat=True)[:100])
        search_args = Q(assignee__username__icontains=params.search)
        search_args |= Q(item_id__in=matching_ids)
        query = query.filter(search_args).distinct()

    filtered = query.count()
    data = []
    for job in query[params.first_id:params.last_id]:
        if job.duration:
            duration = print_duration(job.duration, verbose=False)
        else:
            duration = '-'
        activity_icon = '<img src="%sindustry/img/%s.png" title="%s"/>' % (
            settings.STATIC_URL, job.activity_text.lower(), job.activity_text)
        data.append([
            'Job #%d' % job.id,
            job.state,
            job.id,
            job.order.permalink(shop=False),
            job.assignee_permalink(),
            duration,
            activity_icon,
            print_integer(round(job.runs)),
            job.item.typeName,
        ])
Esempio n. 8
0
            print_integer(mat.quantity),
        ])

    return datatable_ajax_data(data=mat_table, echo=params.sEcho)

#------------------------------------------------------------------------------
@check_user_access()
def manufacturing_time(request, blueprint_id):
    """
    Serves URL /industry/catalog/blueprint/<blueprint_id>/time/
    """
    try:
        bp = get_object_or_404(OwnedBlueprint, id=int(blueprint_id))
    except (KeyError, ValueError), e:
        raise HttpResponseBadRequest(str(e))
    duration = print_duration(bp.manufacturing_time())
    return HttpResponse(duration)




#------------------------------------------------------------------------------
@check_user_access()
def delete(request, blueprint_id):
    """
    Serves URL /industry/catalog/blueprints/<blueprint_id>/delete/
    """
    try:
        blueprint_id = int(blueprint_id)
        bp = get_object_or_404(OwnedBlueprint, id=blueprint_id)
    except ValueError:
Esempio n. 9
0
        ])

    return datatable_ajax_data(data=mat_table, echo=params.sEcho)


#------------------------------------------------------------------------------
@check_user_access()
def manufacturing_time(request, blueprint_id):
    """
    Serves URL /industry/catalog/blueprint/<blueprint_id>/time/
    """
    try:
        bp = get_object_or_404(OwnedBlueprint, id=int(blueprint_id))
    except (KeyError, ValueError), e:
        raise HttpResponseBadRequest(str(e))
    duration = print_duration(bp.manufacturing_time())
    return HttpResponse(duration)


#------------------------------------------------------------------------------
@check_user_access()
def delete(request, blueprint_id):
    """
    Serves URL /industry/catalog/blueprints/<blueprint_id>/delete/
    """
    try:
        blueprint_id = int(blueprint_id)
        bp = get_object_or_404(OwnedBlueprint, id=blueprint_id)
    except ValueError:
        raise Http404()
    bp.delete()
Esempio n. 10
0
def ecm_duration_long(value):
    try:
        return unicode(print_duration(value))
    except:
        return unicode(value)