Пример #1
0
 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}
Пример #2
0
    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'))
Пример #3
0
    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'))
Пример #4
0
 def delete(self, id):
     Permission.destroy(id)
     flash('Successfully deleted.', 'success')
     return redirect(url_for('admin.toolbox.access.permission.list'))
Пример #5
0
 def Query(self, id = None):
     self.permission = Permission.first_or_new(id=id)
     return {'permission': self.permission}
Пример #6
0
 def delete(self, id):
     Permission.destroy(id)
     return 'deleted'
Пример #7
0
 def Query(self, **kwargs):
     permissions = Permission.order_by('sort', 'asc').get()
     return {'permission': permissions}