ikiwiki: Add delete command for wikis and blogs.

This commit is contained in:
James Valleroy authored and Sunil Mohan Adapa committed 2015-04-13 20:43:07 +05:30
1 parent 1464ff3184
commit 18234850ff
5 files changed
+101 -11

No files matched your search

@@ -0,0 +1,39 @@
{% extends "base.html" %}
{% comment %}
#
# This file is part of Plinth.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
{% endcomment %}
{% load bootstrap %}
{% block content %}
<h3>Delete Wiki/Blog <em>{{ name }}</em></h3>
<p>Delete this wiki/blog permanently?</p>
<form class="form" method="post">
{% csrf_token %}
<input type="submit" class="btn btn-md btn-primary"
value="Delete {{ name }}"/>
<a href="{% url 'ikiwiki:manage' %}" role="button"
class="btn btn-md btn-primary">Cancel</a>
</form>
{% endblock %}
@@ -39,7 +39,7 @@
<div class="list-group">
{% for site in sites %}
<div class="list-group-item clearfix">
<a href="{% url 'ikiwiki:index' %}"
<a href="{% url 'ikiwiki:delete' site %}"
class="btn btn-default btn-sm pull-right"
role="button" title="Delete site {{ site }}">
<span class="glyphicon glyphicon-trash"
+1
View File
@@ -26,5 +26,6 @@ urlpatterns = patterns(
'plinth.modules.ikiwiki.views',
url(r'^apps/ikiwiki/$', 'index', name='index'),
url(r'^apps/ikiwiki/manage/$', 'manage', name='manage'),
url(r'^apps/ikiwiki/(?P<name>[\w.@+-]+)/delete/$', 'delete', name='delete'),
url(r'^apps/ikiwiki/create/$', 'create', name='create'),
)
+34 -3
View File
@@ -22,6 +22,7 @@ Plinth module for configuring ikiwiki
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse_lazy
from django.shortcuts import redirect
from django.template.response import TemplateResponse
from gettext import gettext as _
@@ -109,7 +110,8 @@ def create(request):
_create_wiki(request, form.cleaned_data['name'])
elif form.cleaned_data['type'] == 'blog':
_create_blog(request, form.cleaned_data['name'])
form = IkiwikiCreateForm(prefix='ikiwiki')
return redirect(reverse_lazy('ikiwiki:manage'))
else:
form = IkiwikiCreateForm(prefix='ikiwiki')
@@ -121,9 +123,38 @@ def create(request):
def _create_wiki(request, name):
"""Create wiki."""
actions.superuser_run('ikiwiki', ['create-wiki', '--name', name])
try:
actions.superuser_run('ikiwiki', ['create-wiki', '--name', name])
messages.success(request, _('Created wiki %s.') % name)
except actions.ActionError as err:
messages.error(request, _('Could not create wiki: %s') % err)
def _create_blog(request, name):
"""Create blog."""
actions.superuser_run('ikiwiki', ['create-blog', '--name', name])
try:
actions.superuser_run('ikiwiki', ['create-blog', '--name', name])
messages.success(request, _('Created blog %s.') % name)
except actions.ActionError as err:
messages.error(request, _('Could not create blog: %s') % err)
@login_required
def delete(request, name):
"""Handle deleting wikis/blogs, showing a confirmation dialog first.
On GET, display a confirmation page.
On POST, delete the wiki/blog.
"""
if request.method == 'POST':
try:
actions.superuser_run('ikiwiki', ['delete', '--name', name])
messages.success(request, _('%s deleted.') % name)
except actions.ActionError as err:
messages.error(request, _('Could not delete %s: %s') % (name, err))
return redirect(reverse_lazy('ikiwiki:manage'))
return TemplateResponse(request, 'ikiwiki_delete.html',
{'title': _('Delete Wiki/Blog'),
'subsubmenu': subsubmenu,
'name': name})