Class: OrganizationsController

Inherits:
ApplicationController show all
Includes:
DataControllerConfiguration::SharedDataControllerConfiguration
Defined in:
app/controllers/organizations_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#is_data_controller, #is_task_controller, #meta_data, #meta_description, #meta_keywords, #meta_title, #page_title, #site_name

Instance Method Summary (collapse)

Methods included from DataControllerConfiguration::SharedDataControllerConfiguration

#set_is_shared_data_model

Methods inherited from ApplicationController

#digest_cookie, #digested_cookie_exists?, #disable_turbolinks, #invalid_object, #is_data_controller?, #is_task_controller?, #log_user_recent_route, #project_matches, #record_not_found, #set_project_from_params

Methods included from Whitelist

#whitelist_constantize

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Methods included from InterceptApi

#intercept_api, #token_authenticate

Instance Method Details

- (Object) autocomplete

Meh- term/query_string needs unification



75
76
77
# File 'app/controllers/organizations_controller.rb', line 75

def autocomplete
  @organizations = Queries::Organization::Autocomplete.new(params.require(:term)).autocomplete
end

- (Object) create

POST /organizations POST /organizations.json



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/organizations_controller.rb', line 36

def create
  @organization = Organization.new(organization_params)

  respond_to do |format|
    if @organization.save
      format.html { redirect_to @organization, notice: 'Organization was successfully created.' }
      format.json { render :show, status: :created, location: @organization }
    else
      format.html { render :new }
      format.json { render json: @organization.errors, status: :unprocessable_entity }
    end
  end
end

- (Object) destroy

DELETE /organizations/1 DELETE /organizations/1.json



66
67
68
69
70
71
72
# File 'app/controllers/organizations_controller.rb', line 66

def destroy
  @organization.destroy
  respond_to do |format|
    format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }
    format.json { head :no_content }
  end
end

- (Object) edit

GET /organizations/1/edit



31
32
# File 'app/controllers/organizations_controller.rb', line 31

def edit
end

- (Object) index

GET /organizations GET /organizations.json



8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/organizations_controller.rb', line 8

def index
  respond_to do |format|
    format.html do
      @recent_objects = Organization.created_this_week.order(updated_at: :desc).limit(10)
      render '/shared/data/all/index'
    end
    format.json {
      # @organizations = Queries::Organization::Filter.new(filter_params).all.with_project_id(sessions_current_project_id)
    }
  end
end

- (Object) list



79
80
81
# File 'app/controllers/organizations_controller.rb', line 79

def list
  @organizations = Organization.page(params[:page])
end

- (Object) new

GET /organizations/new



26
27
28
# File 'app/controllers/organizations_controller.rb', line 26

def new
  @organization = Organization.new
end

- (Object) organization_params (private)



89
90
91
92
93
94
95
# File 'app/controllers/organizations_controller.rb', line 89

def organization_params
  params.require(:organization).permit(
    :name, :alternate_name, :description, :disambiguating_description,
    :same_as_id, :address, :email, :telephone, :duns, :global_location_number,
    :legal_name, :area_served_id, :department_id, :parent_organization_id
  )
end

- (Object) set_organization (private)



85
86
87
# File 'app/controllers/organizations_controller.rb', line 85

def set_organization
  @organization = Organization.find(params[:id])
end

- (Object) show

GET /organizations/1 GET /organizations/1.json



22
23
# File 'app/controllers/organizations_controller.rb', line 22

def show
end

- (Object) update

PATCH/PUT /organizations/1 PATCH/PUT /organizations/1.json



52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/organizations_controller.rb', line 52

def update
  respond_to do |format|
    if @organization.update(organization_params)
      format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }
      format.json { render :show, status: :ok, location: @organization }
    else
      format.html { render :edit }
      format.json { render json: @organization.errors, status: :unprocessable_entity }
    end
  end
end