diff --git a/apps/perms/templates/perms/asset_permission_detail.html b/apps/perms/templates/perms/asset_permission_detail.html index f9c11cb67..beaa5a362 100644 --- a/apps/perms/templates/perms/asset_permission_detail.html +++ b/apps/perms/templates/perms/asset_permission_detail.html @@ -68,7 +68,7 @@ {% trans 'User group count' %}: - {{ object.users.count }} + {{ object.user_groups.count }} {% trans 'Asset count' %}: 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)