Class: Dscf::Credit::InformationSourcesController

Inherits:
ApplicationController
  • Object
show all
Includes:
Dscf::Core::AuditableController, Dscf::Core::Common, Dscf::Core::ReviewableController
Defined in:
app/controllers/dscf/credit/information_sources_controller.rb

Instance Method Summary collapse

Instance Method Details

#activateObject



37
38
39
40
41
42
43
# File 'app/controllers/dscf/credit/information_sources_controller.rb', line 37

def activate
  if @obj.update(active: true)
    render_success(data: @obj)
  else
    render_error(errors: @obj.errors.full_messages, status: :unprocessable_entity)
  end
end

#createObject



18
19
20
21
22
23
24
25
# File 'app/controllers/dscf/credit/information_sources_controller.rb', line 18

def create
  super do
    information_source = @clazz.new(model_params)
    information_source.created_by = current_user
    information_source.reviews.build(context: "default", status: "draft")
    information_source
  end
end

#deactivateObject



45
46
47
48
49
50
51
# File 'app/controllers/dscf/credit/information_sources_controller.rb', line 45

def deactivate
  if @obj.update(active: false)
    render_success(data: @obj)
  else
    render_error(errors: @obj.errors.full_messages, status: :unprocessable_entity)
  end
end

#updateObject



27
28
29
30
31
32
33
34
35
# File 'app/controllers/dscf/credit/information_sources_controller.rb', line 27

def update
  unless @obj.editable?
    return render_error(
      errors: [ "Cannot update information source after submission. Use modification request workflow instead." ],
      status: :unprocessable_entity
    )
  end
  super
end