##// 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 class NotificationsController(BaseController):
49 class NotificationsController(BaseController):
50 """REST Controller styled on the Atom Publishing Protocol"""
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 @LoginRequired()
52 @LoginRequired()
57 @NotAnonymous()
53 @NotAnonymous()
@@ -62,8 +58,8 b' class NotificationsController(BaseContro'
62 """GET /_admin/notifications: All items in the collection"""
58 """GET /_admin/notifications: All items in the collection"""
63 # url('notifications')
59 # url('notifications')
64 c.user = c.rhodecode_user
60 c.user = c.rhodecode_user
65 notif = NotificationModel().get_for_user(c.rhodecode_user.user_id,
61 notif = NotificationModel().get_for_user(
66 filter_=request.GET.getall('type'))
62 c.rhodecode_user.user_id, filter_=request.GET.getall('type'))
67
63
68 p = safe_int(request.GET.get('page', 1), 1)
64 p = safe_int(request.GET.get('page', 1), 1)
69 notifications_url = webhelpers.paginate.PageURL(
65 notifications_url = webhelpers.paginate.PageURL(
@@ -86,7 +82,6 b' class NotificationsController(BaseContro'
86
82
87 return render('admin/notifications/notifications.mako')
83 return render('admin/notifications/notifications.mako')
88
84
89
90 @auth.CSRFRequired()
85 @auth.CSRFRequired()
91 def mark_all_read(self):
86 def mark_all_read(self):
92 if request.is_xhr:
87 if request.is_xhr:
@@ -115,15 +110,8 b' class NotificationsController(BaseContro'
115
110
116 @auth.CSRFRequired()
111 @auth.CSRFRequired()
117 def update(self, notification_id):
112 def update(self, notification_id):
118 """PUT /_admin/notifications/id: Update an existing item"""
113 no = Notification.get_or_404(notification_id)
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)
125 try:
114 try:
126 no = Notification.get(notification_id)
127 if self._has_permissions(no):
115 if self._has_permissions(no):
128 # deletes only notification2user
116 # deletes only notification2user
129 NotificationModel().mark_read(c.rhodecode_user.user_id, no)
117 NotificationModel().mark_read(c.rhodecode_user.user_id, no)
@@ -136,15 +124,8 b' class NotificationsController(BaseContro'
136
124
137 @auth.CSRFRequired()
125 @auth.CSRFRequired()
138 def delete(self, notification_id):
126 def delete(self, notification_id):
139 """DELETE /_admin/notifications/id: Delete an existing item"""
127 no = Notification.get_or_404(notification_id)
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)
146 try:
128 try:
147 no = Notification.get(notification_id)
148 if self._has_permissions(no):
129 if self._has_permissions(no):
149 # deletes only notification2user
130 # deletes only notification2user
150 NotificationModel().delete(c.rhodecode_user.user_id, no)
131 NotificationModel().delete(c.rhodecode_user.user_id, no)
@@ -156,10 +137,8 b' class NotificationsController(BaseContro'
156 raise HTTPBadRequest()
137 raise HTTPBadRequest()
157
138
158 def show(self, notification_id):
139 def show(self, notification_id):
159 """GET /_admin/notifications/id: Show a specific item"""
160 # url('notification', notification_id=ID)
161 c.user = c.rhodecode_user
140 c.user = c.rhodecode_user
162 no = Notification.get(notification_id)
141 no = Notification.get_or_404(notification_id)
163
142
164 if no and self._has_permissions(no):
143 if no and self._has_permissions(no):
165 unotification = NotificationModel()\
144 unotification = NotificationModel()\
General Comments 0
You need to be logged in to leave comments. Login now