Skip to content

Commit

Permalink
Notifications: Add browser view for daily cron jobs.
Browse files Browse the repository at this point in the history
  • Loading branch information
thet committed Oct 26, 2023
1 parent 9a578a0 commit e0cebb6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/euphorie/client/notifications/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
xmlns:browser="http://namespaces.zope.org/browser"
>

<browser:page
name="send-notifications-daily"
for="*"
class=".send_notifications.SendNotificationsDaily"
permission="cmf.ManagePortal"
layer="..interfaces.IClientSkinLayer"
/>

<browser:page
name="notification__ra-not-modified__email"
for="*"
Expand Down
21 changes: 21 additions & 0 deletions src/euphorie/client/notifications/send_notifications.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from euphorie.client.interfaces import INotificationCategory
from euphorie.client.interfaces import INTERVAL_DAILY
from plone.protect.interfaces import IDisableCSRFProtection
from Products.Five import BrowserView
from zope.component import getAdapters
from zope.interface import alsoProvides


class SendNotificationsDaily(BrowserView):
def do_send(self):
notifications = getAdapters((self.context, self.request), INotificationCategory)
for notification in notifications:
if not notification[1].available:
continue
if not notification[1].interval == INTERVAL_DAILY:
continue
notification[1].notify()

def __call__(self):
alsoProvides(self.request, IDisableCSRFProtection)
self.do_send()

0 comments on commit e0cebb6

Please sign in to comment.