Removed the get_error_url method and the error_url property, because we bounce to the same current URL now in the Mia core application.

This commit is contained in:
依瑪貓 2020-08-14 01:01:45 +08:00
parent c353e17db2
commit 6e64918cd9
2 changed files with 1 additions and 23 deletions

View File

@ -1009,12 +1009,6 @@ class AccountFormView(FormView):
obj.title = form["title"].value()
obj.current_user = self.request.user
def get_error_url(self) -> str:
"""Returns the URL on error."""
user = self.get_object()
return reverse("accounting:accounts.create") if user is None\
else reverse("accounting:accounts.update", args=(user,))
def get_object(self) -> Optional[Account]:
"""Returns the current object, or None on a create form."""
if "account" in self.kwargs:

View File

@ -50,7 +50,6 @@ class FormView(View):
form: Type[forms.Form] = None
template_name: str = None
context_object_name: str = "form"
error_url: str = None
success_url: str = None
not_modified_message: str = None
success_message: str = None
@ -88,8 +87,7 @@ class FormView(View):
utils.strip_post(post)
form = self.make_form_from_post(post)
if not form.is_valid():
url = str(utils.UrlBuilder(self.get_error_url())
.query(r=self.request.GET.get("r")))
url = str(utils.UrlBuilder(self.request.get_full_path()))
return stored_post.error_redirect(self.request, url, post)
if obj is None:
obj = self._model()
@ -154,14 +152,6 @@ class FormView(View):
for name in form.fields:
setattr(obj, name, form[name].value())
def get_error_url(self) -> str:
"""Returns the URL on error."""
if self.error_url is not None:
return self.error_url
raise AttributeError(
"Please define either the error_url property"
" or the get_error_url method.")
def get_success_url(self) -> str:
"""Returns the URL on success."""
if self.success_url is not None:
@ -270,12 +260,6 @@ class UserFormView(FormView):
obj.is_disabled = form["is_disabled"].value()
obj.current_user = self.request.user
def get_error_url(self) -> str:
"""Returns the URL on error."""
user = self.get_object()
return reverse("mia_core:users.create") if user is None\
else reverse("mia_core:users.update", args=(user,))
def get_object(self) -> Optional[Model]:
"""Returns the current object, or None on a create form."""
if "user" in self.kwargs: