1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-07-30 22:34:53 +00:00

Added button to click into group in repo page

This commit is contained in:
xiez 2012-09-03 20:54:07 +08:00
parent d5cd2da36e
commit 22ee4fe65a
5 changed files with 40 additions and 7 deletions

View File

@ -283,6 +283,7 @@ ul.with-bg li {
min-width:65px;
padding:5px 0;
box-shadow: 0 2px 4px rgba(0,0,0,.2);
z-index: 1000;
-moz-box-shadow: -1px 1px 1px rgba(0,0,0,.2);
-webkit-box-shadow: 0 2px 4px rgba(0,0,0,.2);
}

View File

@ -1,4 +1,5 @@
var Bottom_bar = '<div id="bottom-bar">{% if groups %}<button id="recommend">推荐到小组</button> {% endif %}</div>';
{% load url from future %}
var Bottom_bar = '<div id="bottom-bar">{% if groups %}<button id="recommend">推荐到小组</button> <button id="click-into-group">点击进入小组</button>{% endif %}</div>';
$('#wrapper').append(Bottom_bar);
$('#bottom-bar').css({'position':'fixed', 'bottom':0, 'right':'10px'});
$('#main-panel').css('margin-bottom', '28px');
@ -17,6 +18,15 @@ $('#recommend').click(function() {
addAutocomplete('#recommend-groups', '#recommend-form', group_list);
$('.ui-autocomplete').css({'max-height': window.innerHeight - $('.ui-autocomplete-input').offset().top - $('.ui-autocomplete-input').height() - 10, 'overflow': 'auto'});
});
$('#click-into-group').click(function() {
{% for group in groups %}
{% if forloop.first %}
location.href= "{% url 'group_info' group.id %}";
{% endif %}
{% endfor %}
});
$('#recommend-submit').click(function() {
if (!$.trim($('#recommend-groups').val())) {
apply_form_error('recommend-form', '小组名称不能为空。');

View File

@ -8,7 +8,7 @@ from service import get_org_groups, get_personal_groups, get_group_repoids, \
check_group_staff, remove_group_user, get_group, get_org_id_by_group, \
get_group_members, get_shared_groups_by_repo, is_group_user, \
get_org_group_repos, get_group_repos, get_org_groups_by_user, is_org_group,\
del_org_group_repo
del_org_group_repo, get_org_groups_by_repo
from service import get_repos, get_repo, get_commits, get_branches, \
get_org_repos, is_repo_owner, create_org_repo, is_inner_pub_repo, \
list_org_inner_pub_repos, get_org_id_by_repo_id, list_org_shared_repos, \

View File

@ -364,9 +364,9 @@ def get_branches(repo_id):
def get_shared_groups_by_repo(repo_id):
try:
group_ids = seafserv_threaded_rpc.get_shared_groups_by_repo(repo_id)
if not group_ids:
return []
except SearpcError:
group_ids = ''
if not group_ids:
return []
groups = []
@ -475,6 +475,24 @@ def get_org_group_repos(org_id, group_id, user):
return repos
def get_org_groups_by_repo(org_id, repo_id):
try:
group_ids = seafserv_threaded_rpc.get_org_groups_by_repo(org_id,
repo_id)
except SearpcError:
group_ids = ''
if not group_ids:
return []
groups = []
for group_id in group_ids.split('\n'):
if not group_id:
continue
group = get_group(group_id)
if group:
groups.append(group)
return groups
# inner pub repo
def list_inner_pub_repos():
"""

View File

@ -34,7 +34,7 @@ from seaserv import ccnet_rpc, ccnet_threaded_rpc, get_repos, get_emailusers, \
check_group_staff, get_personal_groups, is_repo_owner, del_org_group_repo,\
get_group, get_shared_groups_by_repo, is_group_user, check_permission, \
list_personal_shared_repos, is_org_group, get_org_id_by_group, \
list_inner_pub_repos
list_inner_pub_repos, get_org_groups_by_repo
from pysearpc import SearpcError
from base.accounts import User
@ -199,9 +199,13 @@ def render_repo(request, repo_id, error=''):
# generate path and link
zipped = gen_path_link(path, repo.name)
# get groups this repo is shared
# get groups this repo is shared
groups = []
repo_shared_groups = get_shared_groups_by_repo(repo_id)
if request.user.org:
org_id = request.user.org['org_id']
repo_shared_groups = get_org_groups_by_repo(org_id, repo_id)
else:
repo_shared_groups = get_shared_groups_by_repo(repo_id)
for group in repo_shared_groups:
# check whether user joined this group
if is_group_user(group.id, request.user.username):