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:
parent
c353e17db2
commit
6e64918cd9
@ -1009,12 +1009,6 @@ class AccountFormView(FormView):
|
|||||||
obj.title = form["title"].value()
|
obj.title = form["title"].value()
|
||||||
obj.current_user = self.request.user
|
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]:
|
def get_object(self) -> Optional[Account]:
|
||||||
"""Returns the current object, or None on a create form."""
|
"""Returns the current object, or None on a create form."""
|
||||||
if "account" in self.kwargs:
|
if "account" in self.kwargs:
|
||||||
|
@ -50,7 +50,6 @@ class FormView(View):
|
|||||||
form: Type[forms.Form] = None
|
form: Type[forms.Form] = None
|
||||||
template_name: str = None
|
template_name: str = None
|
||||||
context_object_name: str = "form"
|
context_object_name: str = "form"
|
||||||
error_url: str = None
|
|
||||||
success_url: str = None
|
success_url: str = None
|
||||||
not_modified_message: str = None
|
not_modified_message: str = None
|
||||||
success_message: str = None
|
success_message: str = None
|
||||||
@ -88,8 +87,7 @@ class FormView(View):
|
|||||||
utils.strip_post(post)
|
utils.strip_post(post)
|
||||||
form = self.make_form_from_post(post)
|
form = self.make_form_from_post(post)
|
||||||
if not form.is_valid():
|
if not form.is_valid():
|
||||||
url = str(utils.UrlBuilder(self.get_error_url())
|
url = str(utils.UrlBuilder(self.request.get_full_path()))
|
||||||
.query(r=self.request.GET.get("r")))
|
|
||||||
return stored_post.error_redirect(self.request, url, post)
|
return stored_post.error_redirect(self.request, url, post)
|
||||||
if obj is None:
|
if obj is None:
|
||||||
obj = self._model()
|
obj = self._model()
|
||||||
@ -154,14 +152,6 @@ class FormView(View):
|
|||||||
for name in form.fields:
|
for name in form.fields:
|
||||||
setattr(obj, name, form[name].value())
|
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:
|
def get_success_url(self) -> str:
|
||||||
"""Returns the URL on success."""
|
"""Returns the URL on success."""
|
||||||
if self.success_url is not None:
|
if self.success_url is not None:
|
||||||
@ -270,12 +260,6 @@ class UserFormView(FormView):
|
|||||||
obj.is_disabled = form["is_disabled"].value()
|
obj.is_disabled = form["is_disabled"].value()
|
||||||
obj.current_user = self.request.user
|
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]:
|
def get_object(self) -> Optional[Model]:
|
||||||
"""Returns the current object, or None on a create form."""
|
"""Returns the current object, or None on a create form."""
|
||||||
if "user" in self.kwargs:
|
if "user" in self.kwargs:
|
||||||
|
Loading…
Reference in New Issue
Block a user