|
2 | 2 | from Acquisition import aq_inner |
3 | 3 | from Acquisition import aq_parent |
4 | 4 | from OFS.CopySupport import CopyError |
| 5 | +from plone.app.content.utils import get_recycle_bin_message |
5 | 6 | from plone.base import PloneMessageFactory as _ |
| 7 | +from plone.base.interfaces.recyclebin import IRecycleBin |
6 | 8 | from plone.base.utils import get_user_friendly_types |
7 | 9 | from plone.base.utils import safe_text |
8 | 10 | from plone.locking.interfaces import ILockable |
|
21 | 23 | from zope.component import getMultiAdapter |
22 | 24 | from zope.component import queryMultiAdapter |
23 | 25 | from zope.component import queryUtility |
24 | | -from zope.component.hooks import getSite |
25 | 26 | from zope.container.interfaces import INameChooser |
26 | 27 | from zope.event import notify |
27 | 28 | from zope.interface import Interface |
@@ -90,32 +91,16 @@ def handle_delete(self, action): |
90 | 91 | parent.manage_delObjects(self.context.getId()) |
91 | 92 |
|
92 | 93 | # 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 |
| 94 | + recycle_bin = queryUtility(IRecycleBin) |
| 95 | + recycling_enabled = recycle_bin.is_enabled() if recycle_bin else False |
100 | 96 |
|
101 | 97 | if recycling_enabled: |
102 | | - # Get retention period from registry (default to 30 days if not found) |
| 98 | + # Get retention period from registry |
103 | 99 | registry = queryUtility(IRegistry) |
104 | | - retention_period = 30 # default |
105 | | - if registry is not None: |
106 | | - try: |
107 | | - retention_period = registry.get( |
108 | | - "recyclebin-controlpanel.retention_period", 30 |
109 | | - ) |
110 | | - except Exception: |
111 | | - retention_period = 30 |
| 100 | + retention_period = registry["recyclebin-controlpanel.retention_period"] |
112 | 101 |
|
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 | | - ) |
| 102 | + message = get_recycle_bin_message(title=title, retention_period=retention_period) |
| 103 | + IStatusMessage(self.request).add(message) |
119 | 104 | else: |
120 | 105 | IStatusMessage(self.request).add( |
121 | 106 | _("${title} has been deleted.", mapping={"title": title}) |
|
0 commit comments