def hello_post(key): """Saves user data and responds with the updated form.""" # Build the schedule from the form data, dropping any empty entries. form = request.form list_form = form.to_dict(flat=False) schedule_form = zip(list_form['schedule_name'], list_form['schedule_start'], list_form['schedule_image']) schedule = [{ 'name': name, 'start': start, 'image': image } for name, start, image in schedule_form if name and start and image] # Update the existing user data or create a new one. firestore = Firestore() firestore.set_user( key, { 'home': form['home'], 'work': form['work'], 'travel_mode': form['travel_mode'], 'schedule': schedule }) # Redirect back to the GET version. return redirect(settings_url(key))
def oauth(): """Handles any OAuth flow redirects.""" # Always redirect back to the settings page. key = request.args.get('state') settings = redirect(settings_url(key)) # Handle any errors, notably the user declining. oauth_error = request.args.get('error') if oauth_error: error('OAuth error: %s' % oauth_error) return settings # Continue the flow based on the scope. scope = request.args.get('scope') code = request.args.get('code') oauth_step2(key, scope, code) return settings