Sha256: db2795b5cb0b0c42ff6a8e84a93c3905aff3bff30deb2243ff36076c88a27bf5

Contents?: true

Size: 944 Bytes

Versions: 54

Compression:

Stored size: 944 Bytes

Contents

module Faalis
  module API
    class GroupsAPI < Grape::API

      resource :groups do

        desc "Return all the groups"
        get do
          authenticated_user
          # TODO: Check for admin user only
          Faalis::Group.includes(:permissions)
        end

        delete do
          authenticated_user

          #if can? :delete, Group
          #end
          Group.delete(params[:id].split(","))
        end

        post do
          authenticated_user

          permissions = [];

          params[:permissions].each do |perm_string|
            perm, model = perm_string.split "|"
            permission = Permission.find_or_create_by_model_and_permission_type(model, perm)
            permissions << permission
          end

          Group.create!({
                          name: params[:name],
                          permissions: permissions,
                        })
        end
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
faalis-2.2.0.pre.rc1 lib/faalis/api/groups_api.rb
faalis-2.2.1 lib/faalis/api/groups_api.rb
faalis-2.2.0 lib/faalis/api/groups_api.rb
faalis-2.1.1 lib/faalis/api/groups_api.rb
faalis-2.1.0 lib/faalis/api/groups_api.rb
faalis-2.0.8 lib/faalis/api/groups_api.rb
faalis-2.0.7 lib/faalis/api/groups_api.rb
faalis-2.0.5 lib/faalis/api/groups_api.rb
faalis-2.0.4 lib/faalis/api/groups_api.rb
faalis-2.0.3 lib/faalis/api/groups_api.rb
faalis-2.0.1 lib/faalis/api/groups_api.rb
faalis-2.0.0 lib/faalis/api/groups_api.rb
faalis-2.0.0.rc6 lib/faalis/api/groups_api.rb
faalis-2.0.0.rc5 lib/faalis/api/groups_api.rb
faalis-2.0.0.rc4 lib/faalis/api/groups_api.rb
faalis-2.0.0.rc3 lib/faalis/api/groups_api.rb
faalis-2.0.0.rc2 lib/faalis/api/groups_api.rb
faalis-1.0.0 lib/faalis/api/groups_api.rb
faalis-1.0.0.alpha4 lib/faalis/api/groups_api.rb
faalis-1.0.0.alpha3 lib/faalis/api/groups_api.rb