mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-16 15:19:06 +00:00
Allow share repo to unjoined group
This commit is contained in:
@@ -53,26 +53,18 @@ def share_repo(request):
|
||||
|
||||
to_email_list = string2list(email_or_group)
|
||||
for to_email in to_email_list:
|
||||
# if to_email is user name, the format is: 'example@mail.com';
|
||||
# if to_email is group, the format is 'group_name <creator@mail.com>'
|
||||
if (to_email.split(' ')[0].find('@') == -1):
|
||||
if to_email.find('@') == -1:
|
||||
''' Share repo to group '''
|
||||
# TODO: if we know group id, then we can simplly call group_share_repo
|
||||
if len(to_email.split(' ')) < 2:
|
||||
msg = u'共享给 %s 失败。' % to_email
|
||||
messages.add_message(request, messages.ERROR, msg)
|
||||
continue
|
||||
|
||||
group_name = to_email.split(' ')[0]
|
||||
group_creator = to_email.split(' ')[1]
|
||||
# get all the groups the user joined
|
||||
groups = get_personal_groups(request.user.username)
|
||||
group_name = to_email
|
||||
|
||||
# get all personal groups
|
||||
groups = get_personal_groups(-1, -1)
|
||||
find = False
|
||||
for group in groups:
|
||||
# for every group that user joined, if group name and
|
||||
# group creator matchs, then has find the group
|
||||
if group.props.group_name == group_name and \
|
||||
group_creator.find(group.props.creator_name) >= 0:
|
||||
# for every group that user joined, if group name matchs,
|
||||
# then has find the group
|
||||
if group.props.group_name == group_name:
|
||||
from seahub.group.views import group_share_repo
|
||||
group_share_repo(request, repo_id, int(group.props.id),
|
||||
from_email, permission)
|
||||
@@ -83,7 +75,7 @@ def share_repo(request):
|
||||
messages.add_message(request, messages.INFO, msg)
|
||||
break
|
||||
if not find:
|
||||
msg = u'共享到 %s 失败。' % group_name
|
||||
msg = u'共享到 %s 失败,小组不存在。' % group_name
|
||||
messages.add_message(request, messages.ERROR, msg)
|
||||
else:
|
||||
''' Share repo to user '''
|
||||
|
Reference in New Issue
Block a user