Class: Api::AggregatedController

Inherits:
ApiController
  • Object
show all
Includes:
ActionController::Serialization
Defined in:
app/controllers/api/aggregated_controller.rb

Overview

Main controller for handling submit and edit information

Instance Method Summary (collapse)

Instance Method Details

- (Object) create

Handles submitting information about a person with POST



38
39
40
41
42
43
44
45
46
# File 'app/controllers/api/aggregated_controller.rb', line 38

def create
  Rails.logger.info(params)
  @person = Information.submit_handling(params[:name], params[:position], params[:institution], params[:postdoc], params[:degree])
  if @person != nil && @person.save
    render json: {person: @person}
  else
    render json: {warning: "didnt work"}
  end
end

- (Object) destroy



61
62
63
# File 'app/controllers/api/aggregated_controller.rb', line 61

def destroy
	render json: {warning: 'not implemented'}, status: 200
end

- (Object) edit



33
34
35
# File 'app/controllers/api/aggregated_controller.rb', line 33

def edit
  render json: {warning: 'not implemented'}, status: 200
end

- (Object) index

Handles showing the degree and person name parameters with GET (Need to double-check this)



9
10
11
# File 'app/controllers/api/aggregated_controller.rb', line 9

def index
  render json: {degree: params[:degree], person_name: params[:name]}
end

- (Object) new



29
30
31
# File 'app/controllers/api/aggregated_controller.rb', line 29

def new
  render json: {warning: 'not implemented'}, status: 200
end

- (Object) notify_admin



65
66
67
# File 'app/controllers/api/aggregated_controller.rb', line 65

def notify_admin
  render json: {warning: 'not implemented'}, status: 200
end

- (Object) show

Note:

currently uses the search module to get the information

Retrives a person's information with GET to the frontend



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/api/aggregated_controller.rb', line 15

def show
  Rails.logger.info(params)
  if params.has_key?(:id) && params.has_key?(:approved)
    @person = Search.person(params[:id], params[:approved])
    render :json => @person.to_json
  elsif params.has_key?(:id)
    @person = Search.person(params[:id], nil)
    render :json => @person.to_json
  else
    render json: {warning: 'expected id param'}, status: 200
  end

end

- (Object) update

Handles updating a person's information with PUT Haven't tried this yet!!!



50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/api/aggregated_controller.rb', line 50

def update
  Rails.logger.info(params)
  Rails.logger.debug params.inspect
  @person = Information.update_handling(params[:id], params[:name], params[:position], params[:institution], params[:postdoc], params[:degree])
  if @person != nil && @person.save
    render json: {person: @person}
  else
    render json: {warning: "didnt work"}
  end
end