Sha256: 65a8461445eb536740b77b57012b92609d83baadb860f77edee636e382a88b16

Contents?: true

Size: 1.45 KB

Versions: 56

Compression:

Stored size: 1.45 KB

Contents

# TODO
# This controller is given as an example of a possible admin implementation
# The admin functions should be restricted to admin users
# Admin funcitons :
#  * Link account to external application
#  * Disconnect account from external application
#  * Launch a manual syncrhonization for all entities or a sub-part of them
#  * Chose which entities are synchronized by the connector
#  * Access a list of the organization's idmaps
class AdminController < ApplicationController

  def index
    if is_admin
      @organization = current_organization
      @idmaps = Maestrano::Connector::Rails::IdMap.where(organization_id: @organization.id).order(:connec_entity)
    end
  end

  def update
    organization = Maestrano::Connector::Rails::Organization.find_by_id(params[:id])

    if organization && is_admin?(current_user, organization)
      organization.synchronized_entities.keys.each do |entity|
        if !!params["#{entity}"]
          organization.synchronized_entities[entity] = true
        else
          organization.synchronized_entities[entity] = false
        end
      end
      organization.save
    end

    redirect_to admin_index_path
  end

  def synchronize
    if is_admin
      Maestrano::Connector::Rails::SynchronizationJob.perform_later(current_organization, params['opts'] || {})
    end

    redirect_to root_path
  end

  private
    def is_admin
      current_user && current_organization && is_admin?(current_user, current_organization)
    end
end

Version data entries

56 entries across 55 versions & 1 rubygems

Version Path
maestrano-connector-rails-1.3.4 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-1.3.3 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-1.3.2 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-1.3.1 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-1.3.0 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-1.2.3 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-1.2.2 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-1.2.1 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-1.2.0 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-1.1.2 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-1.1.1 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-1.1.0 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-1.0.4 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-1.0.3 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-1.0.2 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-1.0.1 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-1.0.0 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-0.4.4 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-0.4.3 spec/dummy/app/controllers/admin_controller.rb
maestrano-connector-rails-0.4.2 spec/dummy/app/controllers/admin_controller.rb