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.
This commit is contained in:
parent
0398fb609e
commit
c353e17db2
@ -79,7 +79,7 @@ First written: 2020/8/9
|
||||
<i class="fas fa-chevron-circle-left"></i>
|
||||
{{ _("Back")|force_escape }}
|
||||
</a>
|
||||
<a class="btn btn-primary" role="button" href="{% url "mia_core:users.edit" user %}">
|
||||
<a class="btn btn-primary" role="button" href="{% url "mia_core:users.update" user %}">
|
||||
<i class="fas fa-user-cog"></i>
|
||||
{{ _("Settings")|force_escape }}
|
||||
</a>
|
||||
|
@ -42,7 +42,7 @@ First written: 2020/8/9
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<form id="user-form" action="{% if request|is_in_section:"mia_core:my-account" %}{% url "mia_core:my-account.update" %}{% elif form.user %}{% url "mia_core:users.update" form.user %}{% else %}{% url "mia_core:users.store" %}{% endif %}" method="POST">
|
||||
<form id="user-form" action="{% if request|is_in_section:"mia_core:my-account" %}{% url "mia_core:my-account.update" %}{% elif form.user %}{% url "mia_core:users.update" form.user %}{% else %}{% url "mia_core:users.create" %}{% endif %}" method="POST">
|
||||
{% csrf_token %}
|
||||
<input id="exists-url" type="hidden" value="{% url "mia_core:api.users.exists" "ID" %}" />
|
||||
<input id="user-login-id-original" type="hidden" value="{{ form.user.login_id }}" />
|
||||
|
@ -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/<user:user>", views.UserView.as_view(), name="users.detail"),
|
||||
path("users/<user:user>/edit", views.UserFormView.as_view(), name="users.edit"),
|
||||
path("users/<user:user>/update", views.UserFormView.as_view(), name="users.update"),
|
||||
path("users/<user:user>/delete", views.user_delete, name="users.delete"),
|
||||
path("api/users/<str:login_id>/exists", views.api_users_exists,
|
||||
|
@ -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."""
|
||||
|
Loading…
Reference in New Issue
Block a user