Ejemplo n.º 1
0
def user_own():
    username = session.get('username')
    if username:
        user = auth.find_user_by_username(username)
        return render_template('user_own_project.html', user=user)
    next_url = '/user/own'
    return redirect(url_for('login', next_url=next_url))
Ejemplo n.º 2
0
def user_own():
    username = session.get('username')
    if username:
        user = auth.find_user_by_username(username)
        return render_template('user_own_project.html', user=user)
    next_url = '/user/own'
    return redirect(url_for('login', next_url=next_url))
Ejemplo n.º 3
0
def userinfoedit():
    username = session.get('username')
    if username:
        user = auth.find_user_by_username(username)
    if request.method == 'GET':
        return render_template('user_info_edit.html', user=user)
    if request.method == 'POST':
        user['school'] = request.form['userschool']
        user['grade'] = request.form['usergrade']
        user['phone'] = request.form['userphone']
        user['email'] = request.form['useremail']
        user['gender'] = request.form['usergender']
        interests = []
        if request.form.get('type_0'):
            interests.append(0)
        if request.form.get('type_1'):
            interests.append(1)
        if request.form.get('type_2'):
            interests.append(2)
        if request.form.get('type_3'):
            interests.append(3)
        if request.form.get('type_4'):
            interests.append(4)
        user['interest'] = interests
        auth.user_info_edit(user)
        return redirect(url_for('user_info'))
Ejemplo n.º 4
0
def user_info():
    username = session.get('username')
    if username:
        user = auth.find_user_by_username(username)
        return render_template('user_info.html', user=user)
    next_url = '/user/info'
    return redirect(url_for('login', next_url=next_url, ))
Ejemplo n.º 5
0
def userinfoedit():
    username = session.get('username')
    if username:
        user = auth.find_user_by_username(username)
    if request.method == 'GET':
        return render_template('user_info_edit.html', user=user)
    if request.method == 'POST':
        user['school'] = request.form['userschool']
        user['grade'] = request.form['usergrade']
        user['phone'] = request.form['userphone']
        user['email'] = request.form['useremail']
        user['gender'] = request.form['usergender']
        interests = []
        if request.form.get('type_0'):
            interests.append(0)
        if request.form.get('type_1'):
            interests.append(1)
        if request.form.get('type_2'):
            interests.append(2)
        if request.form.get('type_3'):
            interests.append(3)
        if request.form.get('type_4'):
            interests.append(4)
        user['interest'] = interests
        auth.user_info_edit(user)
        return redirect(url_for('user_info'))
Ejemplo n.º 6
0
def message_page():
    if request.method == 'GET':
        if session.get('username') is None:
            next_url = '/message/page'
            return redirect(url_for('login', next_url=next_url))
        return render_template('message.html')
    if request.method == 'POST':
        if session.get('username') is None:
            error = {'error': 'authorization failed'}
            return json.dumps(error)

        page_size = 4
        page_no = int(request.json['page_no'])
        messages = message.find_message_by_user(
            username=session.get('username'),
            page_no=page_no,
            page_size=page_size)
        response = {}
        message_list = []
        for idx, msg in enumerate(messages):
            proj = {
                'id': idx + 1,
                '_id': str(msg['_id']),
                'project_owner': msg['project_owner'],
                'puser': auth.find_user_by_username(msg['project_owner']),
                'username': msg['username'],
                'user': auth.find_user_by_username(msg['username']),
                'created_time': str(msg['created_time']),
                'message_type': msg['message_type'],
                'isSolved': msg['isSolved'],
                'user_name': session.get('username'),
                'project_id': msg['project_id'],
                'projectname': msg['projectname']
            }
            message_list.append(proj)

        response['messages'] = message_list
        message_count = message.count_message_by_user(
            username=session.get('username'))
        import math
        page_count = int(math.ceil(float(message_count) / float(page_size)))
        print page_count, message_count
        response['page_count'] = page_count
        response_json = json.dumps(response, default=json_util.default)
        return response_json
Ejemplo n.º 7
0
def user_info():
    username = session.get('username')
    if username:
        user = auth.find_user_by_username(username)
        return render_template('user_info.html', user=user)
    next_url = '/user/info'
    return redirect(url_for(
        'login',
        next_url=next_url,
    ))
Ejemplo n.º 8
0
def showprojectdetail():
    project_id = request.args.get('project_id')
    pm = project_manager.ProjectManager()
    project = pm.find_project_by_id(project_id)
    project['teamList'] = project['team'][:]
    for i, t_user in enumerate(project['team']):
        _user = auth.find_user_by_username(t_user)
        project['team'][i] = _user
    project['creator'] = auth.find_user_by_username(project['creator'])
    cm = comment.CommentManager()
    comments = cm.get_all_comment_by_projectid(str(project['_id']))
    for _comment in comments:
        _username = _comment['username']
        _user = auth.find_user_by_username(_username)
        _comment['user'] = _user

    def get_p_time(time):
        time = str(time)
        return time[:len(time) - 7]

    return render_template('showprojectdetail.html', project=project, comments=comments, get_p_time=get_p_time)
Ejemplo n.º 9
0
def message_page():
    if request.method == 'GET':
        if session.get('username') is None:
            next_url = '/message/page'
            return redirect(url_for('login', next_url=next_url))
        return render_template('message.html')
    if request.method == 'POST':
        if session.get('username') is None:
            error = {'error': 'authorization failed'}
            return json.dumps(error)

        page_size = 4
        page_no = int(request.json['page_no'])
        messages = message.find_message_by_user(username=session.get('username'),
                                                page_no=page_no,
                                                page_size=page_size)
        response = {}
        message_list = []
        for idx, msg in enumerate(messages):
            proj = {'id': idx + 1, '_id': str(msg['_id']), 'project_owner': msg['project_owner'],
                    'puser': auth.find_user_by_username(msg['project_owner']),
                    'username': msg['username'],
                    'user': auth.find_user_by_username(msg['username']),
                    'created_time': str(msg['created_time']),
                    'message_type': msg['message_type'],
                    'isSolved': msg['isSolved'],
                    'user_name':session.get('username'),
                    'project_id':msg['project_id'],
                    'projectname': msg['projectname']}
            message_list.append(proj)

        response['messages'] = message_list
        message_count = message.count_message_by_user(username=session.get('username'))
        import math
        page_count = int(math.ceil(float(message_count) / float(page_size)))
        print page_count, message_count
        response['page_count'] = page_count
        response_json = json.dumps(response, default=json_util.default)
        return response_json
Ejemplo n.º 10
0
def showprojectdetail():
    project_id = request.args.get('project_id')
    pm = project_manager.ProjectManager()
    project = pm.find_project_by_id(project_id)
    project['teamList'] = project['team'][:]
    for i, t_user in enumerate(project['team']):
        _user = auth.find_user_by_username(t_user)
        project['team'][i] = _user
    project['creator'] = auth.find_user_by_username(project['creator'])
    cm = comment.CommentManager()
    comments = cm.get_all_comment_by_projectid(str(project['_id']))
    for _comment in comments:
        _username = _comment['username']
        _user = auth.find_user_by_username(_username)
        _comment['user'] = _user

    def get_p_time(time):
        time = str(time)
        return time[:len(time) - 7]

    return render_template('showprojectdetail.html',
                           project=project,
                           comments=comments,
                           get_p_time=get_p_time)
Ejemplo n.º 11
0
def show_user(username):
    user = auth.find_user_by_username(username)
    return render_template('user_info.html', user=user)
Ejemplo n.º 12
0
def person():
    username = session.get('username')
    user = auth.find_user_by_username(username)
    return render_template('user_info.html', user=user)
Ejemplo n.º 13
0
def show_user(username):
    user = auth.find_user_by_username(username)
    return render_template('user_info.html', user=user)
Ejemplo n.º 14
0
def person():
    username = session.get('username')
    user = auth.find_user_by_username(username)
    return render_template('user_info.html', user=user)