applications: add link to delete applications (#63273)
This commit is contained in:
parent
c3244f6b15
commit
6ab83a0e17
|
@ -0,0 +1,19 @@
|
|||
{% extends "hobo/base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block appbar %}
|
||||
<h2>{% blocktrans with title=object.name %}Removal of "{{ title }}"{% endblocktrans %}</h2>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<p>
|
||||
{% trans 'Are you sure you want to remove this application?' %}
|
||||
</p>
|
||||
<div class="buttons">
|
||||
<button class="delete-button">{% trans 'Delete' %}</button>
|
||||
<a class="cancel" href="{% url 'application-manifest' app_slug=view.kwargs.slug %}">{% trans 'Cancel' %}</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -22,6 +22,7 @@ urlpatterns = [
|
|||
url(r'^$', views.home, name='applications-home'),
|
||||
url(r'^create/$', views.init, name='application-init'),
|
||||
url(r'^install/$', views.install, name='application-install'),
|
||||
url(r'^manifest/(?P<slug>[\w-]+)/delete/$', views.delete, name='application-delete'),
|
||||
url(r'^manifest/(?P<app_slug>[\w-]+)/$', views.manifest, name='application-manifest'),
|
||||
url(r'^manifest/(?P<app_slug>[\w-]+)/metadata/$', views.metadata, name='application-metadata'),
|
||||
url(r'^manifest/(?P<app_slug>[\w-]+)/scandeps/$', views.scandeps, name='application-scandeps'),
|
||||
|
|
|
@ -298,3 +298,14 @@ class Install(FormView):
|
|||
|
||||
|
||||
install = Install.as_view()
|
||||
|
||||
|
||||
class AppDeleteView(DeleteView):
|
||||
model = Application
|
||||
template_name = 'hobo/applications/app_confirm_delete.html'
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('applications-home')
|
||||
|
||||
|
||||
delete = AppDeleteView.as_view()
|
||||
|
|
|
@ -178,6 +178,39 @@ def test_create_application(app, admin_user, settings):
|
|||
assert b'<carddef/>' in resp.content
|
||||
|
||||
|
||||
def test_delete_application(app, admin_user, settings):
|
||||
Wcs.objects.create(base_url='https://wcs.example.invalid', slug='foobar', title='Foobar')
|
||||
|
||||
settings.KNOWN_SERVICES = {
|
||||
'wcs': {
|
||||
'foobar': {
|
||||
'title': 'Foobar',
|
||||
'url': 'https://wcs.example.invalid/',
|
||||
'orig': 'example.org',
|
||||
'secret': 'xxx',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
login(app)
|
||||
|
||||
Application.objects.create(name='AppToDelete', slug='app_to_delete')
|
||||
Application.objects.create(name='OtherApp', slug='other_app')
|
||||
|
||||
assert Application.objects.count() == 2
|
||||
|
||||
resp = app.get('/applications/manifest/app_to_delete/delete/')
|
||||
|
||||
resp = resp.forms[0].submit()
|
||||
resp = resp.follow()
|
||||
|
||||
assert '/applications/' in resp
|
||||
assert 'AppToDelete' not in resp.text
|
||||
|
||||
assert Application.objects.count() == 1
|
||||
assert Application.objects.first().name == 'OtherApp'
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def app_bundle():
|
||||
tar_io = io.BytesIO()
|
||||
|
|
Loading…
Reference in New Issue