def reception(): operation = request.args.get('operation') spolunteers = get_model().list_by_operation(table="Spolunteer", operation=operation) return render_template("reception.html", spolunteers=spolunteers, operation=operation, request=request)
def list(): token = request.args.get('page_token', None) if token: token = token.encode('utf-8') spolunteers, next_page_token = get_model().list(cursor=token) return render_template("list.html", spolunteers=spolunteers, next_page_token=next_page_token)
def list_mine(): token = request.args.get('page_token', None) if token: token = token.encode('utf-8') spolunteers, next_page_token = get_model().list_by_user( user_id=session['profile']['id'], cursor=token) return render_template("list.html", spolunteers=spolunteers, next_page_token=next_page_token)
def interestadd(): data = {} if 'profile' in session: data['createdBy'] = session['profile']['displayName'] data['createdById'] = session['profile']['id'] data['createdAt'] = 'now' interest = get_model().create('Interest', data) #print(interest, file=sys.stderr) #return render_template("admin.html", action="List", spolunteer={}) return redirect(url_for('.admin'))
def receptionadd(): data = {} if 'profile' in session: data['createdBy'] = session['profile']['displayName'] data['createdById'] = session['profile']['id'] data['createdAt'] = 'now' data['firstname'] = '' spolunteer = get_model().create('Spolunteer', data) #print(spolunteer, file=sys.stderr) return redirect(url_for('.reception'))
def statistics(): token = request.args.get('page_token', None) if token: token = token.encode('utf-8') spolunteers, next_page_token = get_model().list(table='Spolunteer', cursor=token) return render_template("statistics.html", spolunteers=spolunteers, next_page_token=next_page_token, request=request)
def profile(): token = request.args.get('page_token', None) if token: token = token.encode('utf-8') if 'profile' in session: spolunteers, next_page_token = get_model().list_by_user( table="Spolunteer", user_id=session['profile']['id'], cursor=token) return render_template("profile.html", spolunteers=spolunteers, next_page_token=next_page_token) return render_template("profile.html")
def admin_download(): spolunteers = get_model().download_as_csv(table='Spolunteer') si = io.StringIO() all_spolunteers = [] for spolunteer in spolunteers: temp_dict = {} for item in spolunteer.keys(): temp_dict[item] = spolunteer[item] all_spolunteers.append(temp_dict) df = pd.DataFrame(all_spolunteers) df.to_csv(si, index=False) output = make_response(si.getvalue()) output.headers["Content-Disposition"] = "attachment; filename=export.csv" output.headers["Content-type"] = "text/csv" return output
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. # image_url = upload_image_file(request.files.get('image')) # if image_url: # data['imageUrl'] = image_url # If the user is logged in, associate their profile with the new spolunteer. if 'profile' in session: data['createdBy'] = session['profile']['displayName'] data['createdById'] = session['profile']['id'] spolunteer = get_model().create(data) return redirect(url_for('.view', id=spolunteer['id'])) return render_template("form.html", action="Add", spolunteer={})
def view(id): spolunteer = get_model().read(id) return render_template("view.html", spolunteer=spolunteer)
def delete(id): get_model().delete(id) return redirect(url_for('.list'))
def delete(id): get_model().delete("Spolunteer", id) #return redirect(url_for(request.path)) #return redirect(request.path) return redirect(url_for('.admin'))
def getInterest(id): interest = get_model().getInterest(id) return jsonify(interest)
def createInterest(): data = request.form.to_dict(flat=True) interest = get_model().createInterest(data) return jsonify(interest)