예제 #1
0
def user_loader(username):
    db = pSQL.pSQL()
    if not db.if_username_exists(username):
        return  # Don't have to anything
    user = User()
    user.id = username
    return user
예제 #2
0
def show_blocks():
    # declare pSQL object
    db = pSQL.pSQL()
    # call the function and get the result
    reslist = db.get_all_blocks()
    # close the pSQL object
    db.close()
    # return it to the frontend
    return json.dumps(reslist, default=func.date_to_string_converter)
예제 #3
0
def register_page():
    if request.method == 'POST':
        name = request.values['username']
        email = request.values['email']
        password = request.values['password']
        db = pSQL.pSQL()
        db.register(name, email, password)
        return jsonify({"msg": 1})
    return render_template('account/register_page.html')
예제 #4
0
def request_loader(request):
    username = request.args.get('username')
    db = pSQL.pSQL()
    if not db.if_username_exists(username):
        return  # Don't have to anything
    user = User()
    user.id = username
    password = request.get('password')
    user.is_authenticated = db.if_username_password_exist_match(
        username, password)
    return user
예제 #5
0
def record_my_life():
    # declare pSQL object
    db = pSQL.pSQL()
    # show three tables; help us to test the program
    tagsList, blocksList, blockTagPairList = db.home_display()
    # close the pSQL object
    db.close()
    return render_template('record_my_life.html',
                           tagRows=tagsList,
                           blockRows=blocksList,
                           blockTagPairRows=blockTagPairList)
예제 #6
0
def submit_record_form():
    if request.method == 'POST':
        # Take out the data
        title = request.values['Title']
        description = request.values['Description']
        tags = request.values['Tags']
        func.turn_json_array_string_into_list(tags)
        date = request.values['Date']
        db = pSQL.pSQL()
        db.receive_record_submit(title, description, tags, date)
        db.close()
        # Put into the database
        return jsonify({"msg": 1})
    else:
        return jsonify({"msg": 0})
예제 #7
0
def login():
    if request.method == 'GET':
        # return the empty login form page
        return render_template('account/login.html')
    username = request.form['username']
    password = request.form['password']
    # check if the username and the password matching
    db = pSQL.pSQL()
    if db.if_username_password_exist_match(username, password):
        user = User()
        user.id = username
        login_user(user)
        # flash
        flash('Login successfully!')
        return redirect(url_for('/'))
    # login failed
    flash('Login failed!')
    return render_template('account/login.html')
예제 #8
0
import pSQL

db = pSQL.pSQL()

username = "******"
password = "******"

print(db.if_username_password_exist_match(username, password))

db.close()
예제 #9
0
                )
                + _U(
                    "Workaround for studying fuel substitution: add all fuels You want to consider already in the original state\n"
                )
                + _U("and set original consumption of these additional fuels to 0")
            )
            return False
        else:
            return True


if __name__ == "__main__":
    import pSQL
    import MySQLdb

    class Main(object):
        def __init__(self, qid):
            self.activeQid = qid

    DBName = "einstein"
    Status.SQL = MySQLdb.connect(host="localhost", user="******", passwd="tom.tom", db=DBName)
    Status.DB = pSQL.pSQL(Status.SQL, DBName)

    app = wx.PySimpleApp()
    frame = wx.Frame(parent=None, id=-1, size=wx.Size(800, 600), title="Einstein - panelQ2")
    main = Main(1)
    panel = PanelQ2(frame, main)

    frame.Show(True)
    app.MainLoop()
예제 #10
0
def get_tags():
    keyword = request.values['Keyword']
    db = pSQL.pSQL()
    reslist = db.get_all_tags(keyword)
    db.close()
    return json.dumps(reslist)
예제 #11
0
def delete_block():
    if request.method == 'POST':
        block_id = request.values['block_id']
        db = pSQL.pSQL()
        db.delete_block(block_id)
        return jsonify({"msg": 1})
예제 #12
0
 def __connectToDB(self):
     conn = MySQLdb.connect("localhost", self.__username, self.__password, db="einstein")
     md = pSQL.pSQL(conn, "einstein")
     return md