approve comments
This commit is contained in:
parent
23232d4f0e
commit
1bafe193ad
@ -60,6 +60,7 @@ url_map = Map([
|
||||
url('/1.0/<re(".+"):path>/new', 'comment.create', ['POST']),
|
||||
url('/1.0/<re(".+"):path>/<int:id>', 'comment.get', ['GET']),
|
||||
url('/1.0/<re(".+"):path>/<int:id>', 'comment.modify', ['PUT', 'DELETE']),
|
||||
url('/1.0/<re(".+"):path>/<int:id>/approve', 'comment.approve', ['PUT'])
|
||||
], converters={'re': RegexConverter})
|
||||
|
||||
|
||||
|
@ -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')
|
||||
|
@ -9,13 +9,18 @@ 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() {
|
||||
$.ajax('DELETE', '/1.0/' + encodeURIComponent(path) + '/' + id)
|
||||
.then(function() {
|
||||
$(node).remove()
|
||||
});
|
||||
};
|
||||
|
@ -70,7 +70,7 @@
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2>Recent</h2>
|
||||
<h2 class="recent">Recent</h2>
|
||||
<span class="limit">
|
||||
[<a href="?${query(recentlimit=10)}">10</a>
|
||||
| <a href="?${query(recentlimit=20)}">20</a>
|
||||
|
Loading…
Reference in New Issue
Block a user