Skip to content

Commit

Permalink
Delete pads during group deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
2e2a authored and saschasommer committed Jan 9, 2025
1 parent 87b6065 commit b895ea4
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion cosinnus/views/group_deletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from cosinnus.utils.permissions import check_ug_admin, check_user_can_receive_emails
from cosinnus.utils.urls import get_domain_for_portal, group_aware_reverse
from cosinnus_cloud.utils.nextcloud import get_group_folder_last_modified
from cosinnus_etherpad.models import Etherpad
from cosinnus_etherpad.models import Etherpad, EtherpadException
from cosinnus_message.rocket_chat import RocketChatConnection

logger = logging.getLogger('cosinnus')
Expand Down Expand Up @@ -140,6 +140,22 @@ def delete_group(group):
logger.warn('Attempted to delete default user group!', extra={'group_slug': group.slug})
return

# Delete Etherpads/Ethercalcs
# Note: The automatic deletion of Etherpad instances is normally disabled by the setting
# COSINNUS_DELETE_ETHERPADS_ON_SERVER_ON_DELETE. However, during group deletion the setting is ignored and the
# pads are deleted.
if not getattr(settings, 'COSINNUS_ETHERPAD_DISABLE_HOOKS', False):
for pad in Etherpad.objects.filter(group=group):
try:
pad.client.deletePad(padID=pad.pad_id)
except EtherpadException as exc:
# failed deletion of missing padIDs is ok
if 'padID does not exist' not in str(exc):
logger.error(
'Could not delete etherpad during group deletion.',
extra={'group_slug': group.slug, 'exception': exc},
)

# delete group
group.delete()

Expand Down

0 comments on commit b895ea4

Please sign in to comment.