示例#1
0
def get_common_user_dict(request, gsuser, gsuserprofile):
    feedAction = FeedAction()
    raw_watch_users = feedAction.get_watch_users(gsuser.id, 0, 10)
    raw_bewatch_users = feedAction.get_bewatch_users(gsuser.id, 0, 10)
    watch_user_ids = [int(x[0]) for x in raw_watch_users]
    bewatch_user_ids = [int(x[0]) for x in raw_bewatch_users]
    watch_users_map = GsuserManager.map_users(watch_user_ids)
    bewatch_users_map = GsuserManager.map_users(bewatch_user_ids)
    watch_users = [
        watch_users_map[x] for x in watch_user_ids if x in watch_users_map
    ]
    bewatch_users = [
        bewatch_users_map[x] for x in bewatch_user_ids
        if x in bewatch_users_map
    ]
    raw_recommends = GsuserManager.list_recommend_by_userid(gsuser.id, 0, 20)
    recommends = __conver_to_recommends_vo(raw_recommends)

    is_watched_user = False
    if request.user.is_authenticated():
        is_watched_user = RepoManager.is_watched_user(request.user.id,
                                                      gsuser.id)
    return {
        'gsuser': gsuser,
        'gsuserprofile': gsuserprofile,
        'watch_users': watch_users,
        'bewatch_users': bewatch_users,
        'recommends': recommends,
        'is_watched_user': is_watched_user,
        'show_common': True
    }
示例#2
0
文件: views.py 项目: ZheYuan/gitshell
def watch_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)

    feedAction = FeedAction()
    raw_watch_users = feedAction.get_watch_users(gsuser.id, 0, 100)
    watch_user_ids = [int(x[0]) for x in raw_watch_users]
    watch_users_map = GsuserManager.map_users(watch_user_ids)
    watch_users = [watch_users_map[x] for x in watch_user_ids if x in watch_users_map]

    raw_bewatch_users = feedAction.get_bewatch_users(gsuser.id, 0, 100)
    bewatch_user_ids = [int(x[0]) for x in raw_bewatch_users]
    bewatch_users_map = GsuserManager.map_users(bewatch_user_ids)
    bewatch_users = [bewatch_users_map[x] for x in bewatch_user_ids if x in bewatch_users_map]
    # fixed on detect
    need_fix = False
    if len(watch_users) != gsuserprofile.watch:
        gsuserprofile.watch = len(watch_users)
        need_fix = True
    if len(bewatch_users) < 100 and len(bewatch_users) != gsuserprofile.be_watched:
        gsuserprofile.be_watched = len(bewatch_users) 
        need_fix = True
    if need_fix:
        gsuserprofile.save()

    response_dictionary = {'mainnav': 'user', 'title': title, 'watch_users': watch_users, 'bewatch_users': bewatch_users}
    response_dictionary.update(get_common_user_dict(request, gsuser, gsuserprofile))
    return render_to_response('user/watch_user.html',
                          response_dictionary,
                          context_instance=RequestContext(request))
示例#3
0
def watch_repo(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()
    raw_watch_repos = feedAction.get_watch_repos(gsuser.id, 0, 100)
    watch_repo_ids = [int(x[0]) for x in raw_watch_repos]
    watch_repos_map = RepoManager.merge_repo_map_ignore_visibly(watch_repo_ids)
    watch_repos = [
        watch_repos_map[x] for x in watch_repo_ids if x in watch_repos_map
    ]

    response_dictionary = {
        'mainnav': 'user',
        'title': title,
        'watch_repos': watch_repos
    }
    # fixed on detect
    if len(watch_repos) != gsuserprofile.watchrepo:
        gsuserprofile.watchrepo = len(watch_repos)
        gsuserprofile.save()

    response_dictionary.update(
        get_common_user_dict(request, gsuser, gsuserprofile))
    return render_to_response('user/watch_repo.html',
                              response_dictionary,
                              context_instance=RequestContext(request))
示例#4
0
 def watch_user(self, userprofile, watch_userprofile):
     if userprofile.id == watch_userprofile.id:
         return False
     if userprofile.watch >= 100:
         return False
     watchHistorys = query(WatchHistory, userprofile.id,
                           'watchhistory_s_user',
                           [userprofile.id, watch_userprofile.id])
     feedAction = FeedAction()
     timestamp = int(time.time())
     if len(watchHistorys) > 0:
         # redis action
         feedAction.add_watch_user(userprofile.id, timestamp,
                                   watch_userprofile.id)
         feedAction.add_bewatch_user(watch_userprofile.id, timestamp,
                                     userprofile.id)
         return True
     watchHistory = WatchHistory()
     watchHistory.user_id = userprofile.id
     watchHistory.watch_user_id = watch_userprofile.id
     watchHistory.save()
     userprofile.watch = userprofile.watch + 1
     userprofile.save()
     watch_userprofile.be_watched = watch_userprofile.be_watched + 1
     watch_userprofile.save()
     # redis action
     feedAction.add_watch_user(userprofile.id, timestamp,
                               watch_userprofile.id)
     feedAction.add_bewatch_user(watch_userprofile.id, timestamp,
                                 userprofile.id)
     return True
示例#5
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))
示例#6
0
文件: views.py 项目: drew-sj/gitshell
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)
示例#7
0
文件: views.py 项目: drew-sj/gitshell
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))
示例#8
0
文件: views.py 项目: drew-sj/gitshell
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))
示例#9
0
 def watch_user(self, userprofile, watch_userprofile):
     if userprofile.id == watch_userprofile.id:
         return False
     if userprofile.watch >= 100:
         return False
     watchHistorys = query(WatchHistory, userprofile.id, 'watchhistory_s_user', [userprofile.id, watch_userprofile.id])
     feedAction = FeedAction()
     timestamp = int(time.time())
     if len(watchHistorys) > 0:
         # redis action
         feedAction.add_watch_user(userprofile.id, timestamp, watch_userprofile.id)
         feedAction.add_bewatch_user(watch_userprofile.id, timestamp, userprofile.id)
         return True
     watchHistory = WatchHistory()
     watchHistory.user_id = userprofile.id
     watchHistory.watch_user_id = watch_userprofile.id
     watchHistory.save()
     userprofile.watch = userprofile.watch + 1
     userprofile.save()
     watch_userprofile.be_watched = watch_userprofile.be_watched + 1
     watch_userprofile.save()
     # redis action
     feedAction.add_watch_user(userprofile.id, timestamp, watch_userprofile.id)
     feedAction.add_bewatch_user(watch_userprofile.id, timestamp, userprofile.id)
     return True
示例#10
0
文件: views.py 项目: ZheYuan/gitshell
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))
示例#11
0
文件: views.py 项目: ZheYuan/gitshell
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))
示例#12
0
文件: views.py 项目: ZheYuan/gitshell
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))
示例#13
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))
示例#14
0
 def delete_repo(self, user, userprofile, repo):
     repo.visibly = 1
     repo.last_push_time = datetime.now()
     userprofile.used_quote = userprofile.used_quote - repo.used_quote
     if userprofile.used_quote < 0:
         userprofile.used_quote = 0
     userprofile.save()
     delete_path = '%s/%s' % (DELETE_REPO_PATH, repo.id)
     abs_repopath = repo.get_abs_repopath()
     if os.path.exists(abs_repopath):
         shutil.move(abs_repopath, delete_path)
     feedAction = FeedAction()
     feedAction.delete_repo_feed(repo.id)
     repo.save()
示例#15
0
文件: views.py 项目: drew-sj/gitshell
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))
示例#16
0
 def delete_repo(self, user, userprofile, repo):
     repo.visibly = 1
     repo.last_push_time = datetime.now()
     userprofile.used_quote = userprofile.used_quote - repo.used_quote
     if userprofile.used_quote < 0:
         userprofile.used_quote = 0
     userprofile.save()
     delete_path = '%s/%s' % (DELETE_REPO_PATH, repo.id)
     abs_repopath = repo.get_abs_repopath()
     if os.path.exists(abs_repopath):
         shutil.move(abs_repopath, delete_path)
     feedAction = FeedAction()
     feedAction.delete_repo_feed(repo.id)
     repo.save()
示例#17
0
文件: views.py 项目: ZheYuan/gitshell
def dashboard(request, username):
    (teamUser, teamUserprofile) = _get_team_user_userprofile(request, username)
    feedAction = FeedAction()
    goto = feedAction.get_user_position(teamUser.id)
    if goto == None:
        goto = PositionKey.TIMELINE
    if goto == PositionKey.TIMELINE:
        return timeline(request, username)
    elif goto == PositionKey.PULL:
        return pull_merge(request, username)
    elif goto == PositionKey.ISSUES:
        return issues(request, username, 0)
    elif goto == PositionKey.NOTIF:
        return notif(request, username)
    return timeline(request, username)
示例#18
0
文件: views.py 项目: ZheYuan/gitshell
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))
示例#19
0
def dashboard(request, username):
    (teamUser, teamUserprofile) = _get_team_user_userprofile(request, username)
    feedAction = FeedAction()
    goto = feedAction.get_user_position(teamUser.id)
    if goto == None:
        goto = PositionKey.TIMELINE
    if goto == PositionKey.TIMELINE:
        return timeline(request, username)
    elif goto == PositionKey.PULL:
        return pull_merge(request, username)
    elif goto == PositionKey.ISSUES:
        return issues(request, username, 0)
    elif goto == PositionKey.NOTIF:
        return notif(request, username)
    return timeline(request, username)
示例#20
0
def bulk_create_commits(user, userprofile, repo, repopath, push_id, pushUser,
                        oldrev, newrev, refname):

    # list raw commitHistorys
    raw_commitHistorys = __list_raw_commitHistorys(repo, repopath, oldrev,
                                                   newrev, refname)

    # list uniq commitHistorys and convert to pushRevRef
    commitHistorys = __list_not_exists_commitHistorys(repo, raw_commitHistorys)
    if len(commitHistorys) == 0:
        return 0
    (pushRevRef,
     commitHistorys) = __create_pushRevRef_and_save(repo, commitHistorys,
                                                    push_id, pushUser, oldrev,
                                                    newrev, refname)

    feedAction = FeedAction()
    # generate feed data
    push_revref_feed = __get_push_revref_feed(repo, pushRevRef)
    __add_user_and_repo_feed(feedAction, userprofile, repo, pushRevRef,
                             push_revref_feed)

    # user username, email dict
    (member_username_dict,
     member_email_dict) = __get_member_username_email_dict(repo)

    # at somebody action
    __notif(commitHistorys, repo, member_username_dict, member_email_dict)

    # stats action
    __stats(feedAction, commitHistorys, repo, member_username_dict,
            member_email_dict)

    return len(commitHistorys)
示例#21
0
文件: views.py 项目: ZheYuan/gitshell
def get_common_user_dict(request, gsuser, gsuserprofile):
    feedAction = FeedAction()
    raw_watch_users = feedAction.get_watch_users(gsuser.id, 0, 10)
    raw_bewatch_users = feedAction.get_bewatch_users(gsuser.id, 0, 10)
    watch_user_ids = [int(x[0]) for x in raw_watch_users]
    bewatch_user_ids = [int(x[0]) for x in raw_bewatch_users]
    watch_users_map = GsuserManager.map_users(watch_user_ids)
    bewatch_users_map = GsuserManager.map_users(bewatch_user_ids)
    watch_users = [watch_users_map[x] for x in watch_user_ids if x in watch_users_map]
    bewatch_users = [bewatch_users_map[x] for x in bewatch_user_ids if x in bewatch_users_map]
    raw_recommends = GsuserManager.list_recommend_by_userid(gsuser.id, 0, 20)
    recommends = __conver_to_recommends_vo(raw_recommends)

    is_watched_user = False
    if request.user.is_authenticated():
        is_watched_user = RepoManager.is_watched_user(request.user.id, gsuser.id)
    return {'gsuser': gsuser, 'gsuserprofile': gsuserprofile, 'watch_users': watch_users, 'bewatch_users': bewatch_users, 'recommends': recommends, 'is_watched_user': is_watched_user, 'show_common': True}
示例#22
0
文件: views.py 项目: drew-sj/gitshell
def explore(request):
    repo_ids = get_hot_repo_ids()
    raw_repos = RepoManager.list_repo_by_ids(repo_ids)
    repos = [x for x in raw_repos if x.auth_type != 2]
    user_ids = [x.user_id for x in repos]
    users_dict = GsuserManager.map_users(user_ids)
    username_dict = dict([(users_dict[x]['id'], users_dict[x]['username']) for x in users_dict])
    userimgurl_dict = dict([(users_dict[x]['id'], users_dict[x]['imgurl']) for x in users_dict])

    feedAction = FeedAction()
    latest_feeds = feedAction.get_latest_feeds(0, 100)
    feeds_as_json = latest_feeds_as_json(request, latest_feeds)

    response_dictionary = {'repos': repos, 'users_dict': users_dict, 'username_dict': username_dict, 'userimgurl_dict': userimgurl_dict, 'feeds_as_json': feeds_as_json}
    return render_to_response('explore/explore.html',
                          response_dictionary,
                          context_instance=RequestContext(request))
示例#23
0
 def wrap(request, *args, **kwargs):
     if len(args) >= 2:
         user_name = args[0]; repo_name = args[1]
         repo = RepoManager.get_repo_by_name(user_name, repo_name)
         if repo is None:
             return error_with_reason(request, 'repo_not_found')
         if repo.auth_type != 0 and not request.user.is_authenticated():
             return HttpResponseRedirect('/login/?next=' + urlquote(request.path))
         is_allowed_access_repo = RepoManager.is_allowed_access_repo(repo, request.user, REPO_PERMISSION.READ_ONLY)
         if not is_allowed_access_repo:
             if request.method == 'POST':
                 return json_failed(403, u'没有管理权限')
             return error_with_reason(request, 'repo_permission_denied')
     if request.user.is_authenticated():
         feedAction = FeedAction()
         feedAction.add_recently_view_repo_now(request.user.id, repo.id)
     return function(request, *args, **kwargs)
示例#24
0
文件: views.py 项目: drew-sj/gitshell
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))
示例#25
0
def watch_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)

    feedAction = FeedAction()
    raw_watch_users = feedAction.get_watch_users(gsuser.id, 0, 100)
    watch_user_ids = [int(x[0]) for x in raw_watch_users]
    watch_users_map = GsuserManager.map_users(watch_user_ids)
    watch_users = [
        watch_users_map[x] for x in watch_user_ids if x in watch_users_map
    ]

    raw_bewatch_users = feedAction.get_bewatch_users(gsuser.id, 0, 100)
    bewatch_user_ids = [int(x[0]) for x in raw_bewatch_users]
    bewatch_users_map = GsuserManager.map_users(bewatch_user_ids)
    bewatch_users = [
        bewatch_users_map[x] for x in bewatch_user_ids
        if x in bewatch_users_map
    ]
    # fixed on detect
    need_fix = False
    if len(watch_users) != gsuserprofile.watch:
        gsuserprofile.watch = len(watch_users)
        need_fix = True
    if len(bewatch_users) < 100 and len(
            bewatch_users) != gsuserprofile.be_watched:
        gsuserprofile.be_watched = len(bewatch_users)
        need_fix = True
    if need_fix:
        gsuserprofile.save()

    response_dictionary = {
        'mainnav': 'user',
        'title': title,
        'watch_users': watch_users,
        'bewatch_users': bewatch_users
    }
    response_dictionary.update(
        get_common_user_dict(request, gsuser, gsuserprofile))
    return render_to_response('user/watch_user.html',
                              response_dictionary,
                              context_instance=RequestContext(request))
示例#26
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))
示例#27
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))
示例#28
0
文件: views.py 项目: ZheYuan/gitshell
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))
示例#29
0
 def wrap(request, *args, **kwargs):
     if len(args) >= 2:
         user_name = args[0]; repo_name = args[1]
         repo = RepoManager.get_repo_by_name(user_name, repo_name)
         if repo is None:
             return error_with_reason(request, 'repo_not_found')
         if not request.user.is_authenticated():
             return HttpResponseRedirect('/login/?next=' + urlquote(request.path))
         from gitshell.team.models import TeamManager
         user_permission = TeamManager.get_repo_user_permission(repo, request.user)
         if user_permission < REPO_PERMISSION.ADMIN:
             if user_permission >= REPO_PERMISSION.WEB_VIEW:
                 return HttpResponseRedirect('/%s/%s/' % (user_name, repo_name))
             if request.method == 'POST':
                 return json_failed(403, u'没有管理权限')
             return error_with_reason(request, 'repo_permission_denied')
     if request.user.is_authenticated():
         feedAction = FeedAction()
         feedAction.add_recently_view_repo_now(request.user.id, repo.id)
     return function(request, *args, **kwargs)
示例#30
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))
示例#31
0
 def wrap(request, *args, **kwargs):
     if len(args) >= 2:
         user_name = args[0]
         repo_name = args[1]
         repo = RepoManager.get_repo_by_name(user_name, repo_name)
         if repo is None:
             return error_with_reason(request, 'repo_not_found')
         if repo.auth_type != 0 and not request.user.is_authenticated():
             return HttpResponseRedirect('/login/?next=' +
                                         urlquote(request.path))
         is_allowed_access_repo = RepoManager.is_allowed_access_repo(
             repo, request.user, REPO_PERMISSION.READ_ONLY)
         if not is_allowed_access_repo:
             if request.method == 'POST':
                 return json_failed(403, u'没有管理权限')
             return error_with_reason(request, 'repo_permission_denied')
     if request.user.is_authenticated():
         feedAction = FeedAction()
         feedAction.add_recently_view_repo_now(request.user.id, repo.id)
     return function(request, *args, **kwargs)
示例#32
0
 def unwatch_repo(self, user, userprofile, watch_repo):
     watchHistorys = query(WatchHistory, userprofile.id, 'watchhistory_s_repo', [userprofile.id, watch_repo.id])
     watchHistory = None
     if len(watchHistorys) > 0:
         watchHistory = watchHistorys[0]
     if watchHistory is not None:
         watchHistory.visibly = 1
         watchHistory.save()
         userprofile.watchrepo = userprofile.watchrepo - 1
         if userprofile.watchrepo < 0:
             userprofile.watchrepo = 0
         userprofile.save()
         watch_repo.watch = watch_repo.watch - 1
         if watch_repo.watch < 0:
             watch_repo.watch = 0
         watch_repo.save()
     # redis action
     feedAction = FeedAction()
     feedAction.remove_watch_repo(userprofile.id, watch_repo.id)
     return True
示例#33
0
文件: views.py 项目: drew-sj/gitshell
def dashboard(request):
    feedAction = FeedAction()
    goto = feedAction.get_user_position(request.user.id)
    if goto == None:
        goto = PositionKey.FEED
    if goto == PositionKey.FEED:
        return feed(request)
    elif goto == PositionKey.TIMELINE:
        return timeline(request)
    elif goto == PositionKey.TODO:
        return todo(request)
    elif goto == PositionKey.PULL:
        return pull_merge(request)
    elif goto == PositionKey.ISSUES:
        return issues(request, 0)
    elif goto == PositionKey.EXPLORE:
        return explore(request)
    elif goto == PositionKey.NOTIF:
        return notif(request)
    return feed(request)
示例#34
0
    def feed_issue_change(self, user, repo, orgi_issue, current_issue_id):
        current_issue = IssueManager.get_issue_by_id(current_issue_id)
        if current_issue is None:
            return
        feed_cate = FEED_CATE.ISSUES
        message = ''
        if orgi_issue is None and current_issue is not None:
            feed_type = FEED_TYPE.ISSUES_CREATE
            message = u'新建了问题'
        if orgi_issue is not None and (
                orgi_issue.subject != current_issue.subject
                or orgi_issue.content != current_issue.content
                or orgi_issue.category != current_issue.category):
            feed_type = FEED_TYPE.ISSUES_UPDATE
            message = u'更新了问题'
        # status update
        status_changes = []
        if orgi_issue is not None:
            if orgi_issue.tracker != current_issue.tracker:
                status_changes.append(
                    u'跟踪: ' + ISSUE_ATTR_DICT.TRACKER[current_issue.tracker])
            if orgi_issue.status != current_issue.status:
                status_changes.append(
                    u'状态: ' + ISSUE_ATTR_DICT.STATUS[current_issue.status])
            if orgi_issue.assigned != current_issue.assigned:
                assigned_user = GsuserManager.get_user_by_id(
                    current_issue.assigned)
                if assigned_user is not None:
                    status_changes.append(u'指派给: @' + assigned_user.username)
            if orgi_issue.priority != current_issue.priority:
                status_changes.append(
                    u'优先级: ' +
                    ISSUE_ATTR_DICT.PRIORITY[current_issue.priority])

            if len(status_changes) > 0:
                message = ', '.join(status_changes)
                feed_type = FEED_TYPE.ISSUES_STATUS_CHANGE

        if message != '':
            feed = Feed.create(user.id, repo.id, feed_cate, feed_type,
                               current_issue.id)
            # TODO
            feed.first_refname = message
            feed.save()
            feedAction = FeedAction()
            timestamp = float(time.mktime(feed.create_time.timetuple()))
            feedAction.add_repo_feed(repo.id, timestamp, feed.id)
            if repo.auth_type == 2:
                feedAction.add_pri_user_feed(user.id, timestamp, feed.id)
            else:
                feedAction.add_pub_user_feed(user.id, timestamp, feed.id)
示例#35
0
 def unwatch_user(self, userprofile, watch_userprofile):
     if userprofile.id == watch_userprofile.id:
         return False
     watchHistorys = query(WatchHistory, userprofile.id,
                           'watchhistory_s_user',
                           [userprofile.id, watch_userprofile.id])
     watchHistory = None
     if len(watchHistorys) > 0:
         watchHistory = watchHistorys[0]
     if watchHistory is not None:
         watchHistory.visibly = 1
         watchHistory.save()
         userprofile.watch = userprofile.watch - 1
         if userprofile.watch < 0:
             userprofile.watch = 0
         userprofile.save()
         watch_userprofile.be_watched = watch_userprofile.be_watched - 1
         if watch_userprofile.be_watched < 0:
             watch_userprofile.be_watched = 0
         watch_userprofile.save()
     # redis action
     feedAction = FeedAction()
     feedAction.remove_watch_user(userprofile.id, watch_userprofile.id)
     feedAction.remove_bewatch_user(watch_userprofile.id, userprofile.id)
     return True
示例#36
0
 def watch_repo(self, user, userprofile, watch_repo):
     if watch_repo.auth_type == 2:
         if not self.is_repo_member(watch_repo, user):
             return False
     if userprofile.watchrepo >= 100:
         return False
     watchHistorys = query(WatchHistory, userprofile.id,
                           'watchhistory_s_repo',
                           [userprofile.id, watch_repo.id])
     feedAction = FeedAction()
     timestamp = int(time.time())
     if len(watchHistorys) > 0:
         # redis action
         feedAction.add_watch_repo(userprofile.id, timestamp, watch_repo.id)
         return True
     watchHistory = WatchHistory()
     watchHistory.user_id = userprofile.id
     watchHistory.watch_repo_id = watch_repo.id
     watchHistory.save()
     userprofile.watchrepo = userprofile.watchrepo + 1
     userprofile.save()
     watch_repo.watch = watch_repo.watch + 1
     watch_repo.save()
     # redis action
     feedAction.add_watch_repo(userprofile.id, timestamp, watch_repo.id)
     return True
示例#37
0
 def unwatch_repo(self, user, userprofile, watch_repo):
     watchHistorys = query(WatchHistory, userprofile.id,
                           'watchhistory_s_repo',
                           [userprofile.id, watch_repo.id])
     watchHistory = None
     if len(watchHistorys) > 0:
         watchHistory = watchHistorys[0]
     if watchHistory is not None:
         watchHistory.visibly = 1
         watchHistory.save()
         userprofile.watchrepo = userprofile.watchrepo - 1
         if userprofile.watchrepo < 0:
             userprofile.watchrepo = 0
         userprofile.save()
         watch_repo.watch = watch_repo.watch - 1
         if watch_repo.watch < 0:
             watch_repo.watch = 0
         watch_repo.save()
     # redis action
     feedAction = FeedAction()
     feedAction.remove_watch_repo(userprofile.id, watch_repo.id)
     return True
示例#38
0
文件: Forms.py 项目: drew-sj/gitshell
 def fill_username(self, userprofile, owner_user_id):
     feedAction = FeedAction()
     teamMembers = TeamManager.list_teamMember_by_userId(userprofile.id)
     username_choices = []
     username_choices.append((userprofile.username, userprofile.username))
     for teamMember in teamMembers:
         if teamMember.team_user_id == owner_user_id:
             username_choices.insert(0, (teamMember.team_user.username,
                                         teamMember.team_user.username))
             continue
         username_choices.append(
             (teamMember.team_user.username, teamMember.team_user.username))
     self.fields['username'] = forms.ChoiceField(choices=username_choices,
                                                 required=False)
示例#39
0
 def unwatch_user(self, userprofile, watch_userprofile):
     if userprofile.id == watch_userprofile.id:
         return False
     watchHistorys = query(WatchHistory, userprofile.id, 'watchhistory_s_user', [userprofile.id, watch_userprofile.id])
     watchHistory = None
     if len(watchHistorys) > 0:
         watchHistory = watchHistorys[0]
     if watchHistory is not None:
         watchHistory.visibly = 1
         watchHistory.save()
         userprofile.watch = userprofile.watch - 1
         if userprofile.watch < 0:
             userprofile.watch = 0
         userprofile.save()
         watch_userprofile.be_watched = watch_userprofile.be_watched - 1
         if watch_userprofile.be_watched < 0:
             watch_userprofile.be_watched = 0
         watch_userprofile.save()
     # redis action
     feedAction = FeedAction()
     feedAction.remove_watch_user(userprofile.id, watch_userprofile.id)
     feedAction.remove_bewatch_user(watch_userprofile.id, userprofile.id)
     return True
示例#40
0
文件: views.py 项目: ZheYuan/gitshell
def watch_repo(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()
    raw_watch_repos = feedAction.get_watch_repos(gsuser.id, 0, 100)
    watch_repo_ids = [int(x[0]) for x in raw_watch_repos]
    watch_repos_map = RepoManager.merge_repo_map_ignore_visibly(watch_repo_ids)
    watch_repos = [watch_repos_map[x] for x in watch_repo_ids if x in watch_repos_map]

    response_dictionary = {'mainnav': 'user', 'title': title, 'watch_repos': watch_repos}
    # fixed on detect
    if len(watch_repos) != gsuserprofile.watchrepo:
        gsuserprofile.watchrepo = len(watch_repos)
        gsuserprofile.save()

    response_dictionary.update(get_common_user_dict(request, gsuser, gsuserprofile))
    return render_to_response('user/watch_repo.html',
                          response_dictionary,
                          context_instance=RequestContext(request))
示例#41
0
文件: views.py 项目: ZheYuan/gitshell
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))
示例#42
0
 def wrap(request, *args, **kwargs):
     if len(args) >= 2:
         user_name = args[0]
         repo_name = args[1]
         repo = RepoManager.get_repo_by_name(user_name, repo_name)
         if repo is None:
             return error_with_reason(request, 'repo_not_found')
         if not request.user.is_authenticated():
             return HttpResponseRedirect('/login/?next=' +
                                         urlquote(request.path))
         from gitshell.team.models import TeamManager
         user_permission = TeamManager.get_repo_user_permission(
             repo, request.user)
         if user_permission < REPO_PERMISSION.ADMIN:
             if user_permission >= REPO_PERMISSION.WEB_VIEW:
                 return HttpResponseRedirect('/%s/%s/' %
                                             (user_name, repo_name))
             if request.method == 'POST':
                 return json_failed(403, u'没有管理权限')
             return error_with_reason(request, 'repo_permission_denied')
     if request.user.is_authenticated():
         feedAction = FeedAction()
         feedAction.add_recently_view_repo_now(request.user.id, repo.id)
     return function(request, *args, **kwargs)
示例#43
0
 def watch_repo(self, user, userprofile, watch_repo):
     if watch_repo.auth_type == 2:
         if not self.is_repo_member(watch_repo, user):
             return False
     if userprofile.watchrepo >= 100:
         return False
     watchHistorys = query(WatchHistory, userprofile.id, 'watchhistory_s_repo', [userprofile.id, watch_repo.id])
     feedAction = FeedAction()
     timestamp = int(time.time())
     if len(watchHistorys) > 0:
         # redis action
         feedAction.add_watch_repo(userprofile.id, timestamp, watch_repo.id)
         return True
     watchHistory = WatchHistory()
     watchHistory.user_id = userprofile.id
     watchHistory.watch_repo_id = watch_repo.id
     watchHistory.save()
     userprofile.watchrepo = userprofile.watchrepo + 1
     userprofile.save()
     watch_repo.watch = watch_repo.watch + 1
     watch_repo.save()
     # redis action
     feedAction.add_watch_repo(userprofile.id, timestamp, watch_repo.id)
     return True
示例#44
0
文件: views.py 项目: drew-sj/gitshell
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))
示例#45
0
文件: views.py 项目: drew-sj/gitshell
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))
示例#46
0
文件: views.py 项目: drew-sj/gitshell
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))
示例#47
0
    def feed_issue_change(self, user, repo, orgi_issue, current_issue_id):
        current_issue = IssueManager.get_issue_by_id(current_issue_id)
        if current_issue is None:
            return
        feed_cate = FEED_CATE.ISSUES
        message = ''
        if orgi_issue is None and current_issue is not None:
            feed_type = FEED_TYPE.ISSUES_CREATE
            message = u'新建了问题'
        if orgi_issue is not None and (orgi_issue.subject != current_issue.subject or orgi_issue.content != current_issue.content or orgi_issue.category != current_issue.category):
            feed_type = FEED_TYPE.ISSUES_UPDATE
            message = u'更新了问题'
        # status update
        status_changes = []
        if orgi_issue is not None:
            if orgi_issue.tracker != current_issue.tracker:
                status_changes.append(u'跟踪: ' + ISSUE_ATTR_DICT.TRACKER[current_issue.tracker])
            if orgi_issue.status != current_issue.status:
                status_changes.append(u'状态: ' + ISSUE_ATTR_DICT.STATUS[current_issue.status])
            if orgi_issue.assigned != current_issue.assigned:
                assigned_user = GsuserManager.get_user_by_id(current_issue.assigned)
                if assigned_user is not None:
                    status_changes.append(u'指派给: @' + assigned_user.username)
            if orgi_issue.priority != current_issue.priority:
                status_changes.append(u'优先级: ' + ISSUE_ATTR_DICT.PRIORITY[current_issue.priority])
            
            if len(status_changes) > 0:
                message = ', '.join(status_changes)
                feed_type = FEED_TYPE.ISSUES_STATUS_CHANGE

        if message != '':
            feed = Feed.create(user.id, repo.id, feed_cate, feed_type, current_issue.id)
            # TODO
            feed.first_refname = message
            feed.save()
            feedAction = FeedAction()
            timestamp = float(time.mktime(feed.create_time.timetuple()))
            feedAction.add_repo_feed(repo.id, timestamp, feed.id)
            if repo.auth_type == 2:
                feedAction.add_pri_user_feed(user.id, timestamp, feed.id)
            else:
                feedAction.add_pub_user_feed(user.id, timestamp, feed.id)
示例#48
0
 def feed_pull_change(self, user, pullRequest, pullStatus):
     feed_cate = FEED_CATE.MERGE
     feed_type = FEED_TYPE.MERGE_CREATE_PULL_REQUEST
     repo = pullRequest.desc_repo
     if pullStatus == PULL_STATUS.NEW:
         feed_type = FEED_TYPE.MERGE_CREATE_PULL_REQUEST
     elif pullStatus == PULL_STATUS.MERGED_FAILED:
         feed_type = FEED_TYPE.MERGE_MERGED_FAILED_PULL_REQUEST
     elif pullStatus == PULL_STATUS.MERGED:
         feed_type = FEED_TYPE.MERGE_MERGED_PULL_REQUEST
     elif pullStatus == PULL_STATUS.REJECTED:
         feed_type = NOTIF_TYPE.MERGE_REJECTED_PULL_REQUEST
     elif pullStatus == PULL_STATUS.CLOSE:
         feed_type = NOTIF_TYPE.MERGE_CLOSE_PULL_REQUEST
     feed = Feed.create(user.id, repo.id, feed_cate, feed_type,
                        pullRequest.id)
     feed.save()
     feedAction = FeedAction()
     timestamp = float(time.mktime(feed.create_time.timetuple()))
     feedAction.add_repo_feed(repo.id, timestamp, feed.id)
     if repo.auth_type == 2:
         feedAction.add_pri_user_feed(user.id, timestamp, feed.id)
     else:
         feedAction.add_pub_user_feed(user.id, timestamp, feed.id)
示例#49
0
 def feed_pull_change(self, user, pullRequest, pullStatus):
     feed_cate = FEED_CATE.MERGE
     feed_type = FEED_TYPE.MERGE_CREATE_PULL_REQUEST
     repo = pullRequest.desc_repo
     if pullStatus == PULL_STATUS.NEW:
         feed_type = FEED_TYPE.MERGE_CREATE_PULL_REQUEST
     elif pullStatus == PULL_STATUS.MERGED_FAILED:
         feed_type = FEED_TYPE.MERGE_MERGED_FAILED_PULL_REQUEST
     elif pullStatus == PULL_STATUS.MERGED:
         feed_type = FEED_TYPE.MERGE_MERGED_PULL_REQUEST
     elif pullStatus == PULL_STATUS.REJECTED:
         feed_type = NOTIF_TYPE.MERGE_REJECTED_PULL_REQUEST
     elif pullStatus == PULL_STATUS.CLOSE:
         feed_type = NOTIF_TYPE.MERGE_CLOSE_PULL_REQUEST
     feed = Feed.create(user.id, repo.id, feed_cate, feed_type, pullRequest.id)
     feed.save()
     feedAction = FeedAction()
     timestamp = float(time.mktime(feed.create_time.timetuple()))
     feedAction.add_repo_feed(repo.id, timestamp, feed.id)
     if repo.auth_type == 2:
         feedAction.add_pri_user_feed(user.id, timestamp, feed.id)
     else:
         feedAction.add_pub_user_feed(user.id, timestamp, feed.id)
示例#50
0
 def is_watched_repo(self, user_id, watch_repo_id):
     feedAction = FeedAction()
     return feedAction.is_watch_repo(user_id, watch_repo_id)
示例#51
0
 def is_watched_user(self, user_id, watch_user_id):
     feedAction = FeedAction()
     return feedAction.is_watch_user(user_id, watch_user_id)