本文整理汇总了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))
示例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'
示例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"
示例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"))
示例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)
示例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()