Munch simpler solution using link-button.

This commit is contained in:
Marcus Scholz 2020-08-12 12:38:50 +02:00
parent 8b01bbb2ce
commit 313748f5ac
2 changed files with 11 additions and 13 deletions

View File

@ -10,12 +10,14 @@
<legend class="LP-Form__Legend">Place löschen</legend>
{% csrf_token %}
<div class="LP-Form__Composition LP-Form__Composition--breakable">
<p class="LP-Paragraph">Are you sure you want to delete "{{place.name}}"?</p>
<div class="LP-Form__Composition">
<input type="submit" class="LP-Button LP-Button--cancel" name="cancel" value="Cancel"/>
<input type="submit" class="LP-Button" name="Delete" value="Delete"/>
</div>
</div>
</fieldset>
<p class="LP-Paragraph">Are you sure you want to delete "{{place.name}}"?</p>
<div class="LP-Form__Composition">
<a href="{% url 'place_detail' pk=place.pk %}"
<button class="LP-Button LP-Button--cancel">Cancel</button>
</a>
<input type="submit" class="LP-Button" value="Delete"/>
</div>
</div>
</fieldset>
</form>
{% endblock maincontent %}

View File

@ -98,10 +98,6 @@ class PlaceCreateView(View):
class PlaceDeleteView(DeleteView):
template_name = 'place/place_delete.html'
model = Place
success_url = reverse_lazy('place_list')
def post(self, request, *args, **kwargs):
if "cancel" in request.POST:
return redirect(self.success_url)
else:
return super(PlaceDeleteView, self).post(request, *args, **kwargs)
def get_success_url(self):
return reverse_lazy('place_list')