def Query(self, id=None): self.role = Role.first_or_new(id=id) permissions = Permission.order_by('sort', 'asc').get() actions = [] if hasattr(self.role, 'actions'): actions = self.role.actions.pluck('id').to_json() permission = {'permissions': permissions, 'actions': actions} return {'role': self.role, 'permission': permission}
def save(self, id = None): permission = Permission.first_or_new(id=id) form = PermissionEditLayout(request.form) if form.isValidated() == False: errors = '<br />'.join(form.getValidationError()) flash(errors, 'danger') return redirect(request.url.replace('/save','')) permission.fill(form.getFormData()).save() flash('Successfully deleted.', 'success') return redirect(url_for('admin.toolbox.access.permission.list'))
def save(self, id=None, permission_id=None): permission = Permission.find(permission_id) if not permission: return redirect(request.url.replace('/save', '')) action = Action.first_or_new(id=id) form = ActionEditLayout(request.form) if form.isValidated() == False: errors = '<br />'.join(form.getValidationError()) flash(errors, 'danger') return redirect(request.url.replace('/save', '')) data = form.getFormData() data['permission_id'] = permission.id action.fill(data).save() flash('Successfully deleted.', 'success') return redirect(url_for('admn.access.action.list'))
def delete(self, id): Permission.destroy(id) flash('Successfully deleted.', 'success') return redirect(url_for('admin.toolbox.access.permission.list'))
def Query(self, id = None): self.permission = Permission.first_or_new(id=id) return {'permission': self.permission}
def delete(self, id): Permission.destroy(id) return 'deleted'
def Query(self, **kwargs): permissions = Permission.order_by('sort', 'asc').get() return {'permission': permissions}