Example #1
0
def user_timeline(username):
    """Display's a users tweets."""
    profile_user = query_db('select * from user where username = ?',
                            [username], one=True)
    if profile_user is None:
        department_user = query_db('select * from department where username = ?',
                            [username], one=True)
        if department_user is None:
            flash('User doesn\'t exist.')
            return redirect(url_for('public_timeline'))
        else:
            db = get_db()
            muddas = department_utils.get_muddas(db, department_user['department_id'])
            return render_template('department-timeline.html',
                messages = department_utils.get_timeline(db, department_user['department_id']),
                department_user = department_user,
                assigned_muddas = muddas['assigned'],
                solved_muddas = muddas['solved'])

    else:
        if g.user:
            mudda_count = user_utils.get_mudda_count(get_db(), profile_user['user_id'])
            return render_template('user-timeline.html', messages=query_db('''
                select message.*, user.* from message, user where
                user.user_id = message.author_id and user.user_id = ?
                order by message.pub_date desc limit ?''',
                [profile_user['user_id'], PER_PAGE]),
                profile_user=profile_user, mudda_count=mudda_count)
Example #2
0
def timeline():
    """Shows a users timeline or if no user is logged in it will
    redirect to the public timeline.  This timeline shows the user's
    messages as well as all the messages of followed users.
    """
    if not g.user:
        return redirect(url_for('public_timeline'))
    user_type = get_user_type()
    if user_type == USERS['user']:
        messages = query_db('''
            select message.*, user.* from message, user
            where message.author_id = user.user_id and (
                user.user_id = ? or
                user.user_id in (select whom_id from follower
                                        where who_id = ?))
            order by message.pub_date desc limit ?''',
            [session['user_id'], session['user_id'], PER_PAGE])
        return render_template('timeline.html', messages = messages)

    elif user_type == USERS['department']:
        messages = department_utils.get_timeline(get_db(), session['department_id'])
        return render_template('timeline.html', messages = messages)
Example #3
0
def user_timeline(username):
    """Display's a users tweets."""
    profile_user = query_db('select * from user where username = ?',
                            [username],
                            one=True)
    if profile_user is None:
        department_user = query_db(
            'select * from department where username = ?', [username],
            one=True)
        if department_user is None:
            flash('User doesn\'t exist.')
            return redirect(url_for('public_timeline'))
        else:
            db = get_db()
            muddas = department_utils.get_muddas(
                db, department_user['department_id'])
            return render_template('department-timeline.html',
                                   messages=department_utils.get_timeline(
                                       db, department_user['department_id']),
                                   department_user=department_user,
                                   assigned_muddas=muddas['assigned'],
                                   solved_muddas=muddas['solved'])

    else:
        if g.user:
            mudda_count = user_utils.get_mudda_count(get_db(),
                                                     profile_user['user_id'])
            return render_template('user-timeline.html',
                                   messages=query_db(
                                       '''
                select message.*, user.* from message, user where
                user.user_id = message.author_id and user.user_id = ?
                order by message.pub_date desc limit ?''',
                                       [profile_user['user_id'], PER_PAGE]),
                                   profile_user=profile_user,
                                   mudda_count=mudda_count)
Example #4
0
def timeline():
    """Shows a users timeline or if no user is logged in it will
    redirect to the public timeline.  This timeline shows the user's
    messages as well as all the messages of followed users.
    """
    if not g.user:
        return redirect(url_for('public_timeline'))
    user_type = get_user_type()
    if user_type == USERS['user']:
        messages = query_db(
            '''
            select message.*, user.* from message, user
            where message.author_id = user.user_id and (
                user.user_id = ? or
                user.user_id in (select whom_id from follower
                                        where who_id = ?))
            order by message.pub_date desc limit ?''',
            [session['user_id'], session['user_id'], PER_PAGE])
        return render_template('timeline.html', messages=messages)

    elif user_type == USERS['department']:
        messages = department_utils.get_timeline(get_db(),
                                                 session['department_id'])
        return render_template('timeline.html', messages=messages)