Exemple #1
0
def dashboard_view(request):
    render_items = {
        'characters': EveManager.get_characters_by_owner_id(request.user.id),
        'authinfo': AuthServicesInfoManager.get_auth_service_info(request.user)
    }
    return render_to_response('registered/dashboard.html',
                              render_items,
                              context_instance=RequestContext(request))
Exemple #2
0
def characters_view(request):
    logger.debug("characters_view called by user %s" % request.user)
    render_items = {
        'characters': EveManager.get_characters_by_owner_id(request.user.id),
        'authinfo':
        AuthServicesInfo.objects.get_or_create(user=request.user)[0]
    }
    return render(request, 'registered/characters.html', context=render_items)
Exemple #3
0
def dashboard_view(request):
    render_items = {'characters': EveManager.get_characters_by_owner_id(request.user.id),
                    'authinfo': AuthServicesInfoManager.get_auth_service_info(request.user)}
    return render_to_response('registered/dashboard.html', render_items, context_instance=RequestContext(request))
Exemple #4
0
def characters_view(request):
    logger.debug("characters_view called by user %s" % request.user)
    render_items = {'characters': EveManager.get_characters_by_owner_id(request.user.id),
                    'authinfo': AuthServicesInfo.objects.get_or_create(user=request.user)[0]}
    return render(request, 'registered/characters.html', context=render_items)
Exemple #5
0
def srp_request_view(request, fleet_srp):
    logger.debug("srp_request_view called by user %s for fleet srp code %s" %
                 (request.user, fleet_srp))

    if SrpFleetMain.objects.filter(fleet_srp_code=fleet_srp).exists() is False:
        logger.error("Unable to locate SRP Fleet using code %s for user %s" %
                     (fleet_srp, request.user))
        messages.error(
            request,
            _('Unable to locate SRP code with ID %(srpfleetid)s') %
            {"srpfleetid": fleet_srp})
        return redirect("auth_srp_management_view")

    if request.method == 'POST':
        form = SrpFleetUserRequestForm(request.POST)
        logger.debug("Request type POST contains form valid: %s" %
                     form.is_valid())

        if form.is_valid():
            if SrpUserRequest.objects.filter(
                    killboard_link=form.cleaned_data['killboard_link']).exists(
                    ):
                messages.error(
                    request, _("This Killboard link has already been posted."))
                return redirect("auth_srp_management_view")

            authinfo = AuthServicesInfo.objects.get(user=request.user)
            character = EveManager.get_character_by_id(authinfo.main_char_id)
            srp_fleet_main = SrpFleetMain.objects.get(fleet_srp_code=fleet_srp)
            post_time = timezone.now()

            srp_request = SrpUserRequest()
            srp_request.killboard_link = form.cleaned_data['killboard_link']
            srp_request.additional_info = form.cleaned_data['additional_info']
            srp_request.character = character
            srp_request.srp_fleet_main = srp_fleet_main

            try:
                srp_kill_link = srpManager.get_kill_id(
                    srp_request.killboard_link)
                (ship_type_id, ship_value,
                 victim_name) = srpManager.get_kill_data(srp_kill_link)
            except ValueError:
                logger.debug(
                    "User %s Submitted Invalid Killmail Link %s or server could not be reached"
                    % (request.user, srp_request.killboard_link))
                # THIS SHOULD BE IN FORM VALIDATION
                messages.error(
                    request,
                    _("Your SRP request Killmail link is invalid. Please make sure you are using zKillboard."
                      ))
                return redirect("auth_srp_management_view")

            characters = EveManager.get_characters_by_owner_id(request.user.id)
            for character in characters:
                if character.character_name == victim_name:
                    srp_request.srp_ship_name = EveManager.get_itemtype(
                        ship_type_id).name
                    srp_request.kb_total_loss = ship_value
                    srp_request.post_time = post_time
                    srp_request.save()
                    logger.info(
                        "Created SRP Request on behalf of user %s for fleet name %s"
                        % (request.user, srp_fleet_main.fleet_name))
                    messages.success(
                        request,
                        _('Submitted SRP request for your %(ship)s.') %
                        {"ship": srp_request.srp_ship_name})
                    return redirect("auth_srp_management_view")
                else:
                    continue
            messages.error(
                request,
                _("%(charname)s does not belong to your Auth account. Please add the API key for this character and try again"
                  ) % {"charname": victim_name})
            return redirect("auth_srp_management_view")
    else:
        logger.debug("Returning blank SrpFleetUserRequestForm")
        form = SrpFleetUserRequestForm()

    render_items = {'form': form}

    return render(request,
                  'registered/srpfleetrequest.html',
                  context=render_items)
Exemple #6
0
def srp_request_view(request, fleet_srp):
    logger.debug("srp_request_view called by user %s for fleet srp code %s" % (request.user, fleet_srp))

    if SrpFleetMain.objects.filter(fleet_srp_code=fleet_srp).exists() is False:
        logger.error("Unable to locate SRP Fleet using code %s for user %s" % (fleet_srp, request.user))
        messages.error(request, 
                       _('Unable to locate SRP code with ID %(srpfleetid)s') % {"srpfleetid": fleet_srp})
        return redirect("auth_srp_management_view")

    if request.method == 'POST':
        form = SrpFleetUserRequestForm(request.POST)
        logger.debug("Request type POST contains form valid: %s" % form.is_valid())

        if form.is_valid():
            if SrpUserRequest.objects.filter(killboard_link=form.cleaned_data['killboard_link']).exists():
                messages.error(request,
                               _("This Killboard link has already been posted."))
                return redirect("auth_srp_management_view")

            authinfo = AuthServicesInfo.objects.get(user=request.user)
            character = EveManager.get_character_by_id(authinfo.main_char_id)
            srp_fleet_main = SrpFleetMain.objects.get(fleet_srp_code=fleet_srp)
            post_time = timezone.now()

            srp_request = SrpUserRequest()
            srp_request.killboard_link = form.cleaned_data['killboard_link']
            srp_request.additional_info = form.cleaned_data['additional_info']
            srp_request.character = character
            srp_request.srp_fleet_main = srp_fleet_main

            try:
                srp_kill_link = srpManager.get_kill_id(srp_request.killboard_link)
                (ship_type_id, ship_value, victim_id) = srpManager.get_kill_data(srp_kill_link)
            except ValueError:
                logger.debug("User %s Submitted Invalid Killmail Link %s or server could not be reached" % (
                    request.user, srp_request.killboard_link))
                # THIS SHOULD BE IN FORM VALIDATION
                messages.error(request,
                               _("Your SRP request Killmail link is invalid. Please make sure you are using zKillboard."))
                return redirect("auth_srp_management_view")

            characters = EveManager.get_characters_by_owner_id(request.user.id)
            for character in characters:
                if character.character_id == str(victim_id):
                    srp_request.srp_ship_name = EveManager.get_itemtype(ship_type_id).name
                    srp_request.kb_total_loss = ship_value
                    srp_request.post_time = post_time
                    srp_request.save()
                    logger.info("Created SRP Request on behalf of user %s for fleet name %s" % (
                        request.user, srp_fleet_main.fleet_name))
                    messages.success(request, _('Submitted SRP request for your %(ship)s.') % {"ship": srp_request.srp_ship_name})
                    return redirect("auth_srp_management_view")
                else:
                    continue
            messages.error(request,
                           _("Character ID %(charid)s does not belong to your Auth account. Please add the API key for this character and try again")
                                % {"charid": victim_id})
            return redirect("auth_srp_management_view")
    else:
        logger.debug("Returning blank SrpFleetUserRequestForm")
        form = SrpFleetUserRequestForm()

    render_items = {'form': form}

    return render(request, 'registered/srpfleetrequest.html', context=render_items)