From 03e2ee0c8aba1af81f4aec5e1405bd7e25d57030 Mon Sep 17 00:00:00 2001 From: pabois <pierreandre.boissinot@noesya.coop> Date: Thu, 9 Mar 2023 14:39:14 +0100 Subject: [PATCH] move experiences to people --- .../experiences/imports_controller.rb | 18 ++--- .../experiences_controller.rb | 16 ++-- app/models/import.rb | 2 +- app/services/importers/alumni_cohorts.rb | 56 +------------- app/services/importers/hash_to_alumnus.rb | 13 ++++ app/services/importers/hash_to_cohort.rb | 55 ++++++++++++++ ...i_experiences.rb => hash_to_experience.rb} | 20 ----- .../{alumni.rb => hash_to_person.rb} | 75 ++++++++----------- app/services/importers/people_experiences.rb | 18 +++++ app/services/importers/person.rb | 13 ++++ .../meta_description/_form.html.erb | 4 +- .../admin/university/alumni/_list.html.erb | 2 - .../alumni/experiences/imports/index.html.erb | 12 --- .../admin/university/alumni/index.html.erb | 3 - .../admin/university/alumni/show.html.erb | 10 --- .../admin/university/people/_list.html.erb | 2 + .../experiences/_experience_fields.html.erb | 0 .../experiences/edit.html.erb | 12 +-- .../people/experiences/imports/index.html.erb | 12 +++ .../experiences/imports/new.html.erb | 4 +- .../admin/university/people/index.html.erb | 6 ++ .../admin/university/people/show.html.erb | 10 +++ config/locales/en.yml | 1 + config/locales/fr.yml | 3 +- config/locales/university/en.yml | 8 +- config/locales/university/fr.yml | 8 +- config/routes/admin/university.rb | 12 +-- 27 files changed, 209 insertions(+), 186 deletions(-) rename app/controllers/admin/university/{alumni => people}/experiences/imports_controller.rb (64%) rename app/controllers/admin/university/{alumni => people}/experiences_controller.rb (70%) create mode 100644 app/services/importers/hash_to_alumnus.rb create mode 100644 app/services/importers/hash_to_cohort.rb rename app/services/importers/{alumni_experiences.rb => hash_to_experience.rb} (82%) rename app/services/importers/{alumni.rb => hash_to_person.rb} (58%) create mode 100644 app/services/importers/people_experiences.rb create mode 100644 app/services/importers/person.rb delete mode 100644 app/views/admin/university/alumni/experiences/imports/index.html.erb rename app/views/admin/university/{alumni => people}/experiences/_experience_fields.html.erb (100%) rename app/views/admin/university/{alumni => people}/experiences/edit.html.erb (66%) create mode 100644 app/views/admin/university/people/experiences/imports/index.html.erb rename app/views/admin/university/{alumni => people}/experiences/imports/new.html.erb (96%) diff --git a/app/controllers/admin/university/alumni/experiences/imports_controller.rb b/app/controllers/admin/university/people/experiences/imports_controller.rb similarity index 64% rename from app/controllers/admin/university/alumni/experiences/imports_controller.rb rename to app/controllers/admin/university/people/experiences/imports_controller.rb index 538e9dd0d..663b26c9b 100644 --- a/app/controllers/admin/university/alumni/experiences/imports_controller.rb +++ b/app/controllers/admin/university/people/experiences/imports_controller.rb @@ -1,4 +1,4 @@ -class Admin::University::Alumni::Experiences::ImportsController < Admin::University::ApplicationController +class Admin::University::People::Experiences::ImportsController < Admin::University::ApplicationController load_and_authorize_resource class: Import, through: :current_university, through_association: :imports @@ -6,7 +6,7 @@ class Admin::University::Alumni::Experiences::ImportsController < Admin::Univers has_scope :for_status def index - @imports = apply_scopes(@imports.kind_alumni_experiences).ordered.page(params[:page]) + @imports = apply_scopes(@imports.kind_people_experiences).ordered.page(params[:page]) breadcrumb end @@ -20,11 +20,11 @@ class Admin::University::Alumni::Experiences::ImportsController < Admin::Univers end def create - @import.kind = :alumni_experiences + @import.kind = :people_experiences @import.university = current_university @import.user = current_user if @import.save - redirect_to admin_university_alumni_experiences_import_path(@import), + redirect_to admin_university_people_experiences_import_path(@import), notice: t('admin.successfully_created_html', model: @import.to_s) else breadcrumb @@ -36,12 +36,12 @@ class Admin::University::Alumni::Experiences::ImportsController < Admin::Univers def breadcrumb super - add_breadcrumb University::Person::Alumnus.model_name.human(count: 2), - admin_university_alumni_path - add_breadcrumb t('university.alumni.experiences.title'), - admin_university_alumni_experiences_imports_path + add_breadcrumb University::Person.model_name.human(count: 2), + admin_university_people_path + add_breadcrumb t('university.person.experiences.title'), + admin_university_people_experiences_imports_path return unless @import - @import.persisted? ? add_breadcrumb(@import, admin_university_alumni_experiences_import_path(@import)) + @import.persisted? ? add_breadcrumb(@import, admin_university_people_experiences_import_path(@import)) : add_breadcrumb(t('create')) end diff --git a/app/controllers/admin/university/alumni/experiences_controller.rb b/app/controllers/admin/university/people/experiences_controller.rb similarity index 70% rename from app/controllers/admin/university/alumni/experiences_controller.rb rename to app/controllers/admin/university/people/experiences_controller.rb index 527edb6e9..2fbdec31a 100644 --- a/app/controllers/admin/university/alumni/experiences_controller.rb +++ b/app/controllers/admin/university/people/experiences_controller.rb @@ -1,5 +1,5 @@ -class Admin::University::Alumni::ExperiencesController < Admin::University::ApplicationController - load_and_authorize_resource :alumnus, +class Admin::University::People::ExperiencesController < Admin::University::ApplicationController + load_and_authorize_resource :person, class: University::Person, through: :current_university, through_association: :people, @@ -9,9 +9,9 @@ class Admin::University::Alumni::ExperiencesController < Admin::University::Appl end def update - if @alumnus.update(experiences_params) - redirect_to admin_university_alumnus_path(@alumnus), - notice: t('admin.successfully_updated_html', model: @alumnus.to_s) + if @person.update(experiences_params) + redirect_to admin_university_person_path(@person), + notice: t('admin.successfully_updated_html', model: @person.to_s) else render :edit breadcrumb @@ -22,9 +22,9 @@ class Admin::University::Alumni::ExperiencesController < Admin::University::Appl def breadcrumb super - add_breadcrumb University::Person::Alumnus.model_name.human(count: 2), - admin_university_alumni_path - add_breadcrumb @alumnus, admin_university_alumnus_path(@alumnus) + add_breadcrumb University::Person.model_name.human(count: 2), + admin_university_people_path + add_breadcrumb @person, admin_university_person_path(@person) add_breadcrumb University::Person::Experience.model_name.human(count: 2) end diff --git a/app/models/import.rb b/app/models/import.rb index 0e7512b8c..d3ebfb313 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -29,7 +29,7 @@ class Import < ApplicationRecord has_one_attached_deletable :file - enum kind: { organizations: 0, alumni_cohorts: 1, alumni_experiences: 2 }, _prefix: :kind + enum kind: { organizations: 0, alumni_cohorts: 1, people_experiences: 2 }, _prefix: :kind enum status: { pending: 0, finished: 1, finished_with_errors: 2 } validate :file_validation diff --git a/app/services/importers/alumni_cohorts.rb b/app/services/importers/alumni_cohorts.rb index 2242b8d4e..a225ff769 100644 --- a/app/services/importers/alumni_cohorts.rb +++ b/app/services/importers/alumni_cohorts.rb @@ -1,5 +1,5 @@ module Importers - class AlumniCohorts < Importers::Alumni + class AlumniCohorts < Base protected @@ -16,58 +16,4 @@ module Importers end - class HashToCohort - def initialize(person, hash) - @university = person.university - @hash = hash - @error = nil - extract_variables - person.add_to_cohort cohort if valid? - end - - def valid? - if school.nil? - @error = "School #{@school_id} not found" - elsif program.nil? - @error = "Program #{@program_id} not found" - elsif academic_year.nil? - @error = "The year #{@year} seems incorrect" - elsif cohort.nil? - @error = "Unable to create the cohort" - end - @error.nil? - end - - def error - @error - end - - protected - - def extract_variables - @school_id = @hash[17].to_s.strip - @program_id = @hash[18].to_s.strip - @year = @hash[19].to_s.strip.to_i - end - - def school - @university.education_schools.find_by(id: @school_id) - end - - def program - @university.education_programs.find_by(id: @program_id) - end - - def academic_year - @academic_year ||= @university.academic_years.where(year: @year).first_or_create - end - - def cohort - @cohort ||= @university.education_cohorts - .where(school: school, program: program, academic_year: academic_year) - .first_or_create - end - - end - end diff --git a/app/services/importers/hash_to_alumnus.rb b/app/services/importers/hash_to_alumnus.rb new file mode 100644 index 000000000..bb032cfef --- /dev/null +++ b/app/services/importers/hash_to_alumnus.rb @@ -0,0 +1,13 @@ +module Importers + class HashToAlumnus < HashToPerson + + def person + @person ||= begin + person = build_person + person.is_alumnus = true + person + end + end + + end +end diff --git a/app/services/importers/hash_to_cohort.rb b/app/services/importers/hash_to_cohort.rb new file mode 100644 index 000000000..8cd20a98f --- /dev/null +++ b/app/services/importers/hash_to_cohort.rb @@ -0,0 +1,55 @@ +module Importers + class HashToCohort + def initialize(person, hash) + @university = person.university + @hash = hash + @error = nil + extract_variables + person.add_to_cohort cohort if valid? + end + + def valid? + if school.nil? + @error = "School #{@school_id} not found" + elsif program.nil? + @error = "Program #{@program_id} not found" + elsif academic_year.nil? + @error = "The year #{@year} seems incorrect" + elsif cohort.nil? + @error = "Unable to create the cohort" + end + @error.nil? + end + + def error + @error + end + + protected + + def extract_variables + @school_id = @hash[17].to_s.strip + @program_id = @hash[18].to_s.strip + @year = @hash[19].to_s.strip.to_i + end + + def school + @university.education_schools.find_by(id: @school_id) + end + + def program + @university.education_programs.find_by(id: @program_id) + end + + def academic_year + @academic_year ||= @university.academic_years.where(year: @year).first_or_create + end + + def cohort + @cohort ||= @university.education_cohorts + .where(school: school, program: program, academic_year: academic_year) + .first_or_create + end + + end +end diff --git a/app/services/importers/alumni_experiences.rb b/app/services/importers/hash_to_experience.rb similarity index 82% rename from app/services/importers/alumni_experiences.rb rename to app/services/importers/hash_to_experience.rb index 99b66bb63..8f6e88ffb 100644 --- a/app/services/importers/alumni_experiences.rb +++ b/app/services/importers/hash_to_experience.rb @@ -1,21 +1,4 @@ module Importers - class AlumniExperiences < Importers::Alumni - - protected - - def analyze_hash(hash, index) - hash_to_alumnus = HashToAlumnus.new(@university, hash) - if hash_to_alumnus.valid? - person = hash_to_alumnus.person - hash_to_experience = HashToExperience.new(person, hash) - add_error(hash_to_experience.error, index + 1) unless hash_to_experience.valid? - else - add_error(hash_to_alumnus.error, index + 1) - end - end - - end - class HashToExperience def initialize(person, hash) @person = person @@ -84,8 +67,5 @@ module Importers obj end end - - end - end diff --git a/app/services/importers/alumni.rb b/app/services/importers/hash_to_person.rb similarity index 58% rename from app/services/importers/alumni.rb rename to app/services/importers/hash_to_person.rb index a53962182..72003342e 100644 --- a/app/services/importers/alumni.rb +++ b/app/services/importers/hash_to_person.rb @@ -1,16 +1,5 @@ module Importers - class Alumni < Base - - protected - - def analyze_hash(hash, index) - hash_to_alumnus = HashToAlumnus.new(@university, hash) - add_error(hash_to_alumnus.error, index + 1) unless hash_to_alumnus.valid? - end - - end - - class HashToAlumnus + class HashToPerson def initialize(university, hash) @university = university @hash = hash @@ -36,36 +25,7 @@ module Importers end def person - @person ||= begin - if @email.present? - person = @university.people - .where(email: @email) - .first_or_initialize - elsif @first_name.present? && @last_name.present? - person = @university.people - .where(first_name: @first_name, last_name: @last_name) - .first_or_initialize - end - person.first_name = @first_name - person.last_name = @last_name - person.gender = gender - person.birthdate = @birth - person.email = @email - person.url = @url - person.phone_professional = @phone_professional - person.phone_personal = @phone_personal - person.phone_mobile = @mobile - person.address = @address - person.zipcode = @zipcode - person.city = @city - person.country = @country - person.biography = @biography - person.twitter = @social_twitter - person.linkedin = @social_linkedin - person.is_alumnus = true - person.slug = person.to_s.parameterize.dasherize - person - end + @person ||= build_person end protected @@ -90,6 +50,37 @@ module Importers @social_linkedin = @hash[16].to_s.strip end + def build_person + if @email.present? + person = @university.people + .where(email: @email) + .first_or_initialize + elsif @first_name.present? && @last_name.present? + person = @university.people + .where(first_name: @first_name, last_name: @last_name) + .first_or_initialize + end + person.first_name = @first_name + person.last_name = @last_name + person.gender = gender + person.birthdate = @birth + person.email = @email + person.url = @url + person.phone_professional = @phone_professional + person.phone_personal = @phone_personal + person.phone_mobile = @mobile + person.address = @address + person.zipcode = @zipcode + person.city = @city + person.country = @country + person.biography = @biography + person.twitter = @social_twitter + person.linkedin = @social_linkedin + person.slug = person.to_s.parameterize.dasherize + person.language_id = @university.default_language_id + person + end + def country_not_found? ISO3166::Country[@country].nil? end diff --git a/app/services/importers/people_experiences.rb b/app/services/importers/people_experiences.rb new file mode 100644 index 000000000..9e54d1473 --- /dev/null +++ b/app/services/importers/people_experiences.rb @@ -0,0 +1,18 @@ +module Importers + class PeopleExperiences < Base + + protected + + def analyze_hash(hash, index) + hash_to_person = HashToPerson.new(@university, hash) + if hash_to_person.valid? + person = hash_to_person.person + hash_to_experience = HashToExperience.new(person, hash) + add_error(hash_to_experience.error, index + 1) unless hash_to_experience.valid? + else + add_error(hash_to_person.error, index + 1) + end + end + + end +end diff --git a/app/services/importers/person.rb b/app/services/importers/person.rb new file mode 100644 index 000000000..90c3827b4 --- /dev/null +++ b/app/services/importers/person.rb @@ -0,0 +1,13 @@ +module Importers + class Person < Base + + protected + + def analyze_hash(hash, index) + hash_to_person = HashToPerson.new(@university, hash) + add_error(hash_to_person.error, index + 1) unless hash_to_person.valid? + end + + end + +end diff --git a/app/views/admin/application/meta_description/_form.html.erb b/app/views/admin/application/meta_description/_form.html.erb index cc698e030..0deb74c7d 100644 --- a/app/views/admin/application/meta_description/_form.html.erb +++ b/app/views/admin/application/meta_description/_form.html.erb @@ -1,8 +1,8 @@ -<%= osuny_panel t('admin.summary') do %> +<%= osuny_panel t('admin.seo') do %> <%= f.input :meta_description, label: t('admin.meta_description.label'), hint: t('admin.meta_description.hint'), input_html: { value: about.meta_description&.gsub('&', '&') } %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/admin/university/alumni/_list.html.erb b/app/views/admin/university/alumni/_list.html.erb index 9d171e73e..f0e1db78b 100644 --- a/app/views/admin/university/alumni/_list.html.erb +++ b/app/views/admin/university/alumni/_list.html.erb @@ -5,7 +5,6 @@ <th><%= University::Person.human_attribute_name('last_name') %></th> <th><%= University::Person.human_attribute_name('first_name') %></th> <th><%= Education::Cohort.model_name.human(count: 2) %></th> - <th><%= University::Person::Experience.model_name.human(count: 2) %></th> <th></th> </tr> </thead> @@ -16,7 +15,6 @@ <td><%= link_to_if can?(:read, alumnus), alumnus.last_name, path %></td> <td><%= link_to_if can?(:read, alumnus), alumnus.first_name, path %></td> <td><%= link_to_if can?(:update, alumnus), alumnus.cohorts.size, cohorts_admin_university_alumnus_path(alumnus) %></td> - <td><%= link_to_if can?(:update, alumnus), alumnus.experiences.size, experiences_admin_university_alumnus_path(alumnus) %></td> <td><%= kamifusen_tag alumnus.best_picture, width: 80 if alumnus.best_picture.attached? %></td> </tr> <% end %> diff --git a/app/views/admin/university/alumni/experiences/imports/index.html.erb b/app/views/admin/university/alumni/experiences/imports/index.html.erb deleted file mode 100644 index 58402622c..000000000 --- a/app/views/admin/university/alumni/experiences/imports/index.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -<% content_for :title, t('university.alumni.experiences.title') %> - -<%= render 'filters', current_path: admin_university_alumni_experiences_imports_path, filters: @filters if @filters.any? %> - -<%= render 'admin/imports/list', imports: @imports, path_pattern: 'admin_university_alumni_experiences_import_path' %> - -<% content_for :action_bar_right do %> - <%= link_to_if can?(:create, University::Person::Alumnus), - t('create'), - new_admin_university_alumni_experiences_import_path, - class: button_classes %> -<% end %> diff --git a/app/views/admin/university/alumni/index.html.erb b/app/views/admin/university/alumni/index.html.erb index c6a436b4c..ca8c4e7a7 100644 --- a/app/views/admin/university/alumni/index.html.erb +++ b/app/views/admin/university/alumni/index.html.erb @@ -10,9 +10,6 @@ <%= link_to t('university.alumni.cohorts.import_btn'), new_admin_university_alumni_cohorts_import_path, class: button_classes if can? :create, University::Person::Alumnus %> - <%= link_to t('university.alumni.experiences.import_btn'), - new_admin_university_alumni_experiences_import_path, - class: button_classes if can? :create, University::Person::Alumnus %> <% end %> <% content_for :action_bar_right do %> diff --git a/app/views/admin/university/alumni/show.html.erb b/app/views/admin/university/alumni/show.html.erb index d5723d063..c3bc95732 100644 --- a/app/views/admin/university/alumni/show.html.erb +++ b/app/views/admin/university/alumni/show.html.erb @@ -12,16 +12,6 @@ action += link_to t('university.manage_cohorts'), <%= render 'admin/education/cohorts/list', cohorts: @alumnus.cohorts.ordered %> <% end %> -<% -action = '' -action += link_to t('university.manage_experiences'), - experiences_admin_university_alumnus_path(@alumnus), - class: button_classes if can?(:update, @alumnus) -%> -<%= osuny_panel University::Person::Experience.model_name.human(count: 2), action: action do %> - <%= render 'admin/university/people/experiences/list', experiences: @alumnus.experiences.ordered %> -<% end %> - <% content_for :action_bar_right do %> <%= edit_link @alumnus %> <% end %> diff --git a/app/views/admin/university/people/_list.html.erb b/app/views/admin/university/people/_list.html.erb index f2bd77eec..9b9fe26e7 100644 --- a/app/views/admin/university/people/_list.html.erb +++ b/app/views/admin/university/people/_list.html.erb @@ -5,6 +5,7 @@ <th><%= University::Person.human_attribute_name('last_name') %></th> <th><%= University::Person.human_attribute_name('first_name') %></th> <th><%= University::Person.human_attribute_name('roles') %></th> + <th><%= University::Person::Experience.model_name.human(count: 2) %></th> <th></th> <th></th> </tr> @@ -21,6 +22,7 @@ </span> <% end %> </td> + <td><%= link_to_if can?(:update, person), person.experiences.size, experiences_admin_university_person_path(person) %></td> <td> <%= kamifusen_tag person.best_picture, width: 80 if person.best_picture.attached? %> diff --git a/app/views/admin/university/alumni/experiences/_experience_fields.html.erb b/app/views/admin/university/people/experiences/_experience_fields.html.erb similarity index 100% rename from app/views/admin/university/alumni/experiences/_experience_fields.html.erb rename to app/views/admin/university/people/experiences/_experience_fields.html.erb diff --git a/app/views/admin/university/alumni/experiences/edit.html.erb b/app/views/admin/university/people/experiences/edit.html.erb similarity index 66% rename from app/views/admin/university/alumni/experiences/edit.html.erb rename to app/views/admin/university/people/experiences/edit.html.erb index 6e203626c..8d3671123 100644 --- a/app/views/admin/university/alumni/experiences/edit.html.erb +++ b/app/views/admin/university/people/experiences/edit.html.erb @@ -1,14 +1,14 @@ -<% content_for :title, @alumnus %> +<% content_for :title, @person %> <h2 class="h3"><%= University::Person::Experience.model_name.human(count: 2) %></h2> -<%= simple_form_for [:admin, @alumnus], url: experiences_admin_university_alumnus_path(@alumnus) do |f| %> +<%= simple_form_for [:admin, @person], url: experiences_admin_university_person_path(@person) do |f| %> <%= f.error_notification %> <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> <div class="mb-3"> - <%= link_to_add_association t('add'), - f, + <%= link_to_add_association t('add'), + f, :experiences, class: button_classes, data: { @@ -18,8 +18,8 @@ </div> <div id="experiences"> - <%= f.simple_fields_for :experiences, @alumnus.experiences.ordered, include_id: false do |experience_f| %> - <%= render 'admin/university/alumni/experiences/experience_fields', f: experience_f, include_id: true %> + <%= f.simple_fields_for :experiences, @person.experiences.ordered, include_id: false do |experience_f| %> + <%= render 'admin/university/people/experiences/experience_fields', f: experience_f, include_id: true %> <% end %> </div> diff --git a/app/views/admin/university/people/experiences/imports/index.html.erb b/app/views/admin/university/people/experiences/imports/index.html.erb new file mode 100644 index 000000000..c4b1abb81 --- /dev/null +++ b/app/views/admin/university/people/experiences/imports/index.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, t('university.person.experiences.title') %> + +<%= render 'filters', current_path: admin_university_people_experiences_imports_path, filters: @filters if @filters.any? %> + +<%= render 'admin/imports/list', imports: @imports, path_pattern: 'admin_university_people_experiences_import_path' %> + +<% content_for :action_bar_right do %> + <%= link_to_if can?(:create, University::Person::Experience), + t('create'), + new_admin_university_people_experiences_import_path, + class: button_classes %> +<% end %> diff --git a/app/views/admin/university/alumni/experiences/imports/new.html.erb b/app/views/admin/university/people/experiences/imports/new.html.erb similarity index 96% rename from app/views/admin/university/alumni/experiences/imports/new.html.erb rename to app/views/admin/university/people/experiences/imports/new.html.erb index 88246e722..38a41bb96 100644 --- a/app/views/admin/university/alumni/experiences/imports/new.html.erb +++ b/app/views/admin/university/people/experiences/imports/new.html.erb @@ -5,10 +5,10 @@ <p> <%= t('imports.hint_html') %> <br> - <%= t('university.alumni.experiences.import_hint_html') %> + <%= t('university.person.experiences.import_hint_html') %> </p> <%= simple_form_for @import, - url: admin_university_alumni_experiences_imports_path do |f| %> + url: admin_university_people_experiences_imports_path do |f| %> <%= f.error_notification %> <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> diff --git a/app/views/admin/university/people/index.html.erb b/app/views/admin/university/people/index.html.erb index df601c13f..abb5ce6a2 100644 --- a/app/views/admin/university/people/index.html.erb +++ b/app/views/admin/university/people/index.html.erb @@ -5,6 +5,12 @@ <%= render 'admin/university/people/list', people: @people %> <%= paginate @people, theme: 'bootstrap-5' %> +<% content_for :action_bar_left do %> + <%= link_to t('university.person.experiences.import_btn'), + new_admin_university_people_experiences_import_path, + class: button_classes if can? :create, University::Person::Experience %> +<% end %> + <% content_for :action_bar_right do %> <%= create_link University::Person %> <% end %> diff --git a/app/views/admin/university/people/show.html.erb b/app/views/admin/university/people/show.html.erb index 048600793..485f258b5 100644 --- a/app/views/admin/university/people/show.html.erb +++ b/app/views/admin/university/people/show.html.erb @@ -21,6 +21,16 @@ </div> <% end %> +<% +action = '' +action += link_to t('university.manage_experiences'), + experiences_admin_university_person_path(@person), + class: button_classes if can?(:update, @person) +%> +<%= osuny_panel University::Person::Experience.model_name.human(count: 2), action: action do %> + <%= render 'admin/university/people/experiences/list', experiences: @person.experiences.ordered %> +<% end %> + <% content_for :action_bar_left do %> <%= destroy_link @person %> <%= static_link static_admin_university_person_path(@person) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 532844c10..56de4b0f1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -105,6 +105,7 @@ en: label: Background tasks pending hint: Those tasks precompute your data in order to minimize its carbon footprint. It creates a delay before your changes are online. password_hint: Leave blank if you do not wish to change the password. + seo: SEO successfully_created_html: "<i>%{model}</i> was successfully created." successfully_destroyed_html: "<i>%{model}</i> was successfully destroyed." successfully_duplicated_html: "<i>%{model}</i> was successfully duplicated." diff --git a/config/locales/fr.yml b/config/locales/fr.yml index ba028427c..711fa805d 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -105,6 +105,7 @@ fr: label: Tâches en cours de traitement hint: L'exécution de ces tâches contribue à diminuer l'empreinte carbone du numérique, en précalculant ce qui peut l'être. Cela peut générer un délai avant que vos modifications ne soient visibles. password_hint: Laissez vide si vous ne souhaitez pas modifier le mot de passe. + seo: SEO successfully_created_html: "<i>%{model}</i> a bien été créé(e)." successfully_destroyed_html: "<i>%{model}</i> a bien été détruit(e)." successfully_duplicated_html: "<i>%{model}</i> a bien été dupliqué(e)." @@ -202,7 +203,7 @@ fr: imports: error_msg: "Ligne %{line} : %{error}" errors: Erreurs - hint_html: "Les données doivent être au format xlsx.<br>La première ligne doit être dédiée aux entêtes.<br>Les noms des entêtes sont obligatoires et doivent être respectés strictement.<br>Les caractères doivent être encodés en UTF-8.<br>Les champs marqués d'une astérisque sont obligatoires." + hint_html: "Les données doivent être au format xlsx.<br>La première ligne doit être dédiée aux en-têtes.<br>Les noms des entêtes sont obligatoires et doivent être respectés strictement.<br>Les caractères doivent être encodés en UTF-8.<br>Les champs marqués d'une astérisque sont obligatoires." initiated_by: "Initié par :" number_of_lines: "Nombre de lignes dans le fichier :" status: "Status :" diff --git a/config/locales/university/en.yml b/config/locales/university/en.yml index b71021709..1958db792 100644 --- a/config/locales/university/en.yml +++ b/config/locales/university/en.yml @@ -188,10 +188,6 @@ en: import_btn: Import cohorts import_hint_html: "Possible values for <i>gender</i> are: m (male), f (female) and n (non binary).<br><i>Phone_professional</i>, <i>phone_personal</i>, <i>mobile</i> and <i>zipcode</i> fields must have a text format, not numbers.<br><i>Country</i> field must contain the ISO 3166 code of the country, so 2 upcase characters (<a href=\"https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes\" target=\_blank\">list</a>).<br><i>Social_twitter</i> field should have no @.<br><i>School</i> field should contain the internal school id.<br><i>Program</i> field should contain the internal program id." title: Cohorts imports - experiences: - import_btn: Import experiences - import_hint_html: "Possible values for <i>gender</i> are: m (male), f (female) and n (non binary).<br><i>Phone_professional</i>, <i>phone_personal</i>, <i>mobile</i> and <i>zipcode</i> fields must have a text format, not numbers.<br><i>Country</i> field must contain the ISO 3166 code of the country, so 2 upcase characters (<a href=\"https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes\" target=\_blank\">list</a>).<br><i>Social_twitter</i> field should have no @." - title: Experiences imports description: text: Une université est une institution d'enseignement supérieur, d'étude et de recherche, constituée par la réunion de divers établissements nommés suivant les traditions “collègesâ€, “facultésâ€, “institutsâ€, “départementsâ€, “centresâ€, “sectionsâ€, “unités†ou écoles spécifiques, mais aussi bibliothèque ou atelier, médiathèque ou musée, etc. formant un ensemble administratif cohérent avec un statut de droit défini, public, privé ou éventuellement mixte. source: Wikipedia @@ -210,6 +206,10 @@ en: no_organization_hint_html: "If the organization is not in the list, you can <a href=\"%{url}\">create it</a>" no_organization_hint_no_access_html: "If the organization is not in the list, you should ask to create it" period: Period + experiences: + import_btn: Import experiences + import_hint_html: "Possible values for <i>gender</i> are: m (male), f (female) and n (non binary).<br><i>Phone_professional</i>, <i>phone_personal</i>, <i>mobile</i> and <i>zipcode</i> fields must have a text format, not numbers.<br><i>Country</i> field must contain the ISO 3166 code of the country, so 2 upcase characters (<a href=\"https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes\" target=\_blank\">list</a>).<br><i>Social_twitter</i> field should have no @." + title: Experiences imports personal_data_warning: Warning! The information provided below can be publicly visible on the websites and the extranets about you. taught_programs: Taught programs sso: SSO diff --git a/config/locales/university/fr.yml b/config/locales/university/fr.yml index 8214f25cd..bec6dcdda 100644 --- a/config/locales/university/fr.yml +++ b/config/locales/university/fr.yml @@ -188,10 +188,6 @@ fr: import_btn: Importer des promotions import_hint_html: "Les valeurs pour <i>gender</i> peuvent être m (masculin), f (féminin) et n (non binaire).<br>Les champs <i>phone_professional</i>, <i>phone_personal</i>, <i>mobile</i> et <i>zipcode</i> doivent être au format texte, pas nombre.<br>Le champ <i>country</i> doit contenir le code ISO 3166 du pays, sur 2 caratères en majuscule (<a href=\"https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes\" target=\_blank\">liste</a>)<br>Le champ <i>social_twitter</i> ne doit pas contenir d'@.<br>Le champ <i>school</i> doit contenir l'id interne de l'école.<br>Le champ <i>program</i> doit contenir l'id interne de la formation." title: Imports de promotions - experiences: - import_btn: Importer des expériences - import_hint_html: "Les valeurs pour <i>gender</i> peuvent être m (masculin), f (féminin) et n (non binaire).<br>Les champs <i>phone_professional</i>, <i>phone_personal</i>, <i>mobile</i> et <i>zipcode</i> doivent être au format texte, pas nombre.<br>Le champ <i>country</i> doit contenir le code ISO 3166 du pays, sur 2 caratères en majuscule (<a href=\"https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes\" target=\_blank\">liste</a>)<br>Le champ <i>social_twitter</i> ne doit pas contenir d'@." - title: Imports d'expériences description: text: Une université est une institution d'enseignement supérieur, d'étude et de recherche, constituée par la réunion de divers établissements nommés suivant les traditions “collègesâ€, “facultésâ€, “institutsâ€, “départementsâ€, “centresâ€, “sectionsâ€, “unités†ou écoles spécifiques, mais aussi bibliothèque ou atelier, médiathèque ou musée, etc. formant un ensemble administratif cohérent avec un statut de droit défini, public, privé ou éventuellement mixte. source: Wikipedia @@ -210,6 +206,10 @@ fr: no_organization_hint_html: "Si l'entreprise n'apparait pas dans la liste, vous pouvez la <a href=\"%{url}\">créer</a>" no_organization_hint_no_access_html: "Si l'entreprise n'apparait pas dans la liste, il faut demander à la créer" period: Période + experiences: + import_btn: Importer des expériences + import_hint_html: "Les valeurs pour <i>gender</i> peuvent être m (masculin), f (féminin) et n (non binaire).<br>Les champs <i>phone_professional</i>, <i>phone_personal</i>, <i>mobile</i> et <i>zipcode</i> doivent être au format texte, pas nombre.<br>Le champ <i>country</i> doit contenir le code ISO 3166 du pays, sur 2 caratères en majuscule (<a href=\"https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes\" target=\_blank\">liste</a>)<br>Le champ <i>social_twitter</i> ne doit pas contenir d'@." + title: Imports d'expériences personal_data_warning: Attention ! Les informations renseignées ici sont susceptibles d'être visibles publiquement sur les sites web et les extranets vous concernant. taught_programs: Formations enseignées sso: SSO diff --git a/config/routes/admin/university.rb b/config/routes/admin/university.rb index e7db269e9..8a573a0a1 100644 --- a/config/routes/admin/university.rb +++ b/config/routes/admin/university.rb @@ -7,22 +7,24 @@ namespace :university do namespace :cohorts do resources :imports, only: [:index, :show, :new, :create] end - namespace :experiences do - resources :imports, only: [:index, :show, :new, :create] - end end resources :alumni, only: [:index, :show] do member do get 'cohorts' => 'alumni/cohorts#edit' patch 'cohorts' => 'alumni/cohorts#update' - get 'experiences' => 'alumni/experiences#edit' - patch 'experiences' => 'alumni/experiences#update' end end resources :people do member do get :static get "/translations/:lang" => "people#in_language", as: :show_in_language + get 'experiences' => 'people/experiences#edit' + patch 'experiences' => 'people/experiences#update' + end + end + namespace :people do + namespace :experiences do + resources :imports, only: [:index, :show, :new, :create] end end resources :organizations do -- GitLab