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))
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))
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))
def index(): form1 = TimerForm(request.form) if request.method == 'POST' and form1.validate(): global time_start, time_end, job_day_min, slots_nr time_start = form1.time_start.data time_end = form1.time_end.data job_day_min = convert_time_into_min(time_end) - convert_time_into_min( time_start) slots_nr = job_day_min // 15 return redirect(url_for('timer')) return render_template('first_page.html', form=form1)
def edit_timer(request, timer_id): logger.debug("edit_timer called by user %s for timer id %s" % (request.user, timer_id)) timer = get_object_or_404(Timer, id=timer_id) if request.method == 'POST': form = TimerForm(request.POST) logger.debug("Received POST request containing updated timer 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) corporation = EveManager.get_corporation_info_by_id(character.corporation_id) logger.debug("Determined timer edit 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 = datetime.datetime.utcnow() 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)) 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 logger.info("User %s updating timer id %s " % (request.user, timer_id)) timer.save() logger.debug("Detected no changes between timer id %s and supplied form." % timer_id) return HttpResponseRedirect("/timers/") else: current_time = timezone.now() td = timer.eve_time - current_time tddays, tdhours, tdminutes = td.days, td.seconds // 3600, td.seconds // 60 % 60 data = { 'details': timer.details, 'system': timer.system, 'planet_moon': timer.planet_moon, 'structure': timer.structure, 'objective': timer.objective, 'important': timer.important, 'corp_timer': timer.corp_timer, 'days_left': tddays, 'hours_left': tdhours, 'minutes_left': tdminutes, } form = TimerForm(initial= data) return render_to_response('registered/timerupdate.html', {'form':form}, context_instance=RequestContext(request))
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))
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))
def edit_timer(request, timer_id): logger.debug("edit_timer called by user %s for timer id %s" % (request.user, timer_id)) timer = get_object_or_404(Timer, id=timer_id) if request.method == 'POST': form = TimerForm(request.POST) logger.debug( "Received POST request containing updated timer 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) corporation = EveManager.get_corporation_info_by_id( character.corporation_id) logger.debug( "Determined timer edit 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 = datetime.datetime.utcnow() 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)) 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 logger.info("User %s updating timer id %s " % (request.user, timer_id)) timer.save() logger.debug( "Detected no changes between timer id %s and supplied form." % timer_id) return HttpResponseRedirect("/timers/") else: current_time = timezone.now() td = timer.eve_time - current_time tddays, tdhours, tdminutes = td.days, td.seconds // 3600, td.seconds // 60 % 60 data = { 'details': timer.details, 'system': timer.system, 'planet_moon': timer.planet_moon, 'structure': timer.structure, 'objective': timer.objective, 'important': timer.important, 'corp_timer': timer.corp_timer, 'days_left': tddays, 'hours_left': tdhours, 'minutes_left': tdminutes, } form = TimerForm(initial=data) return render_to_response('registered/timerupdate.html', {'form': form}, context_instance=RequestContext(request))