Exemple #1
0
def feed(request):
    current = 'feed'
    title = u'%s / 动态' % (request.user.username)
    feedAction = FeedAction()
    feedAction.set_user_position(request.user.id, PositionKey.FEED)
    recently_timestamp = feedAction.get_recently_timestamp(
        request.user.id, AttrKey.RECENTLY_TIME_FEED)
    raw_watch_users = feedAction.get_watch_users(request.user.id, 0, 100)
    watch_user_ids = [int(x[0]) for x in raw_watch_users]
    watch_user_ids.append(request.user.id)
    raw_watch_repos = feedAction.get_watch_repos(request.user.id, 0, 100)
    watch_repo_ids = [int(x[0]) for x in raw_watch_repos]

    feeds_as_json = multi_feeds_as_json(request, feedAction, watch_user_ids,
                                        watch_repo_ids)
    feedAction.set_recently_timestamp_now(request.user.id,
                                          AttrKey.RECENTLY_TIME_FEED)
    response_dictionary = {
        'current': current,
        'title': title,
        'feeds_as_json': feeds_as_json,
        'recently_timestamp': recently_timestamp
    }
    return render_to_response('user/feed.html',
                              response_dictionary,
                              context_instance=RequestContext(request))
Exemple #2
0
def issues(request, username, page):
    (teamUser, teamUserprofile) = _get_team_user_userprofile(request, username)
    current = 'issues'
    title = u'%s / 问题' % (teamUser.username)
    feedAction = FeedAction()
    feedAction.set_user_position(teamUser.id, PositionKey.ISSUES)
    page = int(page)
    page_size = 50
    offset = page * page_size
    row_count = page_size + 1
    issues = IssueManager.list_issues_by_teamUserId_assigned(
        teamUser.id, request.user.id, 'modify_time', offset, row_count)

    hasPre = False
    hasNext = False
    if page > 0:
        hasPre = True
    if len(issues) > page_size:
        hasNext = True
        issues.pop()
    response_dictionary = {
        'current': current,
        'title': title,
        'issues': issues,
        'page': page,
        'hasPre': hasPre,
        'hasNext': hasNext
    }
    response_dictionary.update(
        _get_common_team_dict(request, teamUser, teamUserprofile))
    return render_to_response('team/issues.html',
                              response_dictionary,
                              context_instance=RequestContext(request))
Exemple #3
0
def issues(request, page):
    current = 'issues'
    title = u'%s / 问题' % (request.user.username)
    feedAction = FeedAction()
    feedAction.set_user_position(request.user.id, PositionKey.ISSUES)
    recently_timestamp = feedAction.get_recently_timestamp(
        request.user.id, AttrKey.RECENTLY_TIME_ISSUES)
    page = int(page)
    page_size = 50
    offset = page * page_size
    row_count = page_size + 1
    issues = IssueManager.list_assigned_issues(request.user.id, 'modify_time',
                                               offset, row_count)

    hasPre = False
    hasNext = False
    if page > 0:
        hasPre = True
    if len(issues) > page_size:
        hasNext = True
        issues.pop()
    feedAction.set_recently_timestamp_now(request.user.id,
                                          AttrKey.RECENTLY_TIME_ISSUES)
    response_dictionary = {
        'current': current,
        'title': title,
        'issues': issues,
        'page': page,
        'hasPre': hasPre,
        'hasNext': hasNext,
        'recently_timestamp': recently_timestamp
    }
    return render_to_response('user/issues.html',
                              response_dictionary,
                              context_instance=RequestContext(request))
Exemple #4
0
def todo(request):
    current = 'todo'
    feedAction = FeedAction()
    feedAction.set_user_position(request.user.id, PositionKey.TODO)
    scene_id = feedAction.get_user_attr(request.user.id, AttrKey.SCENE_ID)
    if scene_id is None:
        scene_id = 0
    return todo_scene(request, scene_id)
Exemple #5
0
def explore(request):
    current = 'explore'
    feedAction = FeedAction()
    feedAction.set_user_position(request.user.id, PositionKey.EXPLORE)
    latest_feeds = feedAction.get_latest_feeds(0, 100)
    feeds_as_json = latest_feeds_as_json(request, latest_feeds)
    response_dictionary = {'current': current, 'feeds_as_json': feeds_as_json}
    return render_to_response('user/explore.html',
                              response_dictionary,
                              context_instance=RequestContext(request))
Exemple #6
0
def notif(request, username):
    (teamUser, teamUserprofile) = _get_team_user_userprofile(request, username)
    current = 'notif'; title = u'%s / 我的通知' % (teamUser.username)
    feedAction = FeedAction()
    feedAction.set_user_position(teamUser.id, PositionKey.NOTIF)
    notifMessages = FeedManager.list_notifmessage_by_toUserId_teamUserId(request.user.id, teamUser.id, 0, 500)
    response_dictionary = {'current': current, 'title': title, 'notifMessages': notifMessages}
    response_dictionary.update(_get_common_team_dict(request, teamUser, teamUserprofile))
    return render_to_response('team/notif.html',
                          response_dictionary,
                          context_instance=RequestContext(request))
Exemple #7
0
def pull_request(request, username):
    (teamUser, teamUserprofile) = _get_team_user_userprofile(request, username)
    current = 'pull'; title = u'%s / 我创建的合并请求' % (teamUser.username)
    feedAction = FeedAction()
    feedAction.set_user_position(teamUser.id, PositionKey.PULL)
    pullRequests = RepoManager.list_pullRequest_by_teamUserId_pullUserId(teamUser.id, request.user.id)
    response_dictionary = {'current': current, 'title': title, 'pullRequests': pullRequests}
    response_dictionary.update(_get_common_team_dict(request, teamUser, teamUserprofile))
    return render_to_response('team/pull_request.html',
                          response_dictionary,
                          context_instance=RequestContext(request))
Exemple #8
0
def timeline(request, username):
    (teamUser, teamUserprofile) = _get_team_user_userprofile(request, username)
    current = 'timeline'; title = u'%s / 动态' % (teamUser.username)
    feedAction = FeedAction()
    feedAction.set_user_position(teamUser.id, PositionKey.TIMELINE)
    pri_user_feeds = feedAction.get_pri_user_feeds(teamUser.id, 0, 100)
    pub_user_feeds = feedAction.get_pub_user_feeds(teamUser.id, 0, 100)
    feeds_as_json = get_feeds_as_json(request, pri_user_feeds, pub_user_feeds)
    response_dictionary = {'current': current, 'title': title, 'feeds_as_json': feeds_as_json}
    response_dictionary.update(_get_common_team_dict(request, teamUser, teamUserprofile))
    return render_to_response('team/timeline.html',
                          response_dictionary,
                          context_instance=RequestContext(request))
Exemple #9
0
def todo_scene(request, env_scene_id):
    current = 'todo'
    feedAction = FeedAction()
    feedAction.set_user_position(request.user.id, PositionKey.TODO)
    feedAction.set_user_attr(request.user.id, AttrKey.SCENE_ID, env_scene_id)
    scene = get_scene(request.user.id, env_scene_id)
    scene_list = ToDoListManager.list_scene_by_userId(request.user.id, 0, 100)
    todoing_list = ToDoListManager.list_doing_todo_by_userId_sceneId(request.user.id, scene.id, 0, 100)
    todone_list = ToDoListManager.list_done_todo_by_userId_sceneId(request.user.id, scene.id, 0, 100)
    response_dictionary = {'current': current, 'scene_list': scene_list, 'scene': scene, 'todoing_list': todoing_list, 'todone_list': todone_list}
    return render_to_response('user/todo.html',
                          response_dictionary,
                          context_instance=RequestContext(request))
Exemple #10
0
def pull_request(request):
    current = 'pull'
    title = u'%s / 我创建的合并请求' % (request.user.username)
    feedAction = FeedAction()
    feedAction.set_user_position(request.user.id, PositionKey.PULL)
    pullRequests = RepoManager.list_pullRequest_by_pullUserId(request.user.id)
    response_dictionary = {
        'current': current,
        'title': title,
        'pullRequests': pullRequests
    }
    return render_to_response('user/pull_request.html',
                              response_dictionary,
                              context_instance=RequestContext(request))
Exemple #11
0
def pull_request(request, username):
    (teamUser, teamUserprofile) = _get_team_user_userprofile(request, username)
    current = 'pull'
    title = u'%s / 我创建的合并请求' % (teamUser.username)
    feedAction = FeedAction()
    feedAction.set_user_position(teamUser.id, PositionKey.PULL)
    pullRequests = RepoManager.list_pullRequest_by_teamUserId_pullUserId(
        teamUser.id, request.user.id)
    response_dictionary = {
        'current': current,
        'title': title,
        'pullRequests': pullRequests
    }
    response_dictionary.update(
        _get_common_team_dict(request, teamUser, teamUserprofile))
    return render_to_response('team/pull_request.html',
                              response_dictionary,
                              context_instance=RequestContext(request))
Exemple #12
0
def notif(request, username):
    (teamUser, teamUserprofile) = _get_team_user_userprofile(request, username)
    current = 'notif'
    title = u'%s / 我的通知' % (teamUser.username)
    feedAction = FeedAction()
    feedAction.set_user_position(teamUser.id, PositionKey.NOTIF)
    notifMessages = FeedManager.list_notifmessage_by_toUserId_teamUserId(
        request.user.id, teamUser.id, 0, 500)
    response_dictionary = {
        'current': current,
        'title': title,
        'notifMessages': notifMessages
    }
    response_dictionary.update(
        _get_common_team_dict(request, teamUser, teamUserprofile))
    return render_to_response('team/notif.html',
                              response_dictionary,
                              context_instance=RequestContext(request))
Exemple #13
0
def pull_merge(request):
    current = 'pull'
    title = u'%s / 需要我处理的合并请求' % (request.user.username)
    feedAction = FeedAction()
    feedAction.set_user_position(request.user.id, PositionKey.PULL)
    recently_timestamp_astime = feedAction.get_recently_timestamp_astime(
        request.user.id, AttrKey.RECENTLY_TIME_PULL)
    pullRequests = RepoManager.list_pullRequest_by_mergeUserId(request.user.id)
    feedAction.set_recently_timestamp_now(request.user.id,
                                          AttrKey.RECENTLY_TIME_PULL)
    response_dictionary = {
        'current': current,
        'title': title,
        'pullRequests': pullRequests,
        'recently_timestamp_astime': recently_timestamp_astime
    }
    return render_to_response('user/pull_merge.html',
                              response_dictionary,
                              context_instance=RequestContext(request))
Exemple #14
0
def timeline(request, username):
    (teamUser, teamUserprofile) = _get_team_user_userprofile(request, username)
    current = 'timeline'
    title = u'%s / 动态' % (teamUser.username)
    feedAction = FeedAction()
    feedAction.set_user_position(teamUser.id, PositionKey.TIMELINE)
    pri_user_feeds = feedAction.get_pri_user_feeds(teamUser.id, 0, 100)
    pub_user_feeds = feedAction.get_pub_user_feeds(teamUser.id, 0, 100)
    feeds_as_json = get_feeds_as_json(request, pri_user_feeds, pub_user_feeds)
    response_dictionary = {
        'current': current,
        'title': title,
        'feeds_as_json': feeds_as_json
    }
    response_dictionary.update(
        _get_common_team_dict(request, teamUser, teamUserprofile))
    return render_to_response('team/timeline.html',
                              response_dictionary,
                              context_instance=RequestContext(request))
Exemple #15
0
def issues(request, username, page):
    (teamUser, teamUserprofile) = _get_team_user_userprofile(request, username)
    current = 'issues'; title = u'%s / 问题' % (teamUser.username)
    feedAction = FeedAction()
    feedAction.set_user_position(teamUser.id, PositionKey.ISSUES)
    page = int(page); page_size = 50; offset = page*page_size; row_count = page_size + 1
    issues = IssueManager.list_issues_by_teamUserId_assigned(teamUser.id, request.user.id, 'modify_time', offset, row_count)

    hasPre = False ; hasNext = False
    if page > 0:
        hasPre = True 
    if len(issues) > page_size:
        hasNext = True
        issues.pop()
    response_dictionary = {'current': current, 'title': title, 'issues': issues, 'page': page, 'hasPre': hasPre, 'hasNext': hasNext}
    response_dictionary.update(_get_common_team_dict(request, teamUser, teamUserprofile))
    return render_to_response('team/issues.html',
                          response_dictionary,
                          context_instance=RequestContext(request))
Exemple #16
0
def timeline(request):
    current = 'timeline'
    title = u'%s / 我的动态' % (request.user.username)
    feedAction = FeedAction()
    feedAction.set_user_position(request.user.id, PositionKey.TIMELINE)
    recently_timestamp = feedAction.get_recently_timestamp(
        request.user.id, AttrKey.RECENTLY_TIME_TIMELINE)
    pri_user_feeds = feedAction.get_pri_user_feeds(request.user.id, 0, 100)
    pub_user_feeds = feedAction.get_pub_user_feeds(request.user.id, 0, 100)
    feeds_as_json = get_feeds_as_json(request, pri_user_feeds, pub_user_feeds)
    feedAction.set_recently_timestamp_now(request.user.id,
                                          AttrKey.RECENTLY_TIME_TIMELINE)
    response_dictionary = {
        'current': current,
        'title': title,
        'feeds_as_json': feeds_as_json,
        'recently_timestamp': recently_timestamp
    }
    return render_to_response('user/timeline.html',
                              response_dictionary,
                              context_instance=RequestContext(request))
Exemple #17
0
def notif(request):
    current = 'notif'
    title = u'%s / 我的通知' % (request.user.username)
    feedAction = FeedAction()
    feedAction.set_user_position(request.user.id, PositionKey.NOTIF)
    recently_timestamp_astime = feedAction.get_recently_timestamp_astime(
        request.user.id, AttrKey.RECENTLY_TIME_NOTIF)
    notifMessages = FeedManager.list_notifmessage_by_userId(
        request.user.id, 0, 500)
    if request.userprofile.unread_message != 0:
        request.userprofile.unread_message = 0
        request.userprofile.save()
    feedAction.set_recently_timestamp_now(request.user.id,
                                          AttrKey.RECENTLY_TIME_NOTIF)
    response_dictionary = {
        'current': current,
        'title': title,
        'notifMessages': notifMessages,
        'recently_timestamp_astime': recently_timestamp_astime
    }
    return render_to_response('user/notif.html',
                              response_dictionary,
                              context_instance=RequestContext(request))