Beispiel #1
0
def guestbook():
    if request.method == 'POST':
        if request.form['submit'] == 'delete':
            selected_entries = request.form.getlist("delcomments")
            for entry in selected_entries:
                with AzureDB() as a:
                    a.azureDeleteData(entry)
            with AzureDB() as a:
                data = a.azureGetData()
            return render_template("guestbook.html", data=data, mode='delete')
        else:
            name = request.form['name']
            text = request.form['comments']
            with AzureDB() as a:
                a.azureAddData(name, text)
                data = a.azureGetData()
            return render_template("guestbook.html", data=data)
    else:
        user = request.args.get('user')
        if user == 'panda':
            with AzureDB() as a:
                data = a.azureGetData()
            return render_template("guestbook.html", data=data, mode='delete')
        else:
            with AzureDB() as a:
                data = a.azureGetData()
            return render_template("guestbook.html", data=data)
Beispiel #2
0
def edit_comm(id):
    comm = AzureDB().azureGetDataid(id)
    if request.method == "POST":
        if len(request.form['text']) > 5:
            res = AzureDB().azureEditData(request.form['text'], id)
            return redirect('/comments')

        else:
            return 'Nie możesz zostawić pusty komentarz!'
    else:

        return render_template('edit.html', comm=comm)
Beispiel #3
0
def delete():
    index = request.form['id']
    with AzureDB() as a:
        a.azureDeleteData(index)
        return render_template('thankyou.html',
                               title='Dziękuje',
                               metod='DELETE')
Beispiel #4
0
def update_comment(comment_id):
    if request.method == 'PUT':
        data = request.json
        text = data['text']
        with AzureDB() as a:
            a.azureUpdateData(comment_id, text)
            return 200
Beispiel #5
0
def thankyou():
    if request.method == 'POST':
        name = request.form['name']
        comment = request.form['comment']
        date = str(datetime.now())
        with AzureDB() as a:
            a.azureAddData(name, comment, date[:19])
    return render_template('thankyou.html', title='Dziękuje', metod='POST')
Beispiel #6
0
def update():
    index = request.form['id']
    name = request.form['name']
    text = request.form['text']
    with AzureDB() as a:
        a.azureUpdateData(index, name, text)
        return render_template('thankyou.html',
                               title='Dziękuje',
                               metod='UPDATE')
Beispiel #7
0
def edit():
    index = request.form['id']
    with AzureDB() as a:
        data = a.azureGetOneData(index)
        return render_template('editcomment.html',
                               title='Edytowanie',
                               nick=data[1],
                               comment=data[2],
                               id=data[0])
Beispiel #8
0
def comment():
    if request.method == 'POST':
        text = request.form['comment']
        nick = request.form['nick']
        date = str(datetime.datetime.now())[:19]
        print(date)
        with AzureDB() as a:
            a.azureAddData(nick, text, date)
            return redirect('guestBook')
Beispiel #9
0
def contact():
    if request.method == "POST":
        if len(request.form['name']) > 2 and len(
                request.form['mail']) > 3 and len(request.form['text']) > 5:
            res = AzureDB().azureAddData(request.form['name'],
                                         request.form['mail'],
                                         request.form['text'])
            flash('Comentarz został wysłąny', category='success')

        else:
            flash('Niepoprawna forma komentarza, sprawdz', category='error')

    return render_template('contact.html')
Beispiel #10
0
def guestbook():
    with AzureDB() as a:
        data = a.azureGetData()
        return render_template("guestbook.html", data=data, title='GuestBook')
Beispiel #11
0
from AzureDB import AzureDB
#AzureDB().azureAddData()
#AzureDB().azureDeleteData()
with AzureDB() as a:
 data = a.azureGetData()
for result in data:
print("%s napisał : \"%s\"" % (result['name'], result['text']))
Beispiel #12
0
def delete_comm(id):
    AzureDB().azureDeleteData(id)
    return redirect('/comments')
Beispiel #13
0
def comments():
    data = AzureDB().azureGetData()
    return render_template("comments.html", data=data)
Beispiel #14
0
def delete_comment(comment_id):
    if request.method == 'DELETE':
        with AzureDB() as a:
            a.azureDeleteData(comment_id)
        return str('Hello')
Beispiel #15
0
def get_guest_book():
    with AzureDB() as a:
        data = a.azureGetData()
        print(data)
    return render_template("book.html", data=data)