def search(page_name=None):
    """

    @param page_name:
    @return: @rtype:
    """
    error = list()

    # get the id of the user you want to follow
    if request.method == 'GET':
        # via ajax
        search_request = request.args.get('search-request', '', type=str)
    else:
        # via no javascript post
        search_request = request.form['search-request']

    if 'user' in session:
        dbh = UserHelper(StrictRedis())
        user = dbh.get_user_by_id(session['user']['id'])
        dbh.get_all_usernames()
        dbh.post_message(message_object)

    else:
        return redirect(url_for('login'))

    if request.method == 'GET':
        return jsonify(post_time=message_object.posted_time,
                       format_time=message_object.formatted_time,
                       msg_id=message_object.id)

    return redirect(url_for('dash'))
Beispiel #2
0
def dash(app):
    """

    @param app:
    @type app: Flask
    @return:
    @rtype:
    """

    if request.method == 'GET':
        if session.has_key('user'):
            dbh = MessageHelper(StrictRedis())
            dbh_user = UserHelper(StrictRedis())
            backward = dbh.get_user_messages(session['user']['id'])
            messages = reversed(backward)
            user = dbh_user.get_user_by_id(session['user']['id'])
            #users = list()
            #for message in messages:
            #user = dbh_user.get_user_by_id(message.user_id)
            #users.append(user)
            #message.user_id = user
            return render_template('dash.html',
                                   error=None,
                                   title='Twic Dashboard',
                                   messages=messages,
                                   user=user)

        return render_template('login.html',
                               error='Please log in',
                               title='Login')

    if request.method == 'POST':
        error = list()