Class: OrganizationsController

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

Instance Method Summary collapse

Methods included from DataControllerConfiguration::SharedDataControllerConfiguration

#set_is_shared_data_model

Methods included from RequestType

#json_request?

Methods included from LogRecent

#log_user_recent_route

Methods included from Cookies

#digest_cookie, #digested_cookie_exists?

Methods included from Whitelist

#whitelist_constantize

Methods included from ProjectsHelper

#invalid_object, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form

Methods included from Api::Intercept

#intercept_api

Instance Method Details

#autocompleteObject

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

#createObject

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

#destroyObject

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

#editObject

GET /organizations/1/edit



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

def edit
end

#indexObject

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

#listObject



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

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

#newObject

GET /organizations/new



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

def new
  @organization = Organization.new
end

#organization_paramsObject (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

#set_organizationObject (private)



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

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

#showObject

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



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

def show
end

#updateObject

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