コード例 #1
0
ファイル: views.py プロジェクト: yokozuna/eve-wspace
def destination_list(request, map_id, ms_id):
    """
    Returns the destinations of interest tuple for K-space systems and
    a blank response for w-space systems.
    """
    if not request.is_ajax():
        raise PermissionDenied
    destinations = Destination.objects.filter(
        Q(user=None) | Q(user=request.user))
    map_system = get_object_or_404(MapSystem, pk=ms_id)
    try:
        system = KSystem.objects.get(pk=map_system.system.pk)
        rf = utils.RouteFinder()
        result = []
        for destination in destinations:
            result.append((
                destination.system,
                rf.route_length(system, destination.system) - 1,
                round(rf.ly_distance(system, destination.system), 3),
            ))
    except ObjectDoesNotExist:
        return HttpResponse()
    return render(request, 'system_destinations.html', {
        'system': system,
        'destinations': _sort_destinations(result)
    })
コード例 #2
0
ファイル: models.py プロジェクト: viarr/eve-wspace
 def distance(self, destination):
     """
     Returns the light-year distance to the destination.
     """
     return utils.RouteFinder().ly_distance(self, destination)
コード例 #3
0
ファイル: models.py プロジェクト: viarr/eve-wspace
 def jumps_to(self, destination):
     """
     Returns the number of gate jumps to the destination by shortest route.
     """
     return utils.RouteFinder().route_length(self, destination)