approve comments

This commit is contained in:
posativ 2012-10-27 22:33:23 +02:00
parent 23232d4f0e
commit 1bafe193ad
4 changed files with 22 additions and 4 deletions

View File

@ -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})

View File

@ -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')

View File

@ -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();

View File

@ -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>