Example #1
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))
Example #2
0
def user(request, user_name):
    title = u'%s / 概括' % user_name
    gsuser = GsuserManager.get_user_by_name(user_name)
    if gsuser is None:
        raise Http404
    gsuserprofile = GsuserManager.get_userprofile_by_id(gsuser.id)
    if gsuserprofile.is_team_account == 1 and TeamManager.is_teamMember(
            gsuser.id, request.user.id):
        return HttpResponseRedirect('/%s/-/dashboard/' % user_name)
    recommendsForm = RecommendsForm()
    repos = []
    if gsuser.id == request.user.id:
        repos = RepoManager.list_repo_by_userId(gsuser.id, 0, 100)
    else:
        repos = RepoManager.list_unprivate_repo_by_userId(gsuser.id, 0, 100)

    now = datetime.now()
    last30days = timeutils.getlast30days(now)
    last30days_commit = get_last30days_commit(gsuser)

    feedAction = FeedAction()

    raw_watch_repos = feedAction.get_watch_repos(gsuser.id, 0, 10)
    watch_repo_ids = [int(x[0]) for x in raw_watch_repos]
    watch_repos_map = RepoManager.merge_repo_map(watch_repo_ids)
    watch_repos = [
        watch_repos_map[x] for x in watch_repo_ids if x in watch_repos_map
    ]

    pri_user_feeds = feedAction.get_pri_user_feeds(gsuser.id, 0, 10)
    pub_user_feeds = feedAction.get_pub_user_feeds(gsuser.id, 0, 10)
    feeds_as_json = get_feeds_as_json(request, pri_user_feeds, pub_user_feeds)

    star_repos = RepoManager.list_star_repo(gsuser.id, 0, 20)

    response_dictionary = {
        'mainnav': 'user',
        'title': title,
        'recommendsForm': recommendsForm,
        'repos': repos,
        'watch_repos': watch_repos,
        'star_repos': star_repos,
        'last30days': last30days,
        'last30days_commit': last30days_commit,
        'feeds_as_json': feeds_as_json
    }
    response_dictionary.update(
        get_common_user_dict(request, gsuser, gsuserprofile))
    return render_to_response('user/user.html',
                              response_dictionary,
                              context_instance=RequestContext(request))
Example #3
0
def active(request, user_name):
    title = u'%s / 动态' % user_name
    gsuser = GsuserManager.get_user_by_name(user_name)
    if gsuser is None:
        raise Http404
    gsuserprofile = GsuserManager.get_userprofile_by_id(gsuser.id)
    feedAction = FeedAction()
    pri_user_feeds = feedAction.get_pri_user_feeds(gsuser.id, 0, 50)
    pub_user_feeds = feedAction.get_pub_user_feeds(gsuser.id, 0, 50)
    feeds_as_json = get_feeds_as_json(request, pri_user_feeds, pub_user_feeds)
    response_dictionary = {'mainnav': 'user', 'title': title, 'feeds_as_json': feeds_as_json}
    response_dictionary.update(get_common_user_dict(request, gsuser, gsuserprofile))
    return render_to_response('user/active.html',
                          response_dictionary,
                          context_instance=RequestContext(request))
Example #4
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))
Example #5
0
def active(request, user_name):
    title = u'%s / 动态' % user_name
    gsuser = GsuserManager.get_user_by_name(user_name)
    if gsuser is None:
        raise Http404
    gsuserprofile = GsuserManager.get_userprofile_by_id(gsuser.id)
    feedAction = FeedAction()
    pri_user_feeds = feedAction.get_pri_user_feeds(gsuser.id, 0, 50)
    pub_user_feeds = feedAction.get_pub_user_feeds(gsuser.id, 0, 50)
    feeds_as_json = get_feeds_as_json(request, pri_user_feeds, pub_user_feeds)
    response_dictionary = {
        'mainnav': 'user',
        'title': title,
        'feeds_as_json': feeds_as_json
    }
    response_dictionary.update(
        get_common_user_dict(request, gsuser, gsuserprofile))
    return render_to_response('user/active.html',
                              response_dictionary,
                              context_instance=RequestContext(request))
Example #6
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))
Example #7
0
def user(request, user_name):
    title = u'%s / 概括' % user_name
    gsuser = GsuserManager.get_user_by_name(user_name)
    if gsuser is None:
        raise Http404
    gsuserprofile = GsuserManager.get_userprofile_by_id(gsuser.id)
    if gsuserprofile.is_team_account == 1 and TeamManager.is_teamMember(gsuser.id, request.user.id):
        return HttpResponseRedirect('/%s/-/dashboard/' % user_name)
    recommendsForm = RecommendsForm()
    repos = []
    if gsuser.id == request.user.id:
        repos = RepoManager.list_repo_by_userId(gsuser.id, 0, 100)
    else:
        repos = RepoManager.list_unprivate_repo_by_userId(gsuser.id, 0, 100)

    now = datetime.now()
    last30days = timeutils.getlast30days(now)
    last30days_commit = get_last30days_commit(gsuser)

    feedAction = FeedAction()

    raw_watch_repos = feedAction.get_watch_repos(gsuser.id, 0, 10)
    watch_repo_ids = [int(x[0]) for x in raw_watch_repos]
    watch_repos_map = RepoManager.merge_repo_map(watch_repo_ids)
    watch_repos = [watch_repos_map[x] for x in watch_repo_ids if x in watch_repos_map]

    pri_user_feeds = feedAction.get_pri_user_feeds(gsuser.id, 0, 10)
    pub_user_feeds = feedAction.get_pub_user_feeds(gsuser.id, 0, 10)
    feeds_as_json = get_feeds_as_json(request, pri_user_feeds, pub_user_feeds)

    star_repos = RepoManager.list_star_repo(gsuser.id, 0, 20)

    response_dictionary = {'mainnav': 'user', 'title': title, 'recommendsForm': recommendsForm, 'repos': repos, 'watch_repos': watch_repos, 'star_repos': star_repos, 'last30days': last30days, 'last30days_commit': last30days_commit, 'feeds_as_json': feeds_as_json}
    response_dictionary.update(get_common_user_dict(request, gsuser, gsuserprofile))
    return render_to_response('user/user.html',
                          response_dictionary,
                          context_instance=RequestContext(request))