Sha256: 94f1ee9ee347a1bdb219109ecc1d1f46f5648eeeab67d536de7ea5f46fd64861

Contents?: true

Size: 1.11 KB

Versions: 10

Compression:

Stored size: 1.11 KB

Contents

class HomeController < ApplicationController
  def index
    @organization = current_organization
  end

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

    if organization && is_admin?(current_user, organization)
      old_sync_state = organization.sync_enabled

      organization.synchronized_entities.keys.each do |entity|
        organization.synchronized_entities[entity] = !!params["#{entity}"]
      end
      organization.sync_enabled = organization.synchronized_entities.values.any?
      organization.save

      if !old_sync_state
        Maestrano::Connector::Rails::SynchronizationJob.perform_later(organization, {})
        flash[:info] = 'Congrats, you\'re all set up! Your data are now being synced'
      end
    end

    redirect_to(:back)
  end

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

    redirect_to(:back)
  end

  def redirect_to_external
    redirect_to 'https://path/to/external/app'
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
maestrano-connector-rails-0.4.2 lib/generators/connector/templates/home_controller.rb
maestrano-connector-rails-0.4.1 lib/generators/connector/templates/home_controller.rb
maestrano-connector-rails-0.4.0 lib/generators/connector/templates/home_controller.rb
maestrano-connector-rails-0.3.13 lib/generators/connector/templates/home_controller.rb
maestrano-connector-rails-0.3.12 lib/generators/connector/templates/home_controller.rb
maestrano-connector-rails-0.3.11 lib/generators/connector/templates/home_controller.rb
maestrano-connector-rails-0.3.10 lib/generators/connector/templates/home_controller.rb
maestrano-connector-rails-0.3.9 lib/generators/connector/templates/home_controller.rb
maestrano-connector-rails-0.3.8 lib/generators/connector/templates/home_controller.rb
maestrano-connector-rails-0.3.7 lib/generators/connector/templates/home_controller.rb