0001-applications-add-link-to-delete-applications-63273.patch
hobo/applications/templates/hobo/applications/app_confirm_delete.html | ||
---|---|---|
1 |
{% extends "hobo/base.html" %} |
|
2 |
{% load i18n %} |
|
3 | ||
4 |
{% block appbar %} |
|
5 |
<h2>{% blocktrans with title=object.name %}Removal of "{{ title }}"{% endblocktrans %}</h2> |
|
6 |
{% endblock %} |
|
7 | ||
8 |
{% block content %} |
|
9 |
<form method="post"> |
|
10 |
{% csrf_token %} |
|
11 |
<p> |
|
12 |
{% trans 'Are you sure you want to remove this application ?' %} |
|
13 |
</p> |
|
14 |
<div class="buttons"> |
|
15 |
<button class="delete-button">{% trans 'Delete' %}</button> |
|
16 |
<a class="cancel" href="{% url 'application-manifest' app_slug=view.kwargs.slug %}">{% trans 'Cancel' %}</a> |
|
17 |
</div> |
|
18 |
</form> |
|
19 |
{% endblock %} |
hobo/applications/urls.py | ||
---|---|---|
22 | 22 |
url(r'^$', views.home, name='applications-home'), |
23 | 23 |
url(r'^create/$', views.init, name='application-init'), |
24 | 24 |
url(r'^install/$', views.install, name='application-install'), |
25 |
url(r'^manifest/(?P<slug>[\w-]+)/delete/$', views.delete, name='application-delete'), |
|
25 | 26 |
url(r'^manifest/(?P<app_slug>[\w-]+)/$', views.manifest, name='application-manifest'), |
26 | 27 |
url(r'^manifest/(?P<app_slug>[\w-]+)/metadata/$', views.metadata, name='application-metadata'), |
27 | 28 |
url(r'^manifest/(?P<app_slug>[\w-]+)/scandeps/$', views.scandeps, name='application-scandeps'), |
hobo/applications/views.py | ||
---|---|---|
298 | 298 | |
299 | 299 | |
300 | 300 |
install = Install.as_view() |
301 | ||
302 | ||
303 |
class AppDeleteView(DeleteView): |
|
304 |
model = Application |
|
305 |
template_name = 'hobo/applications/app_confirm_delete.html' |
|
306 | ||
307 |
def get_success_url(self): |
|
308 |
return reverse('applications-home') |
|
309 | ||
310 | ||
311 |
delete = AppDeleteView.as_view() |
tests/test_application.py | ||
---|---|---|
178 | 178 |
assert b'<carddef/>' in resp.content |
179 | 179 | |
180 | 180 | |
181 |
def test_delete_application(app, admin_user, settings): |
|
182 |
Wcs.objects.create(base_url='https://wcs.example.invalid', slug='foobar', title='Foobar') |
|
183 | ||
184 |
settings.KNOWN_SERVICES = { |
|
185 |
'wcs': { |
|
186 |
'foobar': { |
|
187 |
'title': 'Foobar', |
|
188 |
'url': 'https://wcs.example.invalid/', |
|
189 |
'orig': 'example.org', |
|
190 |
'secret': 'xxx', |
|
191 |
} |
|
192 |
} |
|
193 |
} |
|
194 | ||
195 |
login(app) |
|
196 | ||
197 |
Application.objects.create(name='AppToDelete', slug='app_to_delete') |
|
198 |
Application.objects.create(name='OtherApp', slug='other_app') |
|
199 | ||
200 |
assert Application.objects.count() == 2 |
|
201 | ||
202 |
resp = app.get('/applications/manifest/app_to_delete/delete/') |
|
203 | ||
204 |
resp = resp.forms[0].submit() |
|
205 |
resp = resp.follow() |
|
206 | ||
207 |
assert '/applications/' in resp |
|
208 |
assert 'AppToDelete' not in resp.text |
|
209 | ||
210 |
assert Application.objects.count() == 1 |
|
211 |
assert Application.objects.first().name == 'OtherApp' |
|
212 | ||
213 | ||
181 | 214 |
@pytest.fixture |
182 | 215 |
def app_bundle(): |
183 | 216 |
tar_io = io.BytesIO() |
184 |
- |