##// END OF EJS Templates
notifications: fixed problem with 500 errors on non-numeric...
marcink -
r1812:7d0f908d default
parent child Browse files
Show More
@@ -48,10 +48,6 b' log = logging.getLogger(__name__)'
48 48
49 49 class NotificationsController(BaseController):
50 50 """REST Controller styled on the Atom Publishing Protocol"""
51 # To properly map this controller, ensure your config/routing.py
52 # file has a resource setup:
53 # map.resource('notification', 'notifications', controller='_admin/notifications',
54 # path_prefix='/_admin', name_prefix='_admin_')
55 51
56 52 @LoginRequired()
57 53 @NotAnonymous()
@@ -62,8 +58,8 b' class NotificationsController(BaseContro'
62 58 """GET /_admin/notifications: All items in the collection"""
63 59 # url('notifications')
64 60 c.user = c.rhodecode_user
65 notif = NotificationModel().get_for_user(c.rhodecode_user.user_id,
66 filter_=request.GET.getall('type'))
61 notif = NotificationModel().get_for_user(
62 c.rhodecode_user.user_id, filter_=request.GET.getall('type'))
67 63
68 64 p = safe_int(request.GET.get('page', 1), 1)
69 65 notifications_url = webhelpers.paginate.PageURL(
@@ -86,7 +82,6 b' class NotificationsController(BaseContro'
86 82
87 83 return render('admin/notifications/notifications.mako')
88 84
89
90 85 @auth.CSRFRequired()
91 86 def mark_all_read(self):
92 87 if request.is_xhr:
@@ -115,15 +110,8 b' class NotificationsController(BaseContro'
115 110
116 111 @auth.CSRFRequired()
117 112 def update(self, notification_id):
118 """PUT /_admin/notifications/id: Update an existing item"""
119 # Forms posted to this method should contain a hidden field:
120 # <input type="hidden" name="_method" value="PUT" />
121 # Or using helpers:
122 # h.form(url('notification', notification_id=ID),
123 # method='put')
124 # url('notification', notification_id=ID)
113 no = Notification.get_or_404(notification_id)
125 114 try:
126 no = Notification.get(notification_id)
127 115 if self._has_permissions(no):
128 116 # deletes only notification2user
129 117 NotificationModel().mark_read(c.rhodecode_user.user_id, no)
@@ -136,15 +124,8 b' class NotificationsController(BaseContro'
136 124
137 125 @auth.CSRFRequired()
138 126 def delete(self, notification_id):
139 """DELETE /_admin/notifications/id: Delete an existing item"""
140 # Forms posted to this method should contain a hidden field:
141 # <input type="hidden" name="_method" value="DELETE" />
142 # Or using helpers:
143 # h.form(url('notification', notification_id=ID),
144 # method='delete')
145 # url('notification', notification_id=ID)
127 no = Notification.get_or_404(notification_id)
146 128 try:
147 no = Notification.get(notification_id)
148 129 if self._has_permissions(no):
149 130 # deletes only notification2user
150 131 NotificationModel().delete(c.rhodecode_user.user_id, no)
@@ -156,10 +137,8 b' class NotificationsController(BaseContro'
156 137 raise HTTPBadRequest()
157 138
158 139 def show(self, notification_id):
159 """GET /_admin/notifications/id: Show a specific item"""
160 # url('notification', notification_id=ID)
161 140 c.user = c.rhodecode_user
162 no = Notification.get(notification_id)
141 no = Notification.get_or_404(notification_id)
163 142
164 143 if no and self._has_permissions(no):
165 144 unotification = NotificationModel()\
General Comments 0
You need to be logged in to leave comments. Login now