Package Products :: Package ZenWidgets :: Package browser :: Module messaging |
[hide private]
[frames] | no frames]

# Source Code for Module Products.ZenWidgets.browser.messaging

     1  ##############################################################################
     2  #
     3  # Copyright (C) Zenoss, Inc. 2007, all rights reserved.
     4  #
     5  # This content is made available according to terms specified in
     6  # License.zenoss under the directory where your Zenoss product is installed.
     7  #
     8  ##############################################################################
     9
    10
    11  from Products.Five.browser import BrowserView
    12
    13  from Products.ZenUtils.jsonutils import json
    14  from Products.ZenModel.ZenossSecurity import *
    15  from Products.ZenWidgets.interfaces import IUserMessages, IBrowserMessages
    16  from Products.ZenWidgets import messaging
    17
    18 -class UserMessages(BrowserView):
    19      """
    20      Delivers up user messages for the current user to the client-side
    21      YAHOO.zenoss.Messenger.
    22      """
    23      @json
    24 -    def __call__(self):
    25          messages = IUserMessages(self.context).get_unread()
    26          messages.extend(IBrowserMessages(self.context).get_unread())
    27          messages.sort(key=lambda x:x.timestamp)
    28          result = []
    29          for message in messages:
    30              result.append(dict(
    31                  sticky=message.priority>=messaging.CRITICAL and True or False,
    32                  image=message.image,
    33                  title=message.title,
    34                  body=message.body,
    35                  priority=message.priority
    36              ))
    37              message.mark_as_read()
    38          result = {'totalRecords':len(result),
    39                    'messages':result}
    40          return result
    41
    42
    43 -class DeleteMessage(BrowserView):
    44 -    def __call__(self):
    45          self.context.delete()
    46