Пример #1
0
def add_timer_view(request):
    if request.method == 'POST':
        form = TimerForm(request.POST)

        if form.is_valid():
            # Get character
            auth_info = AuthServicesInfoManager.get_auth_service_info(request.user)
            character = EveManager.get_character_by_id(auth_info.main_char_id)
            corporation = EveManager.get_corporation_info_by_id(character.corporation_id)

            # calculate future time
            future_time = datetime.timedelta(days=form.cleaned_data['days_left'], hours=form.cleaned_data['hours_left'], minutes=form.cleaned_data['minutes_left'])
            current_time = datetime.datetime.utcnow()
            eve_time = current_time + future_time

            # handle valid form
            timer = Timer()
            timer.details = form.cleaned_data['details']
            timer.system = form.cleaned_data['system']
            timer.planet_moon = form.cleaned_data['planet_moon']
            timer.structure = form.cleaned_data['structure']
            timer.objective = form.cleaned_data['objective']
            timer.eve_time = eve_time
            timer.important = form.cleaned_data['important']
            timer.eve_character = character
            timer.eve_corp = corporation
            timer.user = request.user
            timer.save()
            return HttpResponseRedirect("/timers/")
    else:
        form = TimerForm()

    render_items = {'form': form}

    return render_to_response('registered/addtimer.html', render_items, context_instance=RequestContext(request))
Пример #2
0
def add_timer_view(request):
    if request.method == 'POST':
        form = TimerForm(request.POST)

        if form.is_valid():
            # Get character
            auth_info = AuthServicesInfoManager.get_auth_service_info(request.user)
            character = EveManager.get_character_by_id(auth_info.main_char_id)
            corporation = EveManager.get_corporation_info_by_id(character.corporation_id)

            # handle valid form
            timer = Timer()
            timer.name = form.cleaned_data['name']
            timer.system = form.cleaned_data['system']
            timer.planet_moon = form.cleaned_data['planet_moon']
            timer.structure = form.cleaned_data['structure']
            timer.fleet_type = form.cleaned_data['fleet_type']
            timer.eve_time = form.cleaned_data['eve_time']
            timer.important = form.cleaned_data['important']
            timer.eve_character = character
            timer.eve_corp = corporation
            timer.user = request.user
            timer.save()
            return HttpResponseRedirect("/timers/")
    else:
        form = TimerForm()

    render_items = {'form': form}

    return render_to_response('registered/addtimer.html', render_items, context_instance=RequestContext(request))
Пример #3
0
def add_timer_view(request):
    if request.method == 'POST':
        form = TimerForm(request.POST)

        if form.is_valid():
            # Get character
            auth_info = AuthServicesInfoManager.get_auth_service_info(
                request.user)
            character = EveManager.get_character_by_id(auth_info.main_char_id)
            corporation = EveManager.get_corporation_info_by_id(
                character.corporation_id)

            # handle valid form
            timer = Timer()
            timer.name = form.cleaned_data['name']
            timer.system = form.cleaned_data['system']
            timer.planet_moon = form.cleaned_data['planet_moon']
            timer.structure = form.cleaned_data['structure']
            timer.fleet_type = form.cleaned_data['fleet_type']
            timer.eve_time = form.cleaned_data['eve_time']
            timer.important = form.cleaned_data['important']
            timer.eve_character = character
            timer.eve_corp = corporation
            timer.user = request.user
            timer.save()
            return HttpResponseRedirect("/timers/")
    else:
        form = TimerForm()

    render_items = {'form': form}

    return render_to_response('registered/addtimer.html',
                              render_items,
                              context_instance=RequestContext(request))
Пример #4
0
def add_timer_view(request):
    logger.debug("add_timer_view called by user %s" % request.user)
    if request.method == 'POST':
        form = TimerForm(request.POST)
        logger.debug("Request type POST contains form valid: %s" %
                     form.is_valid())
        if form.is_valid():
            # Get character
            auth_info = AuthServicesInfoManager.get_auth_service_info(
                request.user)
            character = EveManager.get_character_by_id(auth_info.main_char_id)
            corporation = EveManager.get_corporation_info_by_id(
                character.corporation_id)
            logger.debug(
                "Determined timer add request on behalf of character %s corporation %s"
                % (character, corporation))
            # calculate future time
            future_time = datetime.timedelta(
                days=form.cleaned_data['days_left'],
                hours=form.cleaned_data['hours_left'],
                minutes=form.cleaned_data['minutes_left'])
            current_time = timezone.now()
            eve_time = current_time + future_time
            logger.debug(
                "Determined timer eve time is %s - current time %s, adding %s"
                % (eve_time, current_time, future_time))
            # handle valid form
            timer = Timer()
            timer.details = form.cleaned_data['details']
            timer.system = form.cleaned_data['system']
            timer.planet_moon = form.cleaned_data['planet_moon']
            timer.structure = form.cleaned_data['structure']
            timer.objective = form.cleaned_data['objective']
            timer.eve_time = eve_time
            timer.important = form.cleaned_data['important']
            timer.corp_timer = form.cleaned_data['corp_timer']
            timer.eve_character = character
            timer.eve_corp = corporation
            timer.user = request.user
            timer.save()
            logger.info("Created new timer in %s at %s by user %s" %
                        (timer.system, timer.eve_time, request.user))
            return HttpResponseRedirect("/timers/")
    else:
        logger.debug("Returning new TimerForm")
        form = TimerForm()

    render_items = {'form': form}

    return render_to_response('registered/addtimer.html',
                              render_items,
                              context_instance=RequestContext(request))
Пример #5
0
def add_timer_view(request):
    logger.debug("add_timer_view called by user %s" % request.user)
    if request.method == 'POST':
        form = TimerForm(request.POST)
        logger.debug("Request type POST contains form valid: %s" % form.is_valid())
        if form.is_valid():
            # Get character
            auth_info = AuthServicesInfoManager.get_auth_service_info(request.user)
            character = EveManager.get_character_by_id(auth_info.main_char_id)
            corporation = EveManager.get_corporation_info_by_id(character.corporation_id)
            logger.debug("Determined timer add request on behalf of character %s corporation %s" % (character, corporation))
            # calculate future time
            future_time = datetime.timedelta(days=form.cleaned_data['days_left'], hours=form.cleaned_data['hours_left'], minutes=form.cleaned_data['minutes_left'])
            current_time = timezone.now()
            eve_time = current_time + future_time
            logger.debug("Determined timer eve time is %s - current time %s, adding %s" % (eve_time, current_time, future_time))
            # handle valid form
            timer = Timer()
            timer.details = form.cleaned_data['details']
            timer.system = form.cleaned_data['system']
            timer.planet_moon = form.cleaned_data['planet_moon']
            timer.structure = form.cleaned_data['structure']
            timer.objective = form.cleaned_data['objective']
            timer.eve_time = eve_time
            timer.important = form.cleaned_data['important']
            timer.corp_timer = form.cleaned_data['corp_timer']
            timer.eve_character = character
            timer.eve_corp = corporation
            timer.user = request.user
            timer.save()
            logger.info("Created new timer in %s at %s by user %s" % (timer.system, timer.eve_time, request.user))
            return HttpResponseRedirect("/timers/")
    else:
        logger.debug("Returning new TimerForm")
        form = TimerForm()

    render_items = {'form': form}

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