From cc7ce0440254faa7b48edbdfd7050ce4f2527d77 Mon Sep 17 00:00:00 2001 From: jym503558564 <503558564@qq.com> Date: Mon, 15 Jul 2019 09:53:22 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E5=88=9B=E5=BB=BA/=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=20=E8=BF=9C=E7=A8=8B=E5=BA=94=E7=94=A8=E6=8E=88?= =?UTF-8?q?=E6=9D=83=20=E4=BD=BF=E7=94=A8api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../remote_app_permission_create_update.html | 23 +++++++++++++++++++ apps/perms/views/remote_app_permission.py | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/apps/perms/templates/perms/remote_app_permission_create_update.html b/apps/perms/templates/perms/remote_app_permission_create_update.html index 3d6154991..66bbcdffa 100644 --- a/apps/perms/templates/perms/remote_app_permission_create_update.html +++ b/apps/perms/templates/perms/remote_app_permission_create_update.html @@ -116,5 +116,28 @@ $(document).ready(function () { $('#date_start').daterangepicker(dateOptions); $('#date_expired').daterangepicker(dateOptions); }) +.on("submit", "form", function (evt) { + evt.preventDefault(); + var form = $("form"); + var data = form.serializeObject(); + var method = "POST"; + var the_url = '{% url "api-perms:remote-app-permission-list" %}'; + var redirect_to = '{% url "perms:remote-app-permission-list" %}'; + {% if type == "update" %} + the_url = '{% url "api-perms:remote-app-permission-detail" pk=object.id %}'; + method = "PUT"; + {% endif %} + objectAttrsIsList(data, ['users', 'user_groups', 'remote_apps']); + objectAttrsIsDatetime(data, ['date_expired', 'date_start']); + objectAttrsIsBool(data, ['is_active']); + var props = { + url:the_url, + data:data, + method:method, + form:form, + redirect_to:redirect_to + }; + formSubmit(props); + }) {% endblock %} \ No newline at end of file diff --git a/apps/perms/views/remote_app_permission.py b/apps/perms/views/remote_app_permission.py index 3e8a6bff4..91774be0d 100644 --- a/apps/perms/views/remote_app_permission.py +++ b/apps/perms/views/remote_app_permission.py @@ -48,6 +48,7 @@ class RemoteAppPermissionCreateView(PermissionsMixin, CreateView): context = { 'app': _('Perms'), 'action': _('Create RemoteApp permission'), + 'type': 'create' } kwargs.update(context) return super().get_context_data(**kwargs) @@ -63,7 +64,8 @@ class RemoteAppPermissionUpdateView(PermissionsMixin, UpdateView): def get_context_data(self, **kwargs): context = { 'app': _('Perms'), - 'action': _('Update RemoteApp permission') + 'action': _('Update RemoteApp permission'), + 'type': 'update' } kwargs.update(context) return super().get_context_data(**kwargs)