def create_comment(seatarrname):
    if request.method == 'POST':
        error = False
        if request.form['UserName'].isspace() or request.form['UserName'] == "":
            error = "Invalid UserName, Please write something for UserName..."

        elif request.form['CommentText'].isspace() or request.form['CommentText'] == "":
            error = "Invalid Comment Text, Please write something for Comment Text..."

        if error != False:
            return render_template("create_comment.html", seatarrname = seatarrname, new_CommentID = request.form['CommentID'],
                                   today = request.form['CommentDatetime'], error = error)

        new_comment = Comment(seatarrname,
                        request.form['CommentID'],
                        request.form['CommentText'],
                        request.form['CommentDatetime'],
                        request.form['UserName'])
        execute_sql(new_comment.create_new_record())

        UserName, SeatArrName, SeatArrSeq, RowNo, ColumnNo, CommentIDs = execute_sql("SELECT * FROM SavedSeatArr WHERE SeatArrName = '{}'".format(seatarrname))[0]
        edit_ssr = SavedSeatArr(UserName, SeatArrName, SeatArrSeq, RowNo, ColumnNo, CommentIDs)
        edit_ssr.set_CommentIDs(request.form['CommentID'])
        execute_sql(edit_ssr.update_record())

        return redirect(url_for("show_seatarr_by_name", seatarrname = seatarrname))
    else:
        # GET
        CommentID = execute_sql("SELECT Max(CommentID) FROM Comment")[0][0]
        new_CommentID = "{:0>6}".format(int(CommentID) + 1)
        today = "{:%Y-%m-%d}".format(date.today())

        return render_template("create_comment.html", seatarrname = seatarrname, new_CommentID = new_CommentID, today = today)
def delete_comment():
    comment_id = request.form.get('delete')
    comment = execute_sql("SELECT * FROM Comment WHERE CommentID = '{}'".format(comment_id))[0]
    #print(comment)
    SeatArrName, CommentID, CommentText, CommentDatetime, UserName = comment
    delete_comment = Comment(SeatArrName, CommentID, CommentText, CommentDatetime, UserName)

    # Update DB
    execute_sql(delete_comment.delete_record())

    UserName, SeatArrName, SeatArrSeq, RowNo, ColumnNo, CommentIDs = execute_sql("SELECT * FROM SavedSeatArr WHERE SeatArrName = '{}'".format(SeatArrName))[0]
    edit_ssr = SavedSeatArr(UserName, SeatArrName, SeatArrSeq, RowNo, ColumnNo, CommentIDs)
    edit_ssr.delete_CommentIDs(comment_id)
    execute_sql(edit_ssr.update_record())

    # Return to mainpage
    return redirect(url_for("show_seatarr_by_name", seatarrname = SeatArrName))