Class: TranslationCenter::CenterController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- TranslationCenter::CenterController
- Defined in:
- app/controllers/translation_center/center_controller.rb
Instance Method Summary collapse
- #center_params ⇒ Object
- #dashboard ⇒ Object
- #manage ⇒ Object
- #search_activity ⇒ Object
-
#set_language_from ⇒ Object
set language user translating from.
-
#set_language_to ⇒ Object
set language user translating to.
- #update_language ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#center_params ⇒ Object
62 63 64 |
# File 'app/controllers/translation_center/center_controller.rb', line 62 def center_params params.permit! end |
#dashboard ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/translation_center/center_controller.rb', line 26 def dashboard @stats = TranslationKey.langs_stats @langs = @stats.keys # build an empty activity query @activity_query = ActivityQuery.new(center_params[:activity_query]) #TODO perpage constant should be put somewhere else @translations_changes = @activity_query.activities.offset(Translation::CHANGES_PER_PAGE * (@page - 1)).limit(Translation::CHANGES_PER_PAGE) @total_pages = (@activity_query.activities.count / (Translation::CHANGES_PER_PAGE * 1.0)).ceil respond_to do |format| format.html format.js { render 'search_activity' } end end |
#manage ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/translation_center/center_controller.rb', line 52 def manage # if locale is all then send no locale locale = center_params[:locale] == 'all' ? nil : center_params[:locale] TranslationCenter.send center_params[:manage_action], locale respond_to do |format| format.js end end |
#search_activity ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'app/controllers/translation_center/center_controller.rb', line 43 def search_activity @translations_changes = ActivityQuery.new(center_params[:activity_query]).activities.offset(Translation::CHANGES_PER_PAGE * (@page - 1)).limit(Translation::CHANGES_PER_PAGE) @total_pages = (ActivityQuery.new(center_params[:activity_query]).activities.count / (Translation::CHANGES_PER_PAGE * 1.0)).ceil respond_to do |format| format.js end end |
#set_language_from ⇒ Object
set language user translating from
10 11 12 13 14 |
# File 'app/controllers/translation_center/center_controller.rb', line 10 def set_language_from session[:lang_from] = center_params[:lang].to_sym I18n.locale = session[:lang_from] render nothing: true end |
#set_language_to ⇒ Object
set language user translating to
17 18 19 20 21 22 23 24 |
# File 'app/controllers/translation_center/center_controller.rb', line 17 def set_language_to session[:lang_to] = center_params[:lang].to_sym respond_to do |format| format.html { redirect_to root_url } format.js { render nothing: true } end end |
#update_language ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'app/controllers/translation_center/center_controller.rb', line 66 def update_language begin TranslationCenter.db2yaml(params[:lang]) flash[:success] = "Language #{params[:lang]} updated" rescue Exception => e flash[:warning] = "Language #{params[:lang]} could not be updated. Reason: #{e}" end redirect_to dashboard_path end |