當前位置: 首頁>>代碼示例>>Python>>正文


Python Notification.get方法代碼示例

本文整理匯總了Python中rhodecode.model.db.Notification.get方法的典型用法代碼示例。如果您正苦於以下問題:Python Notification.get方法的具體用法?Python Notification.get怎麽用?Python Notification.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rhodecode.model.db.Notification的用法示例。


在下文中一共展示了Notification.get方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __get_notification

# 需要導入模塊: from rhodecode.model.db import Notification [as 別名]
# 或者: from rhodecode.model.db.Notification import get [as 別名]
 def __get_notification(self, notification):
     if isinstance(notification, Notification):
         return notification
     elif isinstance(notification, (int, long)):
         return Notification.get(notification)
     else:
         if notification:
             raise Exception('notification must be int, long or Instance'
                             ' of Notification got %s' % type(notification))
開發者ID:elfixit,項目名稱:rhodecode,代碼行數:11,代碼來源:notification.py

示例2: update

# 需要導入模塊: from rhodecode.model.db import Notification [as 別名]
# 或者: from rhodecode.model.db.Notification import get [as 別名]
 def update(self, notification_id):
     """PUT /_admin/notifications/id: Update an existing item"""
     # Forms posted to this method should contain a hidden field:
     #    <input type="hidden" name="_method" value="PUT" />
     # Or using helpers:
     #    h.form(url('notification', notification_id=ID),
     #           method='put')
     # url('notification', notification_id=ID)
     try:
         no = Notification.get(notification_id)
         owner = all(un.user.user_id == c.rhodecode_user.user_id
                     for un in no.notifications_to_users)
         if h.HasPermissionAny('hg.admin')() or owner:
                 NotificationModel().mark_read(c.rhodecode_user.user_id, no)
                 Session().commit()
                 return 'ok'
     except Exception:
         Session().rollback()
         log.error(traceback.format_exc())
     return 'fail'
開發者ID:adamscieszko,項目名稱:rhodecode,代碼行數:22,代碼來源:notifications.py

示例3: delete

# 需要導入模塊: from rhodecode.model.db import Notification [as 別名]
# 或者: from rhodecode.model.db.Notification import get [as 別名]
    def delete(self, notification_id):
        """DELETE /_admin/notifications/id: Delete an existing item"""
        # Forms posted to this method should contain a hidden field:
        #    <input type="hidden" name="_method" value="DELETE" />
        # Or using helpers:
        #    h.form(url('notification', notification_id=ID),
        #           method='delete')
        # url('notification', notification_id=ID)

        try:
            no = Notification.get(notification_id)
            owner = lambda: (no.notifications_to_users.user.user_id == c.rhodecode_user.user_id)
            if h.HasPermissionAny("hg.admin", "repository.admin")() or owner:
                NotificationModel().delete(c.rhodecode_user.user_id, no)
                Session.commit()
                return "ok"
        except Exception:
            Session.rollback()
            log.error(traceback.format_exc())
        return "fail"
開發者ID:seacoastboy,項目名稱:rhodecode,代碼行數:22,代碼來源:notifications.py

示例4: show

# 需要導入模塊: from rhodecode.model.db import Notification [as 別名]
# 或者: from rhodecode.model.db.Notification import get [as 別名]
    def show(self, notification_id, format="html"):
        """GET /_admin/notifications/id: Show a specific item"""
        # url('notification', notification_id=ID)
        c.user = self.rhodecode_user
        no = Notification.get(notification_id)

        owner = lambda: (no.notifications_to_users.user.user_id == c.user.user_id)
        if no and (h.HasPermissionAny("hg.admin", "repository.admin")() or owner):
            unotification = NotificationModel().get_user_notification(c.user.user_id, no)

            # if this association to user is not valid, we don't want to show
            # this message
            if unotification:
                if unotification.read is False:
                    unotification.mark_as_read()
                    Session.commit()
                c.notification = no

                return render("admin/notifications/show_notification.html")

        return redirect(url("notifications"))
開發者ID:seacoastboy,項目名稱:rhodecode,代碼行數:23,代碼來源:notifications.py

示例5: show

# 需要導入模塊: from rhodecode.model.db import Notification [as 別名]
# 或者: from rhodecode.model.db.Notification import get [as 別名]
    def show(self, notification_id, format='html'):
        """GET /_admin/notifications/id: Show a specific item"""
        # url('notification', notification_id=ID)
        c.user = self.rhodecode_user
        no = Notification.get(notification_id)

        owner = any(un.user.user_id == c.rhodecode_user.user_id
                    for un in no.notifications_to_users)

        if no and (h.HasPermissionAny('hg.admin', 'repository.admin')() or owner):
            unotification = NotificationModel()\
                            .get_user_notification(c.user.user_id, no)

            # if this association to user is not valid, we don't want to show
            # this message
            if unotification:
                if not unotification.read:
                    unotification.mark_as_read()
                    Session().commit()
                c.notification = no

                return render('admin/notifications/show_notification.html')

        return abort(403)
開發者ID:adamscieszko,項目名稱:rhodecode,代碼行數:26,代碼來源:notifications.py

示例6: tearDown

# 需要導入模塊: from rhodecode.model.db import Notification [as 別名]
# 或者: from rhodecode.model.db.Notification import get [as 別名]
 def tearDown(self):
     for n in Notification.query().all():
         inst = Notification.get(n.notification_id)
         self.Session().delete(inst)
     self.Session().commit()
開發者ID:break123,項目名稱:rhodecode,代碼行數:7,代碼來源:test_admin_notifications.py


注:本文中的rhodecode.model.db.Notification.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。