Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
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)
Пример #4
0
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'))
Пример #5
0
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'))
Пример #6
0
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)
Пример #7
0
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")
Пример #8
0
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
Пример #9
0
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={})
Пример #10
0
def view(id):
    spolunteer = get_model().read(id)
    return render_template("view.html", spolunteer=spolunteer)
Пример #11
0
def delete(id):
    get_model().delete(id)
    return redirect(url_for('.list'))
Пример #12
0
def delete(id):
    get_model().delete("Spolunteer", id)
    #return redirect(url_for(request.path))
    #return redirect(request.path)
    return redirect(url_for('.admin'))
Пример #13
0
def getInterest(id):
    interest = get_model().getInterest(id)
    return jsonify(interest)
Пример #14
0
def createInterest():
    data = request.form.to_dict(flat=True)
    interest = get_model().createInterest(data)
    return jsonify(interest)