1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 07:27:04 +00:00

Modify group recommend

This commit is contained in:
xiez
2012-08-13 21:26:58 +08:00
parent 8e88f79ec6
commit 4f64802e22
9 changed files with 60 additions and 14 deletions

View File

@@ -111,7 +111,7 @@
{% else %} {% else %}
<a href="{% url 'repo' msg.attachment.repo_id %}?p={{ msg.attachment.path }}" target="_blank"> <a href="{% url 'repo' msg.attachment.repo_id %}?p={{ msg.attachment.path }}" target="_blank">
{% endif %} {% endif %}
{{ msg.attachment.path }}</a> : {{ msg.attachment.name }}</a> :
</span> </span>
{% endif %} {% endif %}
{{ msg.message|linebreaksbr|seahub_urlize|find_at }} {{ msg.message|linebreaksbr|seahub_urlize|find_at }}

View File

@@ -1,4 +1,5 @@
# encoding: utf-8 # encoding: utf-8
import os
import simplejson as json import simplejson as json
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.contrib import messages from django.contrib import messages
@@ -211,8 +212,24 @@ def render_group_info(request, group_id, form):
group_msgs = msgs_plus_one[:per_page] group_msgs = msgs_plus_one[:per_page]
for msg in group_msgs: for msg in group_msgs:
msg.reply_cnt = len(MessageReply.objects.filter(reply_to=msg)) msg.reply_cnt = len(MessageReply.objects.filter(reply_to=msg))
msg.attachment = get_first_object_or_none( # Get message attachment if exists.
attachment = get_first_object_or_none(
MessageAttachment.objects.filter(group_message=msg)) MessageAttachment.objects.filter(group_message=msg))
if not attachment:
continue
# Attachment name is file name or directory name.
# If is top directory, use repo name instead.
path = attachment.path
if path == '/':
repo = get_repo(attachment.repo_id)
if not repo:
# TODO: what should we do here, tell user the repo is no longer
# exists?
continue
attachment.name = repo.name
else:
attachment.name = os.path.basename(path)
msg.attachment = attachment
return render_to_response("group/group_info.html", { return render_to_response("group/group_info.html", {
"managers": managers, "managers": managers,

View File

@@ -273,6 +273,9 @@ $(function() {
{% for group in groups %} {% for group in groups %}
group_list.push('{{ group.props.group_name }} <{{ group.props.creator_name }}>'); group_list.push('{{ group.props.group_name }} <{{ group.props.creator_name }}>');
{% endfor %} {% endfor %}
if (group_list.length == 1) {
$('#recommend-form #groups').val(group_list[0]);
}
addAutocomplete('#groups', '#recommend-form', group_list); addAutocomplete('#groups', '#recommend-form', group_list);
$('.ui-autocomplete').css({'max-height': window.innerHeight - $('.ui-autocomplete-input').offset().top - $('.ui-autocomplete-input').height() - 10, 'overflow': 'auto'}); $('.ui-autocomplete').css({'max-height': window.innerHeight - $('.ui-autocomplete-input').offset().top - $('.ui-autocomplete-input').height() - 10, 'overflow': 'auto'});

View File

@@ -218,6 +218,9 @@ $(function() {
{% for group in groups %} {% for group in groups %}
group_list.push('{{ group.props.group_name }} <{{ group.props.creator_name }}>'); group_list.push('{{ group.props.group_name }} <{{ group.props.creator_name }}>');
{% endfor %} {% endfor %}
if (group_list.length == 1) {
$('#recommend-form #groups').val(group_list[0]);
}
addAutocomplete('#groups', '#recommend-form', group_list); addAutocomplete('#groups', '#recommend-form', group_list);
$('.ui-autocomplete').css({'max-height': window.innerHeight - $('.ui-autocomplete-input').offset().top - $('.ui-autocomplete-input').height() - 10, 'overflow': 'auto'}); $('.ui-autocomplete').css({'max-height': window.innerHeight - $('.ui-autocomplete-input').offset().top - $('.ui-autocomplete-input').height() - 10, 'overflow': 'auto'});

View File

@@ -1,4 +1,9 @@
{% if groups %}
var Bottom_bar = '<div id="bottom-bar"><button id="recommend">推荐到小组</button> <button>发送到私信</button></div>'; var Bottom_bar = '<div id="bottom-bar"><button id="recommend">推荐到小组</button> <button>发送到私信</button></div>';
{% else %}
var Bottom_bar = '<div id="bottom-bar"><button>发送到私信</button></div>';
{% endif %}
$('#wrapper').append(Bottom_bar); $('#wrapper').append(Bottom_bar);
$('#bottom-bar').css({'position':'fixed', 'bottom':0, 'left':$('#main').offset().left + $('#main').width() + 15}); $('#bottom-bar').css({'position':'fixed', 'bottom':0, 'left':$('#main').offset().left + $('#main').width() + 15});
$('#recommend').click(function() { $('#recommend').click(function() {

View File

@@ -6,7 +6,7 @@ from service import send_command
from service import get_emailusers from service import get_emailusers
from service import get_org_groups, get_personal_groups, get_group_repoids, \ 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, \ check_group_staff, remove_group_user, get_group, get_org_id_by_group, \
get_group_members get_group_members, check_group_repo
from service import get_repos, get_repo, get_commits, get_branches, \ from service import get_repos, get_repo, get_commits, get_branches, \
get_org_repos, is_repo_owner, create_org_repo get_org_repos, is_repo_owner, create_org_repo
from service import get_binding_peerids, is_valid_filename from service import get_binding_peerids, is_valid_filename

View File

@@ -147,6 +147,16 @@ def get_group_members(group_id):
members = [] members = []
return members return members
def check_group_repo(group_id, repo_id, user):
group_id_int = int(group_id)
try:
ret = seafserv_threaded_rpc.check_group_repo(group_id_int, repo_id,
user)
except SearpcError:
ret = 0
return ret
def get_org_id_by_group(group_id): def get_org_id_by_group(group_id):
try: try:
org_id = ccnet_threaded_rpc.get_org_id_by_group(group_id) org_id = ccnet_threaded_rpc.get_org_id_by_group(group_id)

View File

@@ -25,7 +25,7 @@ EMPTY_SHA1 = '0000000000000000000000000000000000000000'
MAX_INT = 2147483647 MAX_INT = 2147483647
PREVIEW_FILEEXT = { PREVIEW_FILEEXT = {
'Text': ('ac', 'am', 'bat', 'c', 'cc', 'cmake', 'cpp', 'css', 'diff', 'h', 'html', 'htm', 'java', 'js', 'json', 'less', 'make', 'org', 'php', 'pl', 'properties', 'py', 'rb', 'scala', 'script', 'sh', 'sql', 'txt','text', 'tex', 'vi', 'vim', 'xhtml', 'xml'), 'Text': ('ac', 'am', 'bat', 'c', 'cc', 'cmake', 'cpp', 'css', 'diff', 'el', 'h', 'html', 'htm', 'java', 'js', 'json', 'less', 'make', 'org', 'php', 'pl', 'properties', 'py', 'rb', 'scala', 'script', 'sh', 'sql', 'txt', 'text', 'tex', 'vi', 'vim', 'xhtml', 'xml'),
'Image': ('gif', 'jpeg', 'jpg', 'png'), 'Image': ('gif', 'jpeg', 'jpg', 'png'),
'Document': ('doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx'), 'Document': ('doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx'),
'SVG': ('svg',), 'SVG': ('svg',),

View File

@@ -33,7 +33,7 @@ from seaserv import ccnet_rpc, ccnet_threaded_rpc, get_repos, get_emailusers, \
get_repo, get_commits, get_branches, is_valid_filename, remove_group_user,\ get_repo, get_commits, get_branches, is_valid_filename, remove_group_user,\
seafserv_threaded_rpc, seafserv_rpc, get_binding_peerids, \ seafserv_threaded_rpc, seafserv_rpc, get_binding_peerids, \
get_group_repoids, check_group_staff, get_personal_groups, is_repo_owner, \ get_group_repoids, check_group_staff, get_personal_groups, is_repo_owner, \
get_group get_group, check_group_repo
from pysearpc import SearpcError from pysearpc import SearpcError
from seahub.base.accounts import User from seahub.base.accounts import User
@@ -225,9 +225,13 @@ def render_repo(request, repo_id, error=''):
# generate path and link # generate path and link
zipped = gen_path_link(path, repo.name) zipped = gen_path_link(path, repo.name)
# my groups # get groups this repo is shared to
groups = get_personal_groups(request.user.username) groups = []
personal_groups = get_personal_groups(request.user.username)
for group in personal_groups:
if check_group_repo(group.id, repo_id, request.user.username):
groups.append(group)
return render_to_response('repo.html', { return render_to_response('repo.html', {
"repo": repo, "repo": repo,
"can_access": can_access, "can_access": can_access,
@@ -237,10 +241,10 @@ def render_repo(request, repo_id, error=''):
"repo_size": repo_size, "repo_size": repo_size,
"dir_list": dir_list, "dir_list": dir_list,
"file_list": file_list, "file_list": file_list,
"path" : path, "path": path,
"zipped" : zipped, "zipped": zipped,
"error" : error, "error": error,
"accessible_repos" : accessible_repos, "accessible_repos": accessible_repos,
"applet_root": get_ccnetapplet_root(), "applet_root": get_ccnetapplet_root(),
"groups": groups, "groups": groups,
}, context_instance=RequestContext(request)) }, context_instance=RequestContext(request))
@@ -818,8 +822,12 @@ def repo_view_file(request, repo_id):
# my constacts # my constacts
contacts = Contact.objects.filter(user_email=request.user.username) contacts = Contact.objects.filter(user_email=request.user.username)
# my groups # get groups this repo is shared to
groups = get_personal_groups(request.user.username) groups = []
personal_groups = get_personal_groups(request.user.username)
for group in personal_groups:
if check_group_repo(group.id, repo_id, request.user.username):
groups.append(group)
return render_to_response('repo_view_file.html', { return render_to_response('repo_view_file.html', {
'repo': repo, 'repo': repo,