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

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

     1  ###########################################################################
     2  #
     3  # This program is part of Zenoss Core, an open source monitoring platform.
     4  # Copyright (C) 2007, Zenoss Inc.
     5  #
     6  # This program is free software; you can redistribute it and/or modify it
     7  # under the terms of the GNU General Public License version 2 as published by
     8  # the Free Software Foundation.
     9  #
    10  # For complete information please visit: http://www.zenoss.com/oss/
    11  #
    12  ###########################################################################
    13
    14  from Products.Five.browser import BrowserView
    15
    16  from Products.ZenUtils.jsonutils import json
    17  from Products.ZenModel.ZenossSecurity import *
    18  from Products.ZenWidgets.interfaces import IUserMessages, IBrowserMessages
    19  from Products.ZenWidgets import messaging
    20
    21 -class UserMessages(BrowserView):
    22      """
    23      Delivers up user messages for the current user to the client-side
    24      YAHOO.zenoss.Messenger.
    25      """
    26      @json
    27 -    def __call__(self):
    28          messages = IUserMessages(self.context).get_unread()
    29          messages.extend(IBrowserMessages(self.context).get_unread())
    30          messages.sort(key=lambda x:x.timestamp)
    31          result = []
    32          for message in messages:
    33              result.append(dict(
    34                  sticky=message.priority>=messaging.CRITICAL and True or False,
    35                  image=message.image,
    36                  title=message.title,
    37                  body=message.body,
    38                  priority=message.priority
    39              ))
    40              message.mark_as_read()
    41          result = {'totalRecords':len(result),
    42                    'messages':result}
    43          return result
    44
    45
    46 -class DeleteMessage(BrowserView):
    47 -    def __call__(self):
    48          self.context.delete()
    49