mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-26 07:22:34 +00:00
org operation signal (#8120)
This commit is contained in:
@@ -1,22 +1,16 @@
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
from seahub.organizations.signals import org_created, org_reactivated
|
||||
from seahub.organizations.signals import org_operation_signal
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
conf_dir = os.environ['SEAFILE_CENTRAL_CONF_DIR']
|
||||
sys.path.append(conf_dir)
|
||||
try:
|
||||
from seahub_custom_functions import org_created_callback
|
||||
org_created.connect(org_created_callback)
|
||||
from seahub_custom_functions import org_operation_callback
|
||||
org_operation_signal.connect(org_operation_callback)
|
||||
except ImportError as e:
|
||||
logger.debug(e)
|
||||
|
||||
try:
|
||||
from seahub_custom_functions import org_reactivated_callback
|
||||
org_reactivated.connect(org_reactivated_callback)
|
||||
except ImportError as e:
|
||||
logger.debug(e)
|
||||
logger.error(e)
|
||||
except KeyError as e:
|
||||
logger.debug(e)
|
||||
logger.error(e)
|
||||
|
@@ -10,6 +10,7 @@ from seahub.constants import DEFAULT_ORG
|
||||
from seahub.role_permissions.utils import get_available_roles
|
||||
from seahub.avatar.util import get_avatar_file_storage
|
||||
from seahub.avatar.settings import AVATAR_STORAGE_DIR
|
||||
from seahub.organizations.signals import org_operation_signal
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -88,6 +89,11 @@ class OrgSettingsManager(models.Manager):
|
||||
|
||||
if is_active is not None:
|
||||
settings.is_active = is_active
|
||||
try:
|
||||
org_operation_signal.send(sender=None, org=org,
|
||||
operation='active' if is_active else 'inactive')
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
|
||||
settings.save(using=self._db)
|
||||
return settings
|
||||
|
@@ -2,6 +2,5 @@
|
||||
from django.dispatch import Signal
|
||||
|
||||
# A new org is created
|
||||
org_created = Signal()
|
||||
org_reactivated = Signal()
|
||||
org_operation_signal = Signal()
|
||||
org_last_activity = Signal()
|
||||
|
@@ -28,7 +28,7 @@ from seahub.utils import get_service_url, render_error
|
||||
from seahub.utils.auth import get_login_bg_image_path
|
||||
|
||||
from seahub.organizations.models import OrgSettings
|
||||
from seahub.organizations.signals import org_created, org_reactivated
|
||||
from seahub.organizations.signals import org_operation_signal
|
||||
from seahub.organizations.decorators import org_staff_required
|
||||
from seahub.organizations.forms import OrgRegistrationForm
|
||||
from seahub.organizations.settings import ORG_AUTO_URL_PREFIX, \
|
||||
@@ -253,7 +253,10 @@ def org_register(request):
|
||||
|
||||
create_org(org_name, url_prefix, new_user.username)
|
||||
new_org = get_org_by_url_prefix(url_prefix)
|
||||
org_created.send(sender=None, email=email, org=new_org)
|
||||
try:
|
||||
org_operation_signal.send(sender=None, org=new_org, operation='create')
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
|
||||
if name:
|
||||
Profile.objects.add_or_update(new_user.username, name)
|
||||
@@ -360,5 +363,4 @@ def org_reactivate(request, token):
|
||||
|
||||
invite.accept()
|
||||
OrgSettings.objects.add_or_update(org, is_active=True)
|
||||
org_reactivated.send(sender=None, email=None, org=org)
|
||||
return HttpResponseRedirect(settings.SITE_ROOT)
|
||||
|
Reference in New Issue
Block a user