From c353e17db219f4ccb41893b7a9e0e17c68fe9632 Mon Sep 17 00:00:00 2001 From: imacat Date: Fri, 14 Aug 2020 00:53:10 +0800 Subject: [PATCH] Combined the create and store URL, and the edit and update URL of the users to simplify the URL pattern settings, because they are handled by the same view now in the Mia core application application. --- mia_core/templates/mia_core/user_detail.html | 2 +- mia_core/templates/mia_core/user_form.html | 2 +- mia_core/urls.py | 2 -- mia_core/views.py | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mia_core/templates/mia_core/user_detail.html b/mia_core/templates/mia_core/user_detail.html index 409e5f3..d8a520c 100644 --- a/mia_core/templates/mia_core/user_detail.html +++ b/mia_core/templates/mia_core/user_detail.html @@ -79,7 +79,7 @@ First written: 2020/8/9 {{ _("Back")|force_escape }} - + {{ _("Settings")|force_escape }} diff --git a/mia_core/templates/mia_core/user_form.html b/mia_core/templates/mia_core/user_form.html index 178ccee..96935ce 100644 --- a/mia_core/templates/mia_core/user_form.html +++ b/mia_core/templates/mia_core/user_form.html @@ -42,7 +42,7 @@ First written: 2020/8/9 -
+ {% csrf_token %} diff --git a/mia_core/urls.py b/mia_core/urls.py index 9d8b417..fc50c86 100644 --- a/mia_core/urls.py +++ b/mia_core/urls.py @@ -32,9 +32,7 @@ urlpatterns = [ path("logout", views.logout, name="logout"), path("users", views.UserListView.as_view(), name="users"), path("users/create", views.UserFormView.as_view(), name="users.create"), - path("users/store", views.UserFormView.as_view(), name="users.store"), path("users/", views.UserView.as_view(), name="users.detail"), - path("users//edit", views.UserFormView.as_view(), name="users.edit"), path("users//update", views.UserFormView.as_view(), name="users.update"), path("users//delete", views.user_delete, name="users.delete"), path("api/users//exists", views.api_users_exists, diff --git a/mia_core/views.py b/mia_core/views.py index 3ef7abe..93f471f 100644 --- a/mia_core/views.py +++ b/mia_core/views.py @@ -274,7 +274,7 @@ class UserFormView(FormView): """Returns the URL on error.""" user = self.get_object() return reverse("mia_core:users.create") if user is None\ - else reverse("mia_core:users.edit", args=(user,)) + else reverse("mia_core:users.update", args=(user,)) def get_object(self) -> Optional[Model]: """Returns the current object, or None on a create form."""