def srp_request_view(request, 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 if request.method == 'POST': form = SrpFleetUserRequestForm(request.POST) 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) 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.save() completed = True else: 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))
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 = request.user 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)) 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/services/srp/srpfleetrequest.html', render_items, context_instance=RequestContext(request))
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))
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) 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.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))