1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-18 08:16:07 +00:00

udpate repo_created_cb

This commit is contained in:
lian
2016-09-19 13:54:17 +08:00
parent 3834245dce
commit b23fc5dbf3
2 changed files with 15 additions and 18 deletions

View File

@@ -619,7 +619,7 @@ class Repos(APIView):
return api_error(HTTP_520_OPERATION_FAILED,
'Failed to create library.')
else:
library_template = request.data.get("library_template", None)
library_template = request.data.get("library_template", '')
repo_created.send(sender=None,
org_id=org_id,
creator=username,
@@ -755,7 +755,7 @@ class PubRepos(APIView):
repo = seafile_api.get_repo(repo_id)
seafile_api.add_inner_pub_repo(repo.id, permission)
library_template = request.data.get("library_template", None)
library_template = request.data.get("library_template", '')
repo_created.send(sender=None,
org_id=org_id,
creator=username,
@@ -3733,7 +3733,7 @@ class GroupRepos(APIView):
repo = seafile_api.get_repo(repo_id)
seafile_api.set_group_repo(repo.id, group.id, username, permission)
library_template = request.data.get("library_template", None)
library_template = request.data.get("library_template", '')
repo_created.send(sender=None,
org_id=org_id,
creator=username,

View File

@@ -6,7 +6,7 @@ from seaserv import seafile_api
from seahub.utils import is_pro_version
logger = logging.getLogger(__name__)
if not hasattr(settings, 'EVENTS_CONFIG_FILE'):
if not is_pro_version():
def repo_created_cb(sender, **kwargs):
pass
@@ -39,21 +39,18 @@ else:
seafevents.save_user_events (session, etype, detail, users, None)
session.close()
if is_pro_version():
LIBRARY_TEMPLATES = getattr(settings, 'LIBRARY_TEMPLATES', {})
library_template = kwargs['library_template']
LIBRARY_TEMPLATES = getattr(settings, 'LIBRARY_TEMPLATES', {})
library_template = kwargs['library_template']
if isinstance(library_template, unicode):
library_template = library_template.encode('utf-8')
dir_path_list = []
if isinstance(LIBRARY_TEMPLATES, dict) and \
LIBRARY_TEMPLATES.has_key(library_template):
dir_path_list = LIBRARY_TEMPLATES[library_template]
try:
for dir_path in dir_path_list:
seafile_api.mkdir_with_parents(repo_id, '/',
dir_path.strip('/'), creator)
except Exception as e:
logger.error(e)
try:
dir_path_list = LIBRARY_TEMPLATES[library_template]
for dir_path in dir_path_list:
seafile_api.mkdir_with_parents(repo_id, '/',
dir_path.strip('/'), creator)
except Exception as e:
logger.error(e)
def repo_deleted_cb(sender, **kwargs):
"""When a repo is deleted, an event would be added to every user in all