Class: Tr8n::Admin::TranslatorController
- Inherits:
-
BaseController
- Object
- BaseController
- Tr8n::Admin::TranslatorController
- Defined in:
- app/controllers/tr8n/admin/translator_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
- #block ⇒ Object
- #delete ⇒ Object
- #demote ⇒ Object
- #following ⇒ Object
- #index ⇒ Object
- #ip_locations ⇒ Object
- #lb_register ⇒ Object
- #log ⇒ Object
- #metrics ⇒ Object
- #register ⇒ Object
- #reports ⇒ Object
- #unblock ⇒ Object
- #update_level ⇒ Object
- #update_stats ⇒ Object
- #view ⇒ Object
Instance Method Details
#block ⇒ Object
46 47 48 49 50 |
# File 'app/controllers/tr8n/admin/translator_controller.rb', line 46 def block @translator = Tr8n::Translator.find(params[:translator_id]) @translator.block!(tr8n_current_user, params[:reason]) redirect_to_source end |
#delete ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/tr8n/admin/translator_controller.rb', line 35 def delete params[:translators] = [params[:translator_id]] if params[:translator_id] if params[:translators] params[:translators].each do |translator_id| translator = Tr8n::Translator.find_by_id(translator_id) translator.destroy if translator end end redirect_to_source end |
#demote ⇒ Object
64 65 66 67 68 |
# File 'app/controllers/tr8n/admin/translator_controller.rb', line 64 def demote @translator = Tr8n::Translator.find(params[:translator_id]) @translator.demote!(tr8n_current_user, params[:reason]) redirect_to_source end |
#following ⇒ Object
99 100 101 |
# File 'app/controllers/tr8n/admin/translator_controller.rb', line 99 def following @following = Tr8n::TranslatorFollowing.filter(:params => params, :filter => Tr8n::TranslatorFollowingFilter) end |
#index ⇒ Object
26 27 28 |
# File 'app/controllers/tr8n/admin/translator_controller.rb', line 26 def index @translators = Tr8n::Translator.filter(:params => params, :filter => Tr8n::TranslatorFilter) end |
#ip_locations ⇒ Object
115 116 117 |
# File 'app/controllers/tr8n/admin/translator_controller.rb', line 115 def ip_locations @ip_locations = Tr8n::IpLocation.filter(:params => params, :filter => Tr8n::IpLocationFilter) end |
#lb_register ⇒ Object
78 79 80 81 |
# File 'app/controllers/tr8n/admin/translator_controller.rb', line 78 def lb_register @translator = Tr8n::Translator.new render :layout => false end |
#log ⇒ Object
107 108 109 |
# File 'app/controllers/tr8n/admin/translator_controller.rb', line 107 def log @logs = Tr8n::TranslatorLog.filter(:params => params, :filter => Tr8n::TranslatorLogFilter) end |
#metrics ⇒ Object
111 112 113 |
# File 'app/controllers/tr8n/admin/translator_controller.rb', line 111 def metrics @metrics = Tr8n::TranslatorMetric.filter(:params => params, :filter => Tr8n::TranslatorMetricFilter) end |
#register ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/controllers/tr8n/admin/translator_controller.rb', line 83 def register user_class = Tr8n::Config.site_info[:user_info][:class_name] user = user_class.constantize.find_by_id(params[:translator][:user_id]) unless user return redirect_to_source end translator = Tr8n::Translator.find_by_user_id(user.id) if translator return redirect_to_source end Tr8n::Translator.create(:user_id => params[:translator][:user_id]) redirect_to_source end |
#reports ⇒ Object
103 104 105 |
# File 'app/controllers/tr8n/admin/translator_controller.rb', line 103 def reports @reports = Tr8n::TranslatorReport.filter(:params => params, :filter => Tr8n::TranslatorReportFilter) end |
#unblock ⇒ Object
52 53 54 55 56 |
# File 'app/controllers/tr8n/admin/translator_controller.rb', line 52 def unblock @translator = Tr8n::Translator.find(params[:translator_id]) @translator.unblock!(tr8n_current_user, params[:reason]) redirect_to_source end |
#update_level ⇒ Object
58 59 60 61 62 |
# File 'app/controllers/tr8n/admin/translator_controller.rb', line 58 def update_level @translator = Tr8n::Translator.find(params[:translator_id]) @translator.update_level!(tr8n_current_user, params[:new_level], params[:reason]) redirect_to_source end |
#update_stats ⇒ Object
70 71 72 73 74 75 76 |
# File 'app/controllers/tr8n/admin/translator_controller.rb', line 70 def update_stats Tr8n::Translator.all.each do |trans| trans.update_total_metrics! end redirect_to :action => :index end |
#view ⇒ Object
30 31 32 33 |
# File 'app/controllers/tr8n/admin/translator_controller.rb', line 30 def view @translator = Tr8n::Translator.find(params[:translator_id]) redirect_to(:action => :index) unless @translator end |