Renamed the get_current_object method of FormView to get_object, to follow the convention of Django form views in the Mia core application.

This commit is contained in:
2020-08-14 00:44:14 +08:00
parent be2ffbf79e
commit 21c9db396d
2 changed files with 15 additions and 15 deletions

View File

@ -991,7 +991,7 @@ class AccountFormView(FormView):
def make_form_from_post(self, post: Dict[str, str]) -> AccountForm:
"""Creates and returns the form from the POST data."""
form = AccountForm(post)
form.account = self.get_current_object()
form.account = self.get_object()
return form
def make_form_from_model(self, obj: Account) -> AccountForm:
@ -1011,11 +1011,11 @@ class AccountFormView(FormView):
def get_error_url(self) -> str:
"""Returns the URL on error."""
user = self.get_current_object()
user = self.get_object()
return reverse("accounting:accounts.create") if user is None\
else reverse("accounting:accounts.edit", args=(user,))
def get_current_object(self) -> Optional[Account]:
def get_object(self) -> Optional[Account]:
"""Returns the current object, or None on a create form."""
if "account" in self.kwargs:
return self.kwargs["account"]