Skip to content

Commit

Permalink
Remove post password
Browse files Browse the repository at this point in the history
  • Loading branch information
goors committed Nov 21, 2014
1 parent 7fb250f commit 0692fc6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
6 changes: 6 additions & 0 deletions PostModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,11 @@ def generateImage(self, size_w, size_h, filename, ex):
im.thumbnail(size, Image.ANTIALIAS)
im.save(UPLOAD_FOLDER + ex + filename, "JPEG")

def postRemovePass(self, id):
from models import db
p = self.Post.query.filter_by(Id=id).first()
p.Password = 'NULL'
db.session.commit()



9 changes: 9 additions & 0 deletions controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ def deletepost(id=None):
post.deletePost(id)
return redirect("/admin")

@admin_api.route('/admin/remove-password', methods=['POST'])
def removepassword():
if request.json['id']:
post = PostModel()
post.postRemovePass(request.json['id'])
response = {'status': 1, 'message': "Deleted"}

return json.jsonify(response)


@admin_api.route('/admin/users', methods=['GET'])
def users():
Expand Down
22 changes: 22 additions & 0 deletions templates/admin/add-post.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<input type="text" name="slug" {% if post %} value="{{post.Slug}}" {% endif%} class="form-control" placeholder="Slug" />
</div>
<div class="form-group">
{% if post %} {% if post.Password != 'NULL' %} <a href="javascript: void(0);" onclick="javscript: removePassword('{{post.Id}}', $(this))">Remove password</a> {% endif%} {% endif%}
<input type="password" name="password" class="form-control" placeholder="Post password" />
</div>
<div class="form-group">
Expand Down Expand Up @@ -141,6 +142,27 @@
});
}
}
function removePassword(id, el){
var g = id;
var id = {id:id}

if(id){

$.ajax({
type : "POST",
url : "/admin/remove-password",
data: JSON.stringify(id, null, '\t'),
contentType: 'application/json;charset=UTF-8',
success: function(result) {
if(result.status){
el.remove();

}
}
});
}
}

</script>
<style>
.redactor_box{
Expand Down

0 comments on commit 0692fc6

Please sign in to comment.