Get delete page feature working
This commit is contained in:
parent
4ef08cc988
commit
4e4cdf6348
|
@ -24,3 +24,12 @@ def wiki_rename_page(old_name, *args, **kwargs):
|
||||||
return
|
return
|
||||||
|
|
||||||
return search.delete_wiki(old_name)
|
return search.delete_wiki(old_name)
|
||||||
|
|
||||||
|
|
||||||
|
@Wiki.after('delete_page')
|
||||||
|
def wiki_delete_page(name, *args, **kwargs):
|
||||||
|
|
||||||
|
if not hasattr(search, 'index_wiki'):
|
||||||
|
return
|
||||||
|
|
||||||
|
return search.delete_wiki(name)
|
||||||
|
|
|
@ -156,11 +156,14 @@ class Wiki(HookMixin):
|
||||||
message = "Deleted %s" % name
|
message = "Deleted %s" % name
|
||||||
|
|
||||||
filename = cname_to_filename(name)
|
filename = cname_to_filename(name)
|
||||||
|
|
||||||
|
# gittle.rm won't actually remove the file, have to do it ourselves
|
||||||
|
os.remove(os.path.join(self.path, filename))
|
||||||
self.gittle.rm(filename)
|
self.gittle.rm(filename)
|
||||||
commit = self.gittle.commit(name=username,
|
commit = self.gittle.commit(name=username,
|
||||||
email=email,
|
email=email,
|
||||||
message=message,
|
message=message,
|
||||||
files=[str(filename)])
|
files=[filename])
|
||||||
cache.delete_many(name)
|
cache.delete_many(name)
|
||||||
return commit
|
return commit
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,11 @@ class WikiTest(WikiBaseTest):
|
||||||
self.assert_403(self.client.delete(url_for('wiki.page_write', name='test')))
|
self.assert_403(self.client.delete(url_for('wiki.page_write', name='test')))
|
||||||
self.app.config['WIKI_LOCKED_PAGES'] = []
|
self.app.config['WIKI_LOCKED_PAGES'] = []
|
||||||
|
|
||||||
|
# Create page, check it exists
|
||||||
|
self.create_page('test', message='test message', content='testing')
|
||||||
|
self.assert_200(self.client.get(url_for('wiki.page', name='test')))
|
||||||
|
|
||||||
|
# Delete page
|
||||||
self.assert_200(self.client.delete(url_for('wiki.page_write', name='test')))
|
self.assert_200(self.client.delete(url_for('wiki.page_write', name='test')))
|
||||||
|
|
||||||
rv = self.client.get(url_for('wiki.page', name='test'))
|
rv = self.client.get(url_for('wiki.page', name='test'))
|
||||||
|
|
|
@ -151,12 +151,12 @@ def page_write(name):
|
||||||
|
|
||||||
return dict(sha=sha)
|
return dict(sha=sha)
|
||||||
|
|
||||||
else:
|
elif request.method == 'DELETE':
|
||||||
# DELETE
|
# DELETE
|
||||||
if cname in current_app.config.get('WIKI_LOCKED_PAGES'):
|
if cname in current_app.config.get('WIKI_LOCKED_PAGES'):
|
||||||
return dict(error=True, message="Page is locked"), 403
|
return dict(error=True, message="Page is locked"), 403
|
||||||
|
|
||||||
sha = g.current_wiki.delete_page(name,
|
sha = g.current_wiki.delete_page(cname,
|
||||||
username=current_user.username,
|
username=current_user.username,
|
||||||
email=current_user.email)
|
email=current_user.email)
|
||||||
|
|
||||||
|
|
|
@ -58,10 +58,31 @@ $(function(){
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#delete-page-btn").click(function() {
|
$("#delete-page-btn").click(function() {
|
||||||
bootbox.alert("Not Done Yet! Sorry");
|
bootbox.confirm('Are you sure you want to delete this page?', function(result) {
|
||||||
|
if (result) {
|
||||||
|
deletePage();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var deletePage = function() {
|
||||||
|
var pageName = $page_name.val();
|
||||||
|
var path = Config['RELATIVE_PATH'] + '/' + pageName;
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'DELETE',
|
||||||
|
url: path,
|
||||||
|
}).done(function(data) {
|
||||||
|
var msg = 'Deleted page: ' + pageName;
|
||||||
|
bootbox.alert(msg, function() {
|
||||||
|
location.href = '/';
|
||||||
|
});
|
||||||
|
}).fail(function(data, status, error) {
|
||||||
|
bootbox.alert('Error deleting page!');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var aced = new Aced({
|
var aced = new Aced({
|
||||||
editor: $('#entry-markdown-content').find('.editor').attr('id'),
|
editor: $('#entry-markdown-content').find('.editor').attr('id'),
|
||||||
renderer: function(md) { return MDR.convert(md) },
|
renderer: function(md) { return MDR.convert(md) },
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -36,7 +36,7 @@ setup(name='realms-wiki',
|
||||||
'click==3.3',
|
'click==3.3',
|
||||||
'gevent==1.0.2',
|
'gevent==1.0.2',
|
||||||
'ghdiff==0.4',
|
'ghdiff==0.4',
|
||||||
'gittle==0.4.0',
|
'gittle==0.5.0',
|
||||||
'gunicorn==19.3',
|
'gunicorn==19.3',
|
||||||
'itsdangerous==0.24',
|
'itsdangerous==0.24',
|
||||||
'markdown2==2.3.0',
|
'markdown2==2.3.0',
|
||||||
|
|
Loading…
Reference in a new issue