diff --git a/app/controllers/admin/education/programs/roles_controller.rb b/app/controllers/admin/education/programs/roles_controller.rb index ea509c432ad3fa0fa579f5747aaa70684b9ffd04..fa6a9d1228b5bf2510798764e4609a34f127575d 100644 --- a/app/controllers/admin/education/programs/roles_controller.rb +++ b/app/controllers/admin/education/programs/roles_controller.rb @@ -70,6 +70,10 @@ class Admin::Education::Programs::RolesController < Admin::Education::Programs:: end def load_administration_people - @administration_people = current_university.people.for_language_id(current_university.default_language_id).administration.accessible_by(current_ability).ordered + @administration_people = current_university.people + .for_language_id(current_university.default_language_id) + .administration + .accessible_by(current_ability) + .ordered end end diff --git a/app/controllers/admin/university/people/translations_controller.rb b/app/controllers/admin/university/people/translations_controller.rb deleted file mode 100644 index c400e90279a9539b152f8eeea07deefaa35322bb..0000000000000000000000000000000000000000 --- a/app/controllers/admin/university/people/translations_controller.rb +++ /dev/null @@ -1,18 +0,0 @@ -class Admin::University::People::TranslationsController < Admin::University::ApplicationController - load_and_authorize_resource :person, - class: University::Person, - id_param: :person_id, - through: :current_university, - through_association: :people, - parent: false - - def show - language = Language.find_by!(iso_code: params[:lang]) - # Early return if language is correct - return [:admin, @person] if @person.language_id == language.id - # Look up for translation or translate (with blocks and all) from person - translation = @person.find_or_translate!(language) - # Redirect to the translation - redirect_to [:admin, translation.becomes(translation.class.base_class)] - end -end diff --git a/app/controllers/admin/university/people_controller.rb b/app/controllers/admin/university/people_controller.rb index 8b9fbd1ffbbfcd04c6471ba5a78654ae87f06a55..3f1bd19587acd7712c74c12175acc10c0206ddcb 100644 --- a/app/controllers/admin/university/people_controller.rb +++ b/app/controllers/admin/university/people_controller.rb @@ -18,6 +18,12 @@ class Admin::University::PeopleController < Admin::University::ApplicationContro breadcrumb end + def in_language + language = Language.find_by!(iso_code: params[:lang]) + translation = @person.find_or_translate!(language) + redirect_to [:admin, translation.becomes(translation.class.base_class)] + end + def static @about = @person @website = @person.websites&.first diff --git a/app/models/communication/website/with_program_categories.rb b/app/models/communication/website/with_program_categories.rb index 2c56713fca41b2bb26edc31455a22501b23764d8..a2f9bd468a7298aad76962dd2c746e32946ec5b4 100644 --- a/app/models/communication/website/with_program_categories.rb +++ b/app/models/communication/website/with_program_categories.rb @@ -6,6 +6,7 @@ module Communication::Website::WithProgramCategories end # TODO : I18n + # Actuellement, on ne crée que dans la langue par défaut du website, on ne gère pas les autres langues def set_programs_categories! programs_root_category = categories.for_language_id(default_language_id).where(is_programs_root: true).first_or_create( name: 'Offre de formation', diff --git a/app/views/admin/application/i18n/_widget.html.erb b/app/views/admin/application/i18n/_widget.html.erb index 9b646599fbf566bb297b8629fcfd275cf2b06b53..716cb26bd4dec9596b66ebe2b08cae08a2833487 100644 --- a/app/views/admin/application/i18n/_widget.html.erb +++ b/app/views/admin/application/i18n/_widget.html.erb @@ -1,7 +1,7 @@ <% if about.available_languages.many? %> <% route_args = about.respond_to?(:website) ? [:admin, about.becomes(about.class.base_class)] - : [:admin, about.becomes(about.class.base_class), :translation] + : [:show_in_language, :admin, about.becomes(about.class.base_class)] %> <%= osuny_panel t('internationalization.label') do %> <ol class="list-unstyled"> diff --git a/config/routes/admin/university.rb b/config/routes/admin/university.rb index 8f397cc6f677880e1c8fe2f825dc48f6c2152455..5da1efdf42f07b3679cd5b7331f9e13b7f0c4bff 100644 --- a/config/routes/admin/university.rb +++ b/config/routes/admin/university.rb @@ -20,9 +20,9 @@ namespace :university do end end resources :people do - resources :translations, only: :show, param: :lang, controller: "people/translations" member do get :static + get "/translations/:lang" => "people#in_language", as: :show_in_language end end resources :organizations do