def edit(id): job = get_model().read(id) if request.method == 'POST': data = request.form.to_dict(flat=True) # If an image was uploaded, update the data to point to the new image. file_url = upload_file(request.files.get('details_file')) if file_url: data['fileURL'] = file_url job = get_model().update(data, id) return redirect(url_for('.view', id=job['id'])) return render_template("form.html", action="Edit", job=job)
def list(): token = request.args.get('page_token', None) if token: token = token.encode('utf-8') jobs, next_page_token = get_model().list(cursor=token) return render_template("list.html", jobs=jobs, next_page_token=next_page_token)
def list_mine(): token = request.args.get('page_token', None) if token: token = token.encode('utf-8') jobs, next_page_token = get_model().list_by_user( user_id=session['profile']['id'], cursor=token) return render_template("list.html", jobs=jobs, next_page_token=next_page_token)
def add(): if request.method == 'POST': data = request.form.to_dict(flat=True) # If an image was uploaded, update the data to point to the new image. file_url = upload_file(request.files.get('details_file')) if file_url: data['fileURL'] = file_url # If the user is logged in, associate their profile with the new job. if 'profile' in session: data['createdBy'] = session['profile']['displayName'] data['createdById'] = session['profile']['id'] job = get_model().create(data) return redirect(url_for('.view', id=job['id'])) return render_template("form.html", action="Add", job={})
def view(id): job = get_model().read(id) return render_template("view.html", job=job)
def delete(id): get_model().delete(id) return redirect(url_for('.list'))