|
6 | 6 | from plone.base.utils import get_user_friendly_types |
7 | 7 | from plone.base.utils import safe_text |
8 | 8 | from plone.locking.interfaces import ILockable |
| 9 | +from plone.registry.interfaces import IRegistry |
9 | 10 | from Products.CMFCore.utils import getToolByName |
10 | 11 | from Products.Five.browser import BrowserView |
11 | 12 | from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile |
|
19 | 20 | from zope import schema |
20 | 21 | from zope.component import getMultiAdapter |
21 | 22 | from zope.component import queryMultiAdapter |
| 23 | +from zope.component import queryUtility |
| 24 | +from zope.component.hooks import getSite |
22 | 25 | from zope.container.interfaces import INameChooser |
23 | 26 | from zope.event import notify |
24 | 27 | from zope.interface import Interface |
@@ -85,9 +88,38 @@ def handle_delete(self, action): |
85 | 88 | # unlock object as it is locked by current user |
86 | 89 | ILockable(self.context).unlock() |
87 | 90 | parent.manage_delObjects(self.context.getId()) |
88 | | - IStatusMessage(self.request).add( |
89 | | - _("${title} has been deleted.", mapping={"title": title}) |
90 | | - ) |
| 91 | + |
| 92 | + # Check if recycle bin is enabled and show appropriate message |
| 93 | + try: |
| 94 | + recyclebin_enabled_view = getMultiAdapter( |
| 95 | + (getSite(), self.request), name="recyclebin-enabled" |
| 96 | + ) |
| 97 | + recycling_enabled = recyclebin_enabled_view() |
| 98 | + except Exception: |
| 99 | + recycling_enabled = False |
| 100 | + |
| 101 | + if recycling_enabled: |
| 102 | + # Get retention period from registry (default to 30 days if not found) |
| 103 | + registry = queryUtility(IRegistry) |
| 104 | + retention_period = 30 # default |
| 105 | + if registry is not None: |
| 106 | + try: |
| 107 | + retention_period = registry.get( |
| 108 | + "plone-recyclebin.retention_period", 30 |
| 109 | + ) |
| 110 | + except Exception: |
| 111 | + retention_period = 30 |
| 112 | + |
| 113 | + IStatusMessage(self.request).add( |
| 114 | + _( |
| 115 | + "${title} has been moved to the recycle bin. It can be restored by administrators and will be permanently deleted after ${days} days.", |
| 116 | + mapping={"title": title, "days": retention_period}, |
| 117 | + ) |
| 118 | + ) |
| 119 | + else: |
| 120 | + IStatusMessage(self.request).add( |
| 121 | + _("${title} has been deleted.", mapping={"title": title}) |
| 122 | + ) |
91 | 123 | else: |
92 | 124 | IStatusMessage(self.request).add( |
93 | 125 | _('"${title}" has already been deleted', mapping={"title": title}) |
|
0 commit comments