From 567cbd262cc9138859880999bf1f1bd66f3ec129 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Mon, 20 Mar 2023 14:41:53 +0100 Subject: [PATCH] Add url to school --- .../admin/education/schools_controller.rb | 2 +- app/models/education/school.rb | 1 + .../admin/education/schools/_form.html.erb | 1 + .../admin/education/schools/show.html.erb | 10 ++++++++-- .../extranet/application/_footer.html.erb | 18 ++++++++++++------ config/locales/education/en.yml | 1 + config/locales/education/fr.yml | 1 + ...230320125138_add_url_to_education_school.rb | 5 +++++ db/schema.rb | 3 ++- test/fixtures/education/schools.yml | 3 ++- 10 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 db/migrate/20230320125138_add_url_to_education_school.rb diff --git a/app/controllers/admin/education/schools_controller.rb b/app/controllers/admin/education/schools_controller.rb index 93593ffc8..ff0db0ab6 100644 --- a/app/controllers/admin/education/schools_controller.rb +++ b/app/controllers/admin/education/schools_controller.rb @@ -60,6 +60,6 @@ class Admin::Education::SchoolsController < Admin::Education::ApplicationControl def school_params params.require(:education_school) - .permit(:university_id, :name, :address, :zipcode, :city, :country, :phone, :logo, :logo_delete, program_ids: []) + .permit(:university_id, :name, :address, :zipcode, :city, :country, :url, :phone, :logo, :logo_delete, program_ids: []) end end diff --git a/app/models/education/school.rb b/app/models/education/school.rb index b98be91e9..9fea2108a 100644 --- a/app/models/education/school.rb +++ b/app/models/education/school.rb @@ -10,6 +10,7 @@ # longitude :float # name :string # phone :string +# url :string # zipcode :string # created_at :datetime not null # updated_at :datetime not null diff --git a/app/views/admin/education/schools/_form.html.erb b/app/views/admin/education/schools/_form.html.erb index 3ac9696e2..90e3d4368 100644 --- a/app/views/admin/education/schools/_form.html.erb +++ b/app/views/admin/education/schools/_form.html.erb @@ -17,6 +17,7 @@ </div> </div> <%= f.input :country, input_html: { class: 'form-select' } %> + <%= f.input :url %> <%= f.input :logo, as: :single_deletable_file, input_html: { accept: '.jpg,.jpeg,.png,.svg' }, diff --git a/app/views/admin/education/schools/show.html.erb b/app/views/admin/education/schools/show.html.erb index 0875e4b50..8fae9ac1c 100644 --- a/app/views/admin/education/schools/show.html.erb +++ b/app/views/admin/education/schools/show.html.erb @@ -10,8 +10,14 @@ <%= @school.zipcode %> <%= @school.city %><br> <%= @school.country %> </p> - <%= osuny_label Education::School.human_attribute_name('phone') %> - <p><%= @school.phone %></p> + <% if @school.phone.present? %> + <%= osuny_label Education::School.human_attribute_name('phone') %> + <p><%= @school.phone %></p> + <% end %> + <% if @school.url.present? %> + <%= osuny_label Education::School.human_attribute_name('url') %> + <p><%= link_to @school.url, @school.url, target: :_blank %></p> + <% end %> <% end %> </div> diff --git a/app/views/extranet/application/_footer.html.erb b/app/views/extranet/application/_footer.html.erb index 3768ffa80..90c6d199b 100644 --- a/app/views/extranet/application/_footer.html.erb +++ b/app/views/extranet/application/_footer.html.erb @@ -1,4 +1,7 @@ -<% hide_logo ||= false %> +<% +hide_logo ||= false +about = current_extranet.about +%> <footer class="pt-5"> <div class="container"> @@ -9,14 +12,17 @@ <% end %> <div class="row justify-space-between"> <div class="col-md-6"> - <% if current_extranet.about.is_a?(Education::School) %> + <% if about.is_a?(Education::School) %> <address itemscope itemtype="https://schema.org/CollegeOrUniversity"> - <span itemprop="name"><%= current_extranet.about.name %></span> + <span itemprop="name"><%= about.name %></span> <div itemprop="address" itemscope itemtype="https://schema.org/PostalAddress"> - <span itemprop="streetAddress"><%= current_extranet.about.address %></span><br> - <span itemprop="postalCode"><%= current_extranet.about.zipcode %></span> - <span itemprop="addressLocality"><%= current_extranet.about.city %></span><br> + <span itemprop="streetAddress"><%= about.address %></span><br> + <span itemprop="postalCode"><%= about.zipcode %></span> + <span itemprop="addressLocality"><%= about.city %></span><br> </div> + <% if about.url.present? %> + <a href="<%= social_website_to_url about.url %>" target="_blank" property="url"><%= social_website_to_s about.url %></a> + <% end %> </address> <% elsif current_extranet.about.is_a?(Education::Program) %> <div itemscope itemtype="https://schema.org/EducationalOccupationalCredential"> diff --git a/config/locales/education/en.yml b/config/locales/education/en.yml index 16fd9aa73..dfd4c369a 100644 --- a/config/locales/education/en.yml +++ b/config/locales/education/en.yml @@ -79,6 +79,7 @@ en: phone: Phone programs: Programs provided roles: Team Members + url: Website websites: Linked websites zipcode: Zipcode admin: diff --git a/config/locales/education/fr.yml b/config/locales/education/fr.yml index dcf3e47d0..73b87aa91 100644 --- a/config/locales/education/fr.yml +++ b/config/locales/education/fr.yml @@ -82,6 +82,7 @@ fr: phone: Téléphone programs: Formations dispensées roles: Membres de l'équipe + url: Site Web websites: Sites Web associés zipcode: Code postal university/person/teacher: diff --git a/db/migrate/20230320125138_add_url_to_education_school.rb b/db/migrate/20230320125138_add_url_to_education_school.rb new file mode 100644 index 000000000..92ab55485 --- /dev/null +++ b/db/migrate/20230320125138_add_url_to_education_school.rb @@ -0,0 +1,5 @@ +class AddUrlToEducationSchool < ActiveRecord::Migration[7.0] + def change + add_column :education_schools, :url, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index f7806b056..e23ee7176 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_03_17_160229) do +ActiveRecord::Schema[7.0].define(version: 2023_03_20_125138) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -658,6 +658,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_17_160229) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "phone" + t.string "url" t.index ["university_id"], name: "index_education_schools_on_university_id" end diff --git a/test/fixtures/education/schools.yml b/test/fixtures/education/schools.yml index e0f957684..fce634f27 100644 --- a/test/fixtures/education/schools.yml +++ b/test/fixtures/education/schools.yml @@ -10,6 +10,7 @@ # longitude :float # name :string # phone :string +# url :string # zipcode :string # created_at :datetime not null # updated_at :datetime not null @@ -29,4 +30,4 @@ default_school: zipcode: 33080 city: Bordeaux country: FR - university: default_university \ No newline at end of file + university: default_university -- GitLab