Skip to content

Commit e9bba25

Browse files
authored
fix: school creation and editing (#982)
2 parents 5295cac + 6135504 commit e9bba25

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

bullet/bullet_admin/views/education.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from django.contrib import messages
12
from django.http import HttpResponseRedirect
23
from django.urls import reverse, reverse_lazy
34
from django.views.generic import CreateView, ListView, UpdateView
@@ -6,7 +7,6 @@
67
from bullet import search
78
from bullet_admin.access import CountryAdminAccess, CountryAdminInAccess
89
from bullet_admin.forms.education import SchoolForm
9-
from bullet_admin.mixins import RedirectBackMixin
1010
from bullet_admin.utils import get_allowed_countries
1111
from bullet_admin.views import GenericForm, GenericList
1212

@@ -69,38 +69,43 @@ def get_edit_url(self, school: School) -> str:
6969
class SchoolUpdateView(
7070
CountryAdminInAccess,
7171
SchoolQuerySetMixin,
72-
RedirectBackMixin,
7372
GenericForm,
7473
UpdateView,
7574
):
7675
form_class = SchoolForm
7776
template_name = "bullet_admin/education/school_form.html"
7877
form_title = "Edit school"
7978
require_unlocked_competition = False
79+
success_url = reverse_lazy("badmin:school_list")
8080

8181
def get_permission_country(self):
8282
return self.get_object().country
8383

8484
def form_valid(self, form):
8585
school: School = form.save(commit=False)
86+
self.object = school
8687
school.importer_ignored = True
8788
school.save()
8889
form.save_m2m()
8990

91+
messages.success(self.request, "School saved.")
9092
return HttpResponseRedirect(self.get_success_url())
9193

9294

9395
class SchoolCreateView(
94-
CountryAdminAccess, SchoolQuerySetMixin, RedirectBackMixin, GenericForm, CreateView
96+
CountryAdminAccess, SchoolQuerySetMixin, GenericForm, CreateView
9597
):
9698
require_unlocked_competition = False
9799
form_class = SchoolForm
98100
form_title = "New school"
101+
success_url = reverse_lazy("badmin:school_list")
99102

100103
def form_valid(self, form):
101104
school: School = form.save(commit=False)
105+
self.object = school
102106
school.importer_ignored = True
103107
school.save()
104108
form.save_m2m()
105109

110+
messages.success(self.request, "School saved.")
106111
return HttpResponseRedirect(self.get_success_url())

0 commit comments

Comments
 (0)