Пример #1
0
def create():

	TripForm = models.trip_form(request.form)

	if request.method=="POST" and TripForm.validate():
		app.logger.debug(request.form)
		
		newTrip  = models.Trip()
		newTrip.startdate = request.form.get('startdate')
		newTrip.enddate = request.form.get('enddate')
		newTrip.location = request.form.get('location')
		newTrip.reminder = request.form.get('reminder')
		newTrip.tripname = request.form.get('tripname')

		newTrip.user = current_user.get()

		try:
			newTrip.save()

		except:
			e = sys.exc_info()
			app.logger.error(e)
			
		return redirect('/create')

	else:
		templateData = {
			'allTrip' : models.Trip.objects(user=current_user.id),
			'current_user' : current_user,
			'form' : TripForm,
			'formType' : 'New'
		}	

	return render_template('create.html', **templateData)	
Пример #2
0
def home():

	# try:
	# 	user = models.User.objects.get(username=username)

	# except Exception:
	# 	e = sys.exc_info()
	# 	app.logger.error(e)
	# 	abort(404)

	# # get content that is linked to user, 
	# trip_content = models.Trip.objects(user=user)

	# # prepare the template data dictionary
	# templateData = {
	# 	'allTrip' : models.Trip.objects(user=current_user.id),
	# 	'current_user' : current_user,
	# 	'form' : TripForm,
	# 	'formType' : 'New'
	# }


	# return render_template('home.html', **templateData)


	TripForm = models.trip_form(request.form)

	templateData = {
		'allTrip' : models.Trip.objects(user=current_user.id),
		'current_user' : current_user,
		'form' : TripForm,
		'formType' : 'New'
	}

	return render_template('home.html', **templateData)