Class: AssessmentAttributesController

Inherits:
ApplicationController show all
Defined in:
frontend/app/controllers/assessment_attributes_controller.rb

Constant Summary

Constants included from Searchable

Searchable::ABSTRACT

Instance Method Summary collapse

Methods inherited from ApplicationController

#archivesspace, can_access?, permission_mappings, set_access_control

Methods included from JsonHelper

#merge_notes, #process_json_notes

Methods included from Searchable

#default_search_opts, #get_filter_years, #handle_results, #html_notes, #process_results, #process_search_results, #repo_context, #search_terms, #set_up_advanced_search, #set_up_and_run_search, #set_up_search, #strip_facet_fields

Methods included from HandleFaceting

#fetch_only_facets, #get_pretty_facet_value, #strip_facets

Methods included from ManipulateNode

#inheritance, #process_mixed_content, #strip_mixed_content

Instance Method Details

#current_recordObject



10
11
12
# File 'frontend/app/controllers/assessment_attributes_controller.rb', line 10

def current_record
  @assessment_attribute_definitions
end

#editObject



6
7
8
# File 'frontend/app/controllers/assessment_attributes_controller.rb', line 6

def edit
  @assessment_attribute_definitions = AssessmentAttributeDefinitions.find(nil)
end

#updateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'frontend/app/controllers/assessment_attributes_controller.rb', line 14

def update
  @assessment_attribute_definitions = AssessmentAttributeDefinitions.find(nil)

  original_repo_formats = @assessment_attribute_definitions.repo_formats
  original_repo_ratings = @assessment_attribute_definitions.repo_ratings
  original_repo_conservation_issues = @assessment_attribute_definitions.repo_conservation_issues

  @assessment_attribute_definitions.repo_formats = prepare(params[:formats])
  @assessment_attribute_definitions.repo_ratings = prepare(params[:ratings])
  @assessment_attribute_definitions.repo_conservation_issues = prepare(params[:conservation_issues])

  begin
    @assessment_attribute_definitions.save
    @assessment_attribute_definitions = AssessmentAttributeDefinitions.find(nil)
    flash.now[:success] = I18n.t('assessment_attribute_definitions._frontend.messages.updated')
  rescue ConflictException => e
    if "RECORD_IN_USE" == e.conflicts
      flash.now[:error] = I18n.t('assessment_attribute_definitions._frontend.messages.attribute_in_use')

      # Add back anything that was deleted
      @assessment_attribute_definitions.repo_formats = revert_deletions(@assessment_attribute_definitions.repo_formats, original_repo_formats)
      @assessment_attribute_definitions.repo_ratings = revert_deletions(@assessment_attribute_definitions.repo_ratings, original_repo_ratings)
      @assessment_attribute_definitions.repo_conservation_issues = revert_deletions(@assessment_attribute_definitions.repo_conservation_issues, original_repo_conservation_issues)
    else
      flash.now[:error] = I18n.t('assessment_attribute_definitions._frontend.messages.conflict',
                                 :conflicts => e.conflicts.join('; '))
    end
  end

  render :template => 'assessment_attributes/edit'
end