implement website deletion

- implement websites.views.DeleteWebsite
- add URL pattern 'delete_website' to websites.urls
- add template website_confirm_delete.html
- add link from hostingpackage page to 'delete_website'
- add changelog entry
This commit is contained in:
Jan Dittberner 2015-01-27 16:26:10 +01:00
parent 5ad32e6894
commit 7da5cfe406
5 changed files with 62 additions and 1 deletions

View file

@ -1,6 +1,7 @@
Changelog Changelog
========= =========
* :feature:`-` implement deletion of websites
* :feature:`-` implement setup of websites * :feature:`-` implement setup of websites
* :support:`-` add webtasks interface * :support:`-` add webtasks interface
* :support:`-` update to new fileservertasks interface (requires gvafile >= * :support:`-` update to new fileservertasks interface (requires gvafile >=

View file

@ -107,7 +107,7 @@
{% with domain=domain.domain %} {% with domain=domain.domain %}
{% for website in domain.website_set.all %}{% spaceless %} {% for website in domain.website_set.all %}{% spaceless %}
{{ website }} {{ website }}
<a href="#" titel="{% trans "Delete website" %}"><i class="glyphicon glyphicon-trash"></i><span class="sr-only"> {% trans "Delete website" %}</span></a> <a href="{% url 'delete_website' package=hostingpackage.id domain=domain.domain pk=website.id %}" titel="{% trans "Delete website" %}"><i class="glyphicon glyphicon-trash"></i><span class="sr-only"> {% trans "Delete website" %}</span></a>
{% endspaceless %}{% if not forloop.last %}, {% endif %}{% endfor %} {% endspaceless %}{% if not forloop.last %}, {% endif %}{% endfor %}
{% endwith %} {% endwith %}
</td> </td>

View file

@ -0,0 +1,34 @@
{% extends "websites/base.html" %}
{% load i18n %}
{% block title %}{{ block.super }} - {% spaceless %}
{% if user == customer %}
{% blocktrans %}Delete Website {{ website }}{% endblocktrans %}
{% else %}
{% blocktrans with full_name=customer.get_full_name %}Delete Website {{ website }} of Customer {{ full_name }}{% endblocktrans %}
{% endif %}
{% endspaceless %}{% endblock title %}
{% block page_title %}{% spaceless %}
{% if user == customer %}
{% blocktrans %}Delete Website <small>{{ website }}</small>{% endblocktrans %}
{% else %}
{% blocktrans with full_name=customer.get_full_name %}Delete Website <small>{{ website }} of Customer {{ full_name }}</small>{% endblocktrans %}
{% endif %}
{% endspaceless %}{% endblock page_title %}
{% block content %}
<div class="panel panel-warning">
<div class="panel-heading">
{% blocktrans %}Do you really want to delete the website {{ website }}?{% endblocktrans %}
</div>
<div class="panel-body">
<p>{% blocktrans %}Please be aware that the website directory is removed from the webserver and the webserver configuration is changed so that the website will not be reachable anymore. <strong>All data in the website directory will be lost!</strong>{% endblocktrans %}</p>
<form action="{% url 'delete_website' package=hostingpackage.id domain=website.domain.domain pk=website.id %}" method="post" class="form">
{% csrf_token %}
<input class="btn btn-warning" type="submit" value="{% trans "Yes, do it!" %}" />
<a class="btn btn-default" href="{{ hostingpackage.get_absolute_url }}">{% trans "Cancel" %}</a>
</form>
</div>
</div>
{% endblock content %}

View file

@ -8,6 +8,7 @@ from django.conf.urls import patterns, url
from .views import ( from .views import (
AddWebsite, AddWebsite,
DeleteWebsite,
) )
@ -15,4 +16,6 @@ urlpatterns = patterns(
'', '',
url(r'^(?P<package>\d+)/(?P<domain>[\w0-9.-]+)/create$', url(r'^(?P<package>\d+)/(?P<domain>[\w0-9.-]+)/create$',
AddWebsite.as_view(), name='add_website'), AddWebsite.as_view(), name='add_website'),
url(r'^(?P<package>\d+)/(?P<domain>[\w0-9.-]+)/(?P<pk>\d+)/delete$',
DeleteWebsite.as_view(), name='delete_website'),
) )

View file

@ -8,6 +8,7 @@ from django.shortcuts import get_object_or_404, redirect
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.views.generic.edit import ( from django.views.generic.edit import (
CreateView, CreateView,
DeleteView,
) )
from django.contrib import messages from django.contrib import messages
@ -58,3 +59,25 @@ class AddWebsite(
) )
) )
return redirect(self.get_hosting_package()) return redirect(self.get_hosting_package())
class DeleteWebsite(
HostingPackageAndCustomerMixin, StaffOrSelfLoginRequiredMixin, DeleteView
):
"""
This view is used to delete websites in a customer hosting package.
"""
context_object_name = 'website'
model = Website
def get_context_data(self, **kwargs):
context = super(DeleteWebsite, self).get_context_data(**kwargs)
context.update({
'customer': self.get_customer_object(),
'hostingpackage': self.get_hosting_package(),
})
return context
def get_success_url(self):
return self.get_hosting_package().get_absolute_url()