Class: Tr8n::Admin::LanguageController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/tr8n/admin/language_controller.rb

Overview

– Copyright © 2010-2011 Michael Berkovich, tr8n.net

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++

Instance Method Summary collapse

Instance Method Details

#calculate_metricsObject



68
69
70
71
# File 'app/controllers/tr8n/admin/language_controller.rb', line 68

def calculate_metrics
  Tr8n::LanguageMetric.calculate_language_metrics
  redirect_to_source
end

#calculate_total_metricsObject



73
74
75
76
# File 'app/controllers/tr8n/admin/language_controller.rb', line 73

def calculate_total_metrics
  Tr8n::LanguageMetric.calculate_total_metrics
  redirect_to_source
end

#case_rulesObject



106
107
108
# File 'app/controllers/tr8n/admin/language_controller.rb', line 106

def case_rules
  @case_rules = Tr8n::LanguageCaseRule.filter(:params => params, :filter => Tr8n::LanguageCaseRuleFilter)
end

#case_valuesObject



110
111
112
# File 'app/controllers/tr8n/admin/language_controller.rb', line 110

def case_values
  @case_values = Tr8n::LanguageCaseValueMap.filter(:params => params, :filter => Tr8n::LanguageCaseValueMapFilter)
end

#casesObject



82
83
84
# File 'app/controllers/tr8n/admin/language_controller.rb', line 82

def cases
  @cases = Tr8n::LanguageCase.filter(:params => params, :filter => Tr8n::LanguageCaseFilter)
end

#chartsObject



56
57
58
# File 'app/controllers/tr8n/admin/language_controller.rb', line 56

def charts
  
end

#delete_value_mapObject



121
122
123
124
125
126
# File 'app/controllers/tr8n/admin/language_controller.rb', line 121

def delete_value_map
  map = Tr8n::LanguageCaseValueMap.find_by_id(params[:map_id]) if params[:map_id]
  map.destroy if map

  redirect_to(:action => :index)
end

#disableObject



45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/tr8n/admin/language_controller.rb', line 45

def disable
  params[:languages] = [params[:lang_id]] if params[:lang_id]
  if params[:languages]
    params[:languages].each do |lang_id|
      language = Tr8n::Language.find_by_id(lang_id)
      language.disable! if language
    end  
  end
  redirect_to_source
end

#enableObject



34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/tr8n/admin/language_controller.rb', line 34

def enable
  params[:languages] = [params[:lang_id]] if params[:lang_id]
  if params[:languages]
    params[:languages].each do |lang_id|
      language = Tr8n::Language.find_by_id(lang_id)
      language.enable! if language
    end  
  end
  redirect_to_source
end

#indexObject



26
27
28
# File 'app/controllers/tr8n/admin/language_controller.rb', line 26

def index
  @languages = Tr8n::Language.filter(:params => params, :filter => Tr8n::LanguageFilter)
end

#lb_updateObject



86
87
88
89
90
91
# File 'app/controllers/tr8n/admin/language_controller.rb', line 86

def lb_update
  @language = Tr8n::Language.find_by_id(params[:lang_id]) unless params[:lang_id].blank?
  @language = Tr8n::Language.new unless @language
  
  render :layout => false
end

#lb_value_mapObject



114
115
116
117
118
119
# File 'app/controllers/tr8n/admin/language_controller.rb', line 114

def lb_value_map
  @map = Tr8n::LanguageCaseValueMap.find_by_id(params[:map_id]) if params[:map_id]
  @map ||= Tr8n::LanguageCaseValueMap.new(:language => tr8n_current_language)
  
  render :layout => false
end

#metricsObject



60
61
62
# File 'app/controllers/tr8n/admin/language_controller.rb', line 60

def metrics
  @metrics = Tr8n::LanguageMetric.filter(:params => params, :filter => Tr8n::LanguageMetricFilter)
end

#rulesObject



78
79
80
# File 'app/controllers/tr8n/admin/language_controller.rb', line 78

def rules
  @rules = Tr8n::LanguageRule.filter(:params => params, :filter => Tr8n::LanguageRuleFilter)
end

#updateObject



93
94
95
96
97
98
99
100
101
102
103
104
# File 'app/controllers/tr8n/admin/language_controller.rb', line 93

def update
  language = Tr8n::Language.find_by_id(params[:language][:id]) unless params[:language][:id].blank?
  
  if language
    language.update_attributes(params[:language])
  else
    language = Tr8n::Language.create(params[:language])
    language.reset!
  end
  
  redirect_to_source
end

#usersObject



64
65
66
# File 'app/controllers/tr8n/admin/language_controller.rb', line 64

def users
  @users = Tr8n::LanguageUser.filter(:params => params, :filter => Tr8n::LanguageUserFilter)
end

#viewObject



30
31
32
# File 'app/controllers/tr8n/admin/language_controller.rb', line 30

def view
  @lang = Tr8n::Language.find(params[:lang_id])
end