Mercurial > kallithea
changeset 6076:d2ce61e4363d
routing: introduce 'notification_delete' url and use POST instead of DELETE
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Thu, 04 Aug 2016 14:23:36 +0200 |
parents | 2e294e1fb9e2 |
children | 949d50b31c22 |
files | kallithea/config/routing.py kallithea/public/js/base.js kallithea/templates/admin/notifications/notifications.html kallithea/templates/admin/notifications/show_notification.html kallithea/tests/functional/test_admin_notifications.py |
diffstat | 5 files changed, 8 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/config/routing.py Thu Aug 04 14:23:36 2016 +0200 +++ b/kallithea/config/routing.py Thu Aug 04 14:23:36 2016 +0200 @@ -379,8 +379,8 @@ action="index", conditions=dict(method=["GET"])) m.connect("/notifications/{notification_id}", action="update", conditions=dict(method=["PUT"])) - m.connect("/notifications/{notification_id}", - action="delete", conditions=dict(method=["DELETE"])) + m.connect("notification_delete", "/notifications/{notification_id}/delete", + action="delete", conditions=dict(method=["POST"])) m.connect("notification", "/notifications/{notification_id}", action="show", conditions=dict(method=["GET"])) m.connect("formatted_notification", "/notifications/{notification_id}.{format}",
--- a/kallithea/public/js/base.js Thu Aug 04 14:23:36 2016 +0200 +++ b/kallithea/public/js/base.js Thu Aug 04 14:23:36 2016 +0200 @@ -1000,7 +1000,7 @@ var failure = function(o){ alert("deleteNotification failure"); }; - var postData = {'_method': 'delete'}; + var postData = {}; var sUrl = url.replace('__NOTIFICATION_ID__',notification_id); ajaxPOST(sUrl, postData, success, failure); };
--- a/kallithea/templates/admin/notifications/notifications.html Thu Aug 04 14:23:36 2016 +0200 +++ b/kallithea/templates/admin/notifications/notifications.html Thu Aug 04 14:23:36 2016 +0200 @@ -35,11 +35,12 @@ </div> </div> <script type="text/javascript"> +var url_delete = "${url('notification_delete', notification_id='__NOTIFICATION_ID__')}"; var url_action = "${url('notification', notification_id='__NOTIFICATION_ID__')}"; var run = function(){ $('.delete-notification').click(function(e){ var notification_id = e.currentTarget.id; - deleteNotification(url_action,notification_id); + deleteNotification(url_delete,notification_id); }); $('.read-notification').click(function(e){ var notification_id = e.currentTarget.id;
--- a/kallithea/templates/admin/notifications/show_notification.html Thu Aug 04 14:23:36 2016 +0200 +++ b/kallithea/templates/admin/notifications/show_notification.html Thu Aug 04 14:23:36 2016 +0200 @@ -42,7 +42,7 @@ </div> </div> <script type="text/javascript"> -var url = "${url('notification', notification_id='__NOTIFICATION_ID__')}"; +var url = "${url('notification_delete', notification_id='__NOTIFICATION_ID__')}"; var main = "${url('notifications')}"; $('.delete-notification').click(function(e){ var notification_id = e.currentTarget.id;
--- a/kallithea/tests/functional/test_admin_notifications.py Thu Aug 04 14:23:36 2016 +0200 +++ b/kallithea/tests/functional/test_admin_notifications.py Thu Aug 04 14:23:36 2016 +0200 @@ -61,8 +61,8 @@ cur_usr_id = cur_user.user_id response = self.app.post( - url('notification', notification_id=notification.notification_id), - params={'_method': 'delete', '_authentication_token': self.authentication_token()}) + url('notification_delete', notification_id=notification.notification_id), + params={'_authentication_token': self.authentication_token()}) assert response.body == 'ok' cur_user = User.get(cur_usr_id)