示例#1
0
def edit_signature(request, sigtracker_id):
    logger.debug("edit_optimer called by user %s for optimer id %s" % (request.user, sigtracker_id))
    sig = get_object_or_404(sigtracker, id=sigtracker_id)
    if request.method == 'POST':
        form = SignatureForm(request.POST)
        logger.debug("Received POST request containing update sigtracker form, is valid: %s" % form.is_valid())
        if form.is_valid():
            auth_info = AuthServicesInfoManager.get_auth_service_info(request.user)
            character = EveManager.get_character_by_id(auth_info.main_char_id)
            sig.ident = form.cleaned_data['ident']
            sig.system = form.cleaned_data['system']
            sig.destination = form.cleaned_data['destination']
            sig.sigtype = form.cleaned_data['sigtype']
            sig.status = form.cleaned_data['status']
            sig.notes = form.cleaned_data['notes']
            sig.eve_character = character
            logger.info("User %s updating sigtracker id %s " % (request.user, sigtracker_id))
            sig.save()

        logger.debug("Detected no changes between sigtracker id %s and supplied form." % sigtracker_id)
        return HttpResponseRedirect("/sigtracker/")
    else:
        data = {
            'ident': sig.ident,
            'system': sig.system,
            'destination': sig.destination,
            'sigtype': sig.sigtype,
            'status': sig.status,
            'notes': sig.notes,
        }
        form = SignatureForm(initial= data)
    return render_to_response('registered/signatureupdate.html', {'form':form}, context_instance=RequestContext(request))
示例#2
0
def add_signature_view(request):
    logger.info("add_signature_view called by user %s" % request.user)
    if request.method == 'POST':
    	form = SignatureForm(request.POST)
	logger.info("Request type POST contains form valid: %s" % form.is_valid())
        if form.is_valid():
            #Get Current Time
            post_time = timezone.now()
            # Get character
            auth_info = AuthServicesInfoManager.get_auth_service_info(request.user)
            character = EveManager.get_character_by_id(auth_info.main_char_id)
            # handle valid form
            sig = sigtracker()
            sig.ident = form.cleaned_data['ident']
            sig.system = form.cleaned_data['system']
            sig.destination = form.cleaned_data['destination']
            sig.sigtype = form.cleaned_data['sigtype']
            sig.status = form.cleaned_data['status']
            sig.notes = form.cleaned_data['notes']
            sig.create_time = post_time
            sig.eve_character = character
            sig.save()
            return HttpResponseRedirect("/sigtracker/")
    else:
        logger.info("Returning new SignatureForm")
        form = SignatureForm()

    render_items = {'form': form}

    return render_to_response('registered/addsignature.html', render_items, context_instance=RequestContext(request))
示例#3
0
def add_signature_view(request):
    logger.info("add_signature_view called by user %s" % request.user)
    if request.method == 'POST':
        form = SignatureForm(request.POST)
        logger.info("Request type POST contains form valid: %s" %
                    form.is_valid())
        if form.is_valid():
            #Get Current Time
            post_time = timezone.now()
            # Get character
            auth_info = AuthServicesInfoManager.get_auth_service_info(
                request.user)
            character = EveManager.get_character_by_id(auth_info.main_char_id)
            # handle valid form
            sig = sigtracker()
            sig.ident = form.cleaned_data['ident']
            sig.system = form.cleaned_data['system']
            sig.destination = form.cleaned_data['destination']
            sig.sigtype = form.cleaned_data['sigtype']
            sig.status = form.cleaned_data['status']
            sig.notes = form.cleaned_data['notes']
            sig.create_time = post_time
            sig.eve_character = character
            sig.save()
            return HttpResponseRedirect("/sigtracker/")
    else:
        logger.info("Returning new SignatureForm")
        form = SignatureForm()

    render_items = {'form': form}

    return render_to_response('registered/addsignature.html',
                              render_items,
                              context_instance=RequestContext(request))
示例#4
0
def edit_signature(request, sigtracker_id):
    logger.debug("edit_optimer called by user %s for optimer id %s" %
                 (request.user, sigtracker_id))
    sig = get_object_or_404(sigtracker, id=sigtracker_id)
    if request.method == 'POST':
        form = SignatureForm(request.POST)
        logger.debug(
            "Received POST request containing update sigtracker form, is valid: %s"
            % form.is_valid())
        if form.is_valid():
            auth_info = AuthServicesInfoManager.get_auth_service_info(
                request.user)
            character = EveManager.get_character_by_id(auth_info.main_char_id)
            sig.ident = form.cleaned_data['ident']
            sig.system = form.cleaned_data['system']
            sig.destination = form.cleaned_data['destination']
            sig.lifetime_status = form.cleaned_data['lifetime_status']
            sig.mass_status = form.cleaned_data['mass_status']
            sig.ships_size = form.cleaned_data['ships_size']
            sig.through_dest = form.cleaned_data['through_dest']
            sig.notes = form.cleaned_data['notes']
            sig.eve_character = character
            logger.info("User %s updating sigtracker id %s " %
                        (request.user, sigtracker_id))
            sig.save()

        logger.debug(
            "Detected no changes between sigtracker id %s and supplied form." %
            sigtracker_id)
        return HttpResponseRedirect("/sigtracker/")
    else:
        data = {
            'ident': sig.ident,
            'system': sig.system,
            'destination': sig.destination,
            'lifetime_status': sig.lifetime_status,
            'mass_status': sig.mass_status,
            'ships_size': sig.ships_size,
            'through_dest': sig.through_dest,
            'notes': sig.notes,
        }
        form = SignatureForm(initial=data)
    return render_to_response('registered/signatureupdate.html',
                              {'form': form},
                              context_instance=RequestContext(request))