def add_optimer_view(request): logger.debug("add_optimer_view called by user %s" % request.user) if request.method == 'POST': form = opForm(request.POST) logger.debug("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 op = optimer() op.doctrine = form.cleaned_data['doctrine'] op.system = form.cleaned_data['system'] op.location = form.cleaned_data['location'] op.start = form.cleaned_data['start'] op.duration = form.cleaned_data['duration'] op.operation_name = form.cleaned_data['operation_name'] op.fc = form.cleaned_data['fc'] op.details = form.cleaned_data['details'] op.create_time = post_time op.eve_character = character op.save() logger.info("User %s created op timer with name %s" % (request.user, op.operation_name)) return HttpResponseRedirect("/optimer/") else: logger.debug("Returning new opForm") form = opForm() render_items = {'form': form} return render_to_response('registered/addoperation.html', render_items, context_instance=RequestContext(request))
def edit_optimer(request, optimer_id): logger.debug("edit_optimer called by user %s for optimer id %s" % (request.user, optimer_id)) op = get_object_or_404(optimer, id=optimer_id) if request.method == 'POST': form = opForm(request.POST) logger.debug("Received POST request containing update optimer form, is valid: %s" % form.is_valid()) if form.is_valid(): character = EVECharacter.objects.get(user=request.user).name op.doctrine = form.cleaned_data['doctrine'] op.system = form.cleaned_data['system'] op.location = form.cleaned_data['location'] op.start = form.cleaned_data['start'] op.duration = form.cleaned_data['duration'] op.operation_name = form.cleaned_data['operation_name'] op.fc = form.cleaned_data['fc'] op.details = form.cleaned_data['details'] op.eve_character = character logger.info("User %s updating optimer id %s " % (request.user, optimer_id)) op.save() logger.debug("Detected no changes between optimer id %s and supplied form." % optimer_id) return HttpResponseRedirect("/optimer/") else: data = { 'doctrine': op.doctrine, 'system': op.system, 'location': op.location, 'start': op.start, 'duration': op.duration, 'operation_name': op.operation_name, 'fc': op.fc, 'details': op.details, } form = opForm(initial=data) return render_to_response('registered/services/optimer/admin/optimerupdate.html', {'form':form}, context_instance=RequestContext(request))
def edit_optimer(request, optimer_id): logger.debug("edit_optimer called by user %s for optimer id %s" % (request.user, optimer_id)) op = get_object_or_404(optimer, id=optimer_id) if request.method == 'POST': form = opForm(request.POST) logger.debug( "Received POST request containing update optimer 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) op.doctrine = form.cleaned_data['doctrine'] op.system = form.cleaned_data['system'] op.location = form.cleaned_data['location'] op.start = form.cleaned_data['start'] op.duration = form.cleaned_data['duration'] op.operation_name = form.cleaned_data['operation_name'] op.fc = form.cleaned_data['fc'] op.details = form.cleaned_data['details'] op.eve_character = character logger.info("User %s updating optimer id %s " % (request.user, optimer_id)) op.save() logger.debug( "Detected no changes between optimer id %s and supplied form." % optimer_id) return HttpResponseRedirect("/optimer/") else: data = { 'doctrine': op.doctrine, 'system': op.system, 'location': op.location, 'start': op.start, 'duration': op.duration, 'operation_name': op.operation_name, 'fc': op.fc, 'details': op.details, } form = opForm(initial=data) return render_to_response('registered/optimerupdate.html', {'form': form}, context_instance=RequestContext(request))
def add_optimer_view(request): logger.debug("add_optimer_view called by user %s" % request.user) if request.method == 'POST': form = opForm(request.POST) logger.debug("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 op = optimer() op.doctrine = form.cleaned_data['doctrine'] op.system = form.cleaned_data['system'] op.location = form.cleaned_data['location'] op.start = form.cleaned_data['start'] op.duration = form.cleaned_data['duration'] op.operation_name = form.cleaned_data['operation_name'] op.fc = form.cleaned_data['fc'] op.details = form.cleaned_data['details'] op.create_time = post_time op.eve_character = character op.save() logger.info("User %s created op timer with name %s" % (request.user, op.operation_name)) return HttpResponseRedirect("/optimer/") else: logger.debug("Returning new opForm") form = opForm() render_items = {'form': form} return render_to_response('registered/addoperation.html', render_items, context_instance=RequestContext(request))