Skip to content

[ENG-8246] Fixed deletion of maintenance alerts in admin #11226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion admin/maintenance/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from admin.maintenance.forms import MaintenanceForm

from django.shortcuts import redirect
from django.urls import reverse_lazy
from django.forms.models import model_to_dict
from django.views.generic import DeleteView, TemplateView
from django.contrib.auth.mixins import PermissionRequiredMixin
Expand All @@ -15,11 +16,13 @@ class DeleteMaintenance(PermissionRequiredMixin, DeleteView):
permission_required = 'osf.delete_maintenancestate'
raise_exception = True
template_name = 'maintenance/delete_maintenance.html'
success_url = reverse_lazy('maintenance:display')

def get_object(self, queryset=None):
return MaintenanceState.objects.first()

def delete(self, request, *args, **kwargs):
def post(self, request, *args, **kwargs):
super().post(request, *args, **kwargs)
maintenance.unset_maintenance()
return redirect('maintenance:display')

Expand Down
2 changes: 1 addition & 1 deletion admin_tests/maintenance/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def view(self, req, plain_view):
return view

def test_delete(self, view, req):
res = view.delete(req)
res = view.post(req)
assert res.url == '/maintenance/'
assert res.status_code == 302
assert MaintenanceState.objects.all().count() == 0
Expand Down
Loading