diff --git a/isso/__init__.py b/isso/__init__.py index 23642fb..0883ebb 100644 --- a/isso/__init__.py +++ b/isso/__init__.py @@ -60,6 +60,7 @@ url_map = Map([ url('/1.0//new', 'comment.create', ['POST']), url('/1.0//', 'comment.get', ['GET']), url('/1.0//', 'comment.modify', ['PUT', 'DELETE']), + url('/1.0///approve', 'comment.approve', ['PUT']) ], converters={'re': RegexConverter}) diff --git a/isso/comment.py b/isso/comment.py index 2296698..060ffc9 100644 --- a/isso/comment.py +++ b/isso/comment.py @@ -89,3 +89,15 @@ def modify(app, environ, request, path, id): response = Response(json.dumps(rv), 200, content_type='application/json') response.delete_cookie('session-%s-%s' % (urllib.quote(path, ''), id)) return response + + +def approve(app, environ, request, path, id): + + try: + if app.unsign(request.cookies.get('session-admin', '')) != '*': + abort(403) + except (SignatureExpired, BadSignature): + abort(403) + + app.db.activate(path, id) + return Response(json.dumps(app.db.get(path, id)), 200, content_type='application/json') diff --git a/isso/templates/admin.js b/isso/templates/admin.js index 6e9987c..40bcd4b 100644 --- a/isso/templates/admin.js +++ b/isso/templates/admin.js @@ -9,14 +9,19 @@ function initialize() { if (item.text == 'Approve') { $(item).on('click', function(event) { + $.ajax('PUT', '/1.0/' + encodeURIComponent(path) + '/' + id + '/approve') + .then(function(status, rv) { + // $(node).detach(); + $('h2.recent + span').after(node); + }); event.stop(); }); } else { $(item).on('click', function(event) { if (confirm("RLY?") == true) { - $.ajax('DELETE', '/1.0/' + encodeURIComponent(path) + '/' + id).then( - function() { - $(node).remove() + $.ajax('DELETE', '/1.0/' + encodeURIComponent(path) + '/' + id) + .then(function() { + $(node).remove() }); }; event.stop(); diff --git a/isso/templates/admin.mako b/isso/templates/admin.mako index eeb5938..6137460 100644 --- a/isso/templates/admin.mako +++ b/isso/templates/admin.mako @@ -70,7 +70,7 @@
-

Recent

+

Recent

[10 | 20