Exemple #1
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))
    completed = False
    no_srp_code = False

    if SrpFleetMain.objects.filter(fleet_srp_code=fleet_srp).exists() is False:
        no_srp_code = True
        logger.error("Unable to locate SRP Fleet using code %s for user %s" % (fleet_srp, request.user))

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

        if form.is_valid():
            authinfo = AuthServicesInfo.objects.get_or_create(user=request.user)[0]
            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_status = "Pending"

            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
            srp_request.srp_status = srp_status

            try:
                srp_kill_link = srpManager.get_kill_id(srp_request.killboard_link)
                (srp_kill_data, ship_value) = 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")
            srp_ship_name = srpManager.get_ship_name(srp_kill_data)
            srp_request.srp_ship_name = srp_ship_name
            kb_total_loss = ship_value
            srp_request.kb_total_loss = kb_total_loss
            srp_request.post_time = post_time
            srp_request.save()
            completed = True
            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 %s.' % srp_ship_name)

    else:
        logger.debug("Returning blank SrpFleetUserRequestForm")
        form = SrpFleetUserRequestForm()

    render_items = {'form': form, "completed": completed, "no_srp_code": no_srp_code}

    return render(request, 'registered/srpfleetrequest.html', context=render_items)
Exemple #2
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))
    completed = False
    no_srp_code = False

    if SrpFleetMain.objects.filter(fleet_srp_code=fleet_srp).exists() is False:
        no_srp_code = True
        logger.error("Unable to locate SRP Fleet using code %s for user %s" % (fleet_srp, request.user))

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

        if form.is_valid():
            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) = 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")
            srp_ship_name = EveManager.get_itemtype(ship_type_id).name
            srp_request.srp_ship_name = srp_ship_name
            kb_total_loss = ship_value
            srp_request.kb_total_loss = kb_total_loss
            srp_request.post_time = post_time
            srp_request.save()
            completed = True
            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_ship_name})

    else:
        logger.debug("Returning blank SrpFleetUserRequestForm")
        form = SrpFleetUserRequestForm()

    render_items = {'form': form, "completed": completed, "no_srp_code": no_srp_code}

    return render(request, 'registered/srpfleetrequest.html', context=render_items)
Exemple #3
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))
    completed = False
    no_srp_code = False
    srp_code = ""

    if SrpFleetMain.objects.filter(fleet_srp_code=fleet_srp).exists() is False:
        no_srp_code = True
        logger.error("Unable to locate SRP Fleet using code %s for user %s" % (fleet_srp, request.user))

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

        if form.is_valid():
            authinfo = AuthServicesInfoManager.get_auth_service_info(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_status = "Pending"

            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
            srp_request.srp_status = srp_status

            try:
                srp_kill_link = srpManager.get_kill_id(srp_request.killboard_link)
                (srp_kill_data, ship_value) = 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))
                notify(request.user, "Your SRP request Killmail Link Failed Validation", message="Your SRP request Killmail link %s is invalid. Please make sure your using zKillboard." % srp_request.killboard_link, level="danger")
                return HttpResponseRedirect("/srp")
            srp_ship_name = srpManager.get_ship_name(srp_kill_data)
            srp_request.srp_ship_name = srp_ship_name
            kb_total_loss = ship_value
            srp_request.kb_total_loss = kb_total_loss
            srp_request.post_time = post_time
            srp_request.save()
            completed = True
            logger.info("Created SRP Request on behalf of user %s for fleet name %s" % (request.user, srp_fleet_main.fleet_name))

    else:
        logger.debug("Returning blank SrpFleetUserRequestForm")
        form = SrpFleetUserRequestForm()

    render_items = {'form': form, "completed": completed, "no_srp_code": no_srp_code}

    return render_to_response('registered/srpfleetrequest.html', render_items, context_instance=RequestContext(request))
Exemple #4
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 #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))
    completed = False
    no_srp_code = False
    srp_code = ""

    if SrpFleetMain.objects.filter(fleet_srp_code=fleet_srp).exists() is False:
        no_srp_code = True
        logger.error("Unable to locate SRP Fleet using code %s for user %s" % (fleet_srp, request.user))

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

        if form.is_valid():
            authinfo = AuthServicesInfoManager.get_auth_service_info(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_status = "Pending"

            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
            srp_request.srp_status = srp_status

            try:
                srp_kill_link = srpManager.get_kill_id(srp_request.killboard_link)
                (srp_kill_data, ship_value) = 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)
                )
                notify(
                    request.user,
                    "Your SRP request Killmail Link Failed Validation",
                    message="Your SRP request Killmail link %s is invalid. Please make sure your using zKillboard."
                    % srp_request.killboard_link,
                    level="danger",
                )
                return HttpResponseRedirect("/srp")
            srp_ship_name = srpManager.get_ship_name(srp_kill_data)
            srp_request.srp_ship_name = srp_ship_name
            kb_total_loss = ship_value
            srp_request.kb_total_loss = kb_total_loss
            srp_request.post_time = post_time
            srp_request.save()
            completed = True
            logger.info(
                "Created SRP Request on behalf of user %s for fleet name %s" % (request.user, srp_fleet_main.fleet_name)
            )

    else:
        logger.debug("Returning blank SrpFleetUserRequestForm")
        form = SrpFleetUserRequestForm()

    render_items = {"form": form, "completed": completed, "no_srp_code": no_srp_code}

    return render_to_response("registered/srpfleetrequest.html", render_items, context_instance=RequestContext(request))
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)