-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Notifications: Add browser view for daily cron jobs.
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |