예제 #1
0
def signup():
    form = SignupForm()
    if form.validate_on_submit():
        first_name = form.first_name.data
        last_name = form.last_name.data
        username = form.username.data
        email = form.email.data
        password = form.password.data
        if User.query.filter_by(username=username).first():
            db.session.rollback()
            flash('Username already taken! Please try different username',
                  "error")
        else:
            new_user = User.register(first_name=first_name.capitalize(),
                                     last_name=last_name.capitalize(),
                                     username=username,
                                     email=email,
                                     password=password)
            if new_user:
                db.session.add(new_user)
                db.session.commit()
                #session["username"] = new_user.username
                redis.set('username', new_user.username)
                flash(f"Welcome {new_user.username}!", "success")
                return redirect(f'/users/{new_user.username}')
    return render_template('signup.html', form=form)
예제 #2
0
def main():
    ship_list = get_ship_list()
    for t in ship_list.values():
        for ship_id in t:
            # ship_names[ship_id] = t[ship_id]
            process_construct_data(get_construct_data(ship_id))
    redis.set("ship_list", repr(ship_list))
    redis.set("gengaku_table", repr(gengaku_table))
예제 #3
0
파일: flaskr.py 프로젝트: bonniee/bib-web-2
def add_book_info_programmatically(isbn):
    clear_caches()
    field_dict = fields_for_isbn(isbn)
    field_dict['rfid_num'] = 0
    field_dict['on_shelf'] = False
    for key in field_dict:
        redis.set(isbn+":"+key, field_dict[key])
    redis.set("rfid_most_recent_isbn", isbn)
예제 #4
0
def communicate_post():
    if request.form['my-form'] == 'Send':
        name = request.form['text']
        redis.set('name',name)
        return render_template("communicate.html", name=name)
    elif request.form['my-form'] == 'Refresh':
        name = redis.get('name').decode('utf-8')
        return render_template("communicate.html", name=name)
    else:
        return "Something went wrong"
예제 #5
0
def store_to_redis(isbns):
    for isbn in isbns:
        book = amazon_lookup(isbn)
        # Adding to the list of books
        redis.sadd("books", book.to_string())
        # so that the book data can be access later using the isbn
        redis.set(isbn, book.to_string())
        isbn_to_saved_image(isbn)
        with open("isbn_db.txt", "a") as myfile:
            myfile.write(isbn + "\n")
예제 #6
0
def homepage():
    form = LoginForm()
    if form.validate_on_submit():
        username = form.username.data
        password = form.password.data
        user = User.authentication(username=username, password=password)
        if user:
            #session['username'] = user.username
            redis.set('username', user.username)
            flash(f'Welcome back! {user.username}', "success")
            return redirect(f'/users/{user.username}')
        else:
            form.username.errors = ['Please enter valid username/password']

    return render_template('login.html', form=form)
예제 #7
0
파일: main.py 프로젝트: DerekHXZ/Travelog
def auth():
    print "Called auth"
    fbId = getFbId()
    if not fbId:
        return "", 403

    accntype = request.form['type']
    username = request.form['username']
    password = request.form['password']
    email = request.form['email']

    plaid = Plaid(PLAID_ID, PLAID_KEY)
    plaid_resp = plaid.connect(accntype, username, password, email)
    if not plaid_resp:
        return "", 403
    redis.set(fbId, plaid_resp['access_token'])
    if plaid_resp['mfa']:
        return plaid_resp['mfa']['message'], 201
    else:
        return "", 200
예제 #8
0
파일: flaskr.py 프로젝트: bonniee/bib-web-2
def books_on_shelf_changed():
    clear_caches()
    rfid_id = request.args['scanid']
    rfid_num = request.args['tagid']
    # Scanner is a number (or a string?) indicating scanner ID
    # Tag is the tag number of the book
    books_prev_on_shelf = set([])
    try:
        books_prev_on_shelf = set(redis.get("rfid:"+rfid_id).split(':'))
    except:
        # no books have ever been added to this shelf
        pass
    
    # old book vs. new book
    isbn = redis.get("rfid_id:"+rfid_num)
    if isbn == None:
        # associate tag with book in the system
        isbn = redis.get("rfid_most_recent_isbn")
        redis.set("rfid_id:"+rfid_num, isbn)
        redis.set(isbn+":rfid_num", rfid_num)
    
    book_was_removed = rfid_num in books_prev_on_shelf
    if not book_was_removed:
        # book added
        print "adding book", isbn, rfid_num, "to shelf", rfid_id
        redis.set(str(isbn)+":on_shelf", rfid_id)
        books_rfids_currently_on_shelf = books_prev_on_shelf | set([rfid_num])
    else:
        # book removed
        print "removing book", isbn, rfid_num, "from shelf", rfid_id
        redis.set(isbn+":on_shelf", False)
        books_rfids_currently_on_shelf = books_prev_on_shelf - set([rfid_num])

    shelf_string = ":".join(books_rfids_currently_on_shelf)
    redis.set("rfid:"+rfid_id, shelf_string)
    return redirect(url_for('show_entries'))
예제 #9
0
파일: flaskr.py 프로젝트: bonniee/bib-web-2
def add_to_shelf_with_tag(isbn, shelf, rfid_num):
    clear_caches()
    isbn = str(isbn)
    shelf = str(shelf)
    rfid_num = str(rfid_num)
    redis.set(isbn+":on_shelf", shelf)
    redis.set(isbn+":rfid_num", rfid_num)
    books_prev_on_shelf = set([])
    try:
        books_prev_on_shelf = set(redis.get("rfid:"+shelf).split(':'))
    except:
        # no books have ever been added to this shelf
        pass
    books_rfids_currently_on_shelf = books_prev_on_shelf | set([rfid_num])
    shelf_string = ":".join(books_rfids_currently_on_shelf)
    redis.set("rfid:"+shelf, shelf_string)
    redis.set("rfid_id:"+rfid_num, isbn)
예제 #10
0
파일: tweeter.py 프로젝트: ukch/biblebot
 def _set_last_tweeted(self, value):
     self._last_tweeted_date = value
     redis.set('last_tweeted_date', value)
예제 #11
0
 def _set_last_tweeted(self, value):
     self._last_tweeted_date = value
     redis.set('last_tweeted_date', value)
예제 #12
0
def logout():
    #session.pop('username')
    redis.set('username', '')
    flash("You have been logged out successfully!", "success")
    return redirect('/')
예제 #13
0
파일: flaskr.py 프로젝트: bonniee/bib-web-2
def populate():
    clear_caches()
    # books_on_shelf = {'9780691036564': 0, \
    #                 '9780393924282': 0, \
    #                 '9780393971668': 0, \
    #                 '9780486270654': 0, \
    #                 '9780060726461': 0, \
    #                 '9781844674183': 1, \
    #                 '9780300118063': 1, \
    #                 '9780061792960': 1, \
    #                 '9780802170019': 1, \
    #                 '9780521566827': 1, \
    #                 '9781852421397': 2, \
    #                 '9780140186246': 2, \
    #                 '9781565848160': 2, \
    #                 '9780945774075': 2, \
    #                 '9780231133814': 2, }
    books_on_shelf = {'9780691036564': 0, \
                    '9780393924282': 0, \
                    '9780393971668': 0, \
                    '9780486270654': 0, \
                    '9780060726461': 0, \
                    '9781844674183': 1, \
                    '9780300118063': 1, \
                    '9780061792960': 1, \
                    '9780802170019': 1, \
                    '9780521566827': 1, \
                    '9781852421397': 2, \
                    '9780140186246': 2, \
                    '9781565848160': 2, \
                    '9780945774075': 2, \
                    '9780231133814': 2 }
    # bookmark ids go here
    books_on_shelf_tag_ids = {'9780691036564': 27445, \
                    '9780393924282': "06876", \
                    '9780393971668': 11927, \
                    '9780486270654': 56581, \
                    '9780060726461': 38526, \
                    '9781844674183': 13087, \
                    '9780300118063': 45975, \
                    '9780061792960': 13238, \
                    '9780802170019': 18351, \
                    '9780521566827': 50273, \
                    '9781852421397': 39726, \
                    '9780140186246': 39670, \
                    '9781565848160': 43616, \
                    '9780945774075': 10091, \
                    '9780231133814': 28475, }  
    books_not_on_shelf = ['9780062255655', \
                            '9780062017819', \
                            '9781476727653', \
                            '9780061342394', \
                            '9780316198837', \
                            '9780440180296', \
                            '9780810117433', \
                            '9781593076672']
    redis.flushdb();
    for isbn in books_on_shelf.keys():
        add_book_info_programmatically(isbn)
        add_to_shelf_with_tag(isbn, books_on_shelf[isbn], books_on_shelf_tag_ids[isbn])
    for isbn in books_not_on_shelf:
        add_book_info_programmatically(isbn)
    # special book for testing, must have card
    redis.set("9781852421397:rfid_num", "11927")
    return redirect(url_for('show_entries'))
예제 #14
0
파일: flaskr.py 프로젝트: bonniee/bib-web-2
def add_to_shelf_wizard_prog(shelf):
    clear_caches()
    isbn = redis.get("rfid_most_recent_isbn")
    redis.set(isbn+":on_shelf", shelf)
예제 #15
0
파일: initdb.py 프로젝트: bfontaine/web-pp
def save_list():
    """
    Save the list of people, as a JSON hash.
    """
    redis.set('people.json', json.dumps(parse_all()))