Exemplo n.º 1
0
def srp_fleet_edit_view(request, fleet_id):
    no_fleet_id = False
    form = None
    if SrpFleetMain.objects.filter(id=fleet_id).exists():
        if request.method == 'POST':
            form = SrpFleetMainUpdateForm(request.POST)
            if form.is_valid():
                srpfleetmain = SrpFleetMain.objects.get(id=fleet_id)
                srpfleetmain.fleet_srp_aar_link = form.cleaned_data['fleet_aar_link']
                srpfleetmain.save()
                return HttpResponseRedirect("/srp")
        else:
            form = SrpFleetMainUpdateForm()
    else:
        no_fleet_id = True

    render_items = {'form': form, "no_fleet_id": no_fleet_id}

    return render_to_response('registered/srpfleetupdate.html', render_items,
                              context_instance=RequestContext(request))
Exemplo n.º 2
0
def srp_fleet_edit_view(request, fleet_id):
    logger.debug("srp_fleet_edit_view called by user %s for fleet id %s" % (request.user, fleet_id))
    no_fleet_id = False
    form = None
    if SrpFleetMain.objects.filter(id=fleet_id).exists():
        if request.method == 'POST':
            form = SrpFleetMainUpdateForm(request.POST)
            logger.debug("Request type POST contains form valid: %s" % form.is_valid())
            if form.is_valid():
                srpfleetmain = SrpFleetMain.objects.get(id=fleet_id)
                srpfleetmain.fleet_srp_aar_link = form.cleaned_data['fleet_aar_link']
                srpfleetmain.save()
                logger.info("User %s edited SRP Fleet %s" % (request.user, srpfleetmain.fleet_name))
                return HttpResponseRedirect("/srp")
        else:
            logger.debug("Returning blank SrpFleetMainUpdateForm")
            form = SrpFleetMainUpdateForm()
    else:
        logger.error("Unable to edit srp fleet id %s for user %s - fleet matching id not found." % (fleet_id, request.user))
        no_fleet_id = True

    render_items = {'form': form, "no_fleet_id": no_fleet_id}

    return render_to_response('registered/srpfleetupdate.html', render_items,
                              context_instance=RequestContext(request))