diff --git a/app/controllers/admin/education/programs_controller.rb b/app/controllers/admin/education/programs_controller.rb index 30e6561f067ae08e94c3bbbb490ce7a771ddcfaf..bddf6e5125abf63e795c8d12782611137ad8bb76 100644 --- a/app/controllers/admin/education/programs_controller.rb +++ b/app/controllers/admin/education/programs_controller.rb @@ -112,7 +112,8 @@ class Admin::Education::ProgramsController < Admin::Education::ApplicationContro :name, :short_name, :slug, :capacity, :continuing, :initial, :apprenticeship, :meta_description, :summary, :published, :featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit, :prerequisites, :objectives, :presentation, :registration, :pedagogy, :content, :registration_url, - :evaluation, :accessibility, :pricing, :contacts, :opportunities, :results, :other, :main_information, + :evaluation, :accessibility, :contacts, :opportunities, :results, :other, :main_information, + :pricing, :pricing_apprenticeship, :pricing_continuing, :pricing_initial, :downloadable_summary, :downloadable_summary_delete, :parent_id, :diploma_id, school_ids: [], university_person_involvements_attributes: [:id, :person_id, :description, :position, :_destroy] diff --git a/app/models/communication/website/agenda/event.rb b/app/models/communication/website/agenda/event.rb index d30cb3a71fc133f1b97fd68180e9faad0f22508f..19cca5948739de129e32e5920094e408872cff94 100644 --- a/app/models/communication/website/agenda/event.rb +++ b/app/models/communication/website/agenda/event.rb @@ -3,6 +3,7 @@ # Table name: communication_website_agenda_events # # id :uuid not null, primary key +# add_to_calendar_urls :jsonb # featured_image_alt :text # featured_image_credit :text # from_day :date diff --git a/app/models/communication/website/agenda/event/with_cal.rb b/app/models/communication/website/agenda/event/with_cal.rb index b03c58c3e980285a41e58e55ae56116a8516fded..e964f63a650e8c1a9ac2ae1bab6f328adae7d7ca 100644 --- a/app/models/communication/website/agenda/event/with_cal.rb +++ b/app/models/communication/website/agenda/event/with_cal.rb @@ -1,6 +1,10 @@ module Communication::Website::Agenda::Event::WithCal extend ActiveSupport::Concern + included do + before_save :set_add_to_calendar_urls + end + def cal @cal ||= AddToCalendar::URLs.new( start_datetime: cal_from_time, @@ -13,8 +17,39 @@ module Communication::Website::Agenda::Event::WithCal ) end + def cal_google_url + add_to_calendar_urls['google'] + end + + def cal_yahoo_url + add_to_calendar_urls['yahoo'] + end + + def cal_office_url + add_to_calendar_urls['office'] + end + + def cal_outlook_url + add_to_calendar_urls['outlook'] + end + + def cal_ical_url + add_to_calendar_urls['ical'] + end + + protected + def set_add_to_calendar_urls + self.add_to_calendar_urls = { + 'google' => cal.google_url, + 'yahoo' => cal.yahoo_url, + 'office' => cal.office365_url, + 'outlook' => cal.outlook_com_url, + 'ical' => cal.ical_url + } + end + def cal_from_time from_hour.nil? ? from_day.to_time : date_and_time(from_day, from_hour) diff --git a/app/models/communication/website/agenda/event/with_time.rb b/app/models/communication/website/agenda/event/with_time.rb index 4f2078fd5b21324c44e2d47360fe7deadb85b7f6..ea401cbbb8120e29a215884a2a5750d5031d0245 100644 --- a/app/models/communication/website/agenda/event/with_time.rb +++ b/app/models/communication/website/agenda/event/with_time.rb @@ -47,6 +47,14 @@ module Communication::Website::Agenda::Event::WithTime from_day == to_day end + def has_hours? + from_hour.present? || to_hour.present? + end + + def has_specific_time_zone? + time_zone != website.default_time_zone + end + # Un événement demain aura une distance de 1, comme un événement hier # On utilise cette info pour classer les événements à venir dans un sens et les archives dans l'autre def distance_in_days @@ -56,7 +64,7 @@ module Communication::Website::Agenda::Event::WithTime protected def set_time_zone - self.time_zone = Time.zone.name if self.time_zone.nil? + self.time_zone = website.default_time_zone if self.time_zone.blank? end def set_to_day diff --git a/app/models/education/program.rb b/app/models/education/program.rb index e636a892ca1036b8c8f8c019a52bfaef4b5482f4..8644effa2e608d63f19e73a8c387cdcbe2e56b98 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -2,41 +2,44 @@ # # Table name: education_programs # -# id :uuid not null, primary key -# accessibility :text -# apprenticeship :boolean -# capacity :integer -# contacts :text -# content :text -# continuing :boolean -# duration :text -# evaluation :text -# featured_image_alt :string -# featured_image_credit :text -# initial :boolean -# meta_description :text -# name :string -# objectives :text -# opportunities :text -# other :text -# path :string -# pedagogy :text -# position :integer default(0) -# prerequisites :text -# presentation :text -# pricing :text -# published :boolean default(FALSE) -# registration :text -# registration_url :string -# results :text -# short_name :string -# slug :string indexed -# summary :text -# created_at :datetime not null -# updated_at :datetime not null -# diploma_id :uuid indexed -# parent_id :uuid indexed -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# accessibility :text +# apprenticeship :boolean +# capacity :integer +# contacts :text +# content :text +# continuing :boolean +# duration :text +# evaluation :text +# featured_image_alt :string +# featured_image_credit :text +# initial :boolean +# meta_description :text +# name :string +# objectives :text +# opportunities :text +# other :text +# path :string +# pedagogy :text +# position :integer default(0) +# prerequisites :text +# presentation :text +# pricing :text +# pricing_apprenticeship :text +# pricing_continuing :text +# pricing_initial :text +# published :boolean default(FALSE) +# registration :text +# registration_url :string +# results :text +# short_name :string +# slug :string indexed +# summary :text +# created_at :datetime not null +# updated_at :datetime not null +# diploma_id :uuid indexed +# parent_id :uuid indexed +# university_id :uuid not null, indexed # # Indexes # @@ -83,6 +86,9 @@ class Education::Program < ApplicationRecord :pedagogy, :prerequisites, :pricing, + :pricing_apprenticeship, + :pricing_continuing, + :pricing_initial, :registration, :content, :results diff --git a/app/models/research/hal/author.rb b/app/models/research/hal/author.rb index 4db356faaf84186dbf974b2933754b865e78c3c3..d9ab7826da28942c0042f42500540bb324a8aef0 100644 --- a/app/models/research/hal/author.rb +++ b/app/models/research/hal/author.rb @@ -65,7 +65,8 @@ class Research::Hal::Author < ApplicationRecord end def import_research_hal_publications! - publications.hal.clear + # HAL author has only HAL publications + publications.clear # Do not overuse the API if no researcher is concerned return if researchers.none? Importers::Hal.import_publications_for_author(self).each do |publication| diff --git a/app/models/university/person/with_research.rb b/app/models/university/person/with_research.rb index da728421fbd7de53f12f2a1a47ff7d044eb839c3..d70abcb3ffe0ae0b895a76e95569d37200ccee2c 100644 --- a/app/models/university/person/with_research.rb +++ b/app/models/university/person/with_research.rb @@ -34,7 +34,7 @@ module University::Person::WithResearch end def import_research_hal_publications! - publications.hal.clear + publications.delete(publications.hal) hal_authors.each do |author| # TODO manage same researcher in different universities publications.concat author.import_research_hal_publications! diff --git a/app/views/admin/communication/websites/agenda/events/_dates.html.erb b/app/views/admin/communication/websites/agenda/events/_dates.html.erb index 7528bc5be65c40946c8b50059cabc20564d44fa2..5fbfedcf52976acc328986e2088d95c1b938b9b2 100644 --- a/app/views/admin/communication/websites/agenda/events/_dates.html.erb +++ b/app/views/admin/communication/websites/agenda/events/_dates.html.erb @@ -21,7 +21,7 @@ day_format = detailed ? :full <%= l(event.to_hour, format: :time_only) if event.to_hour %> <% end %> <% end %> -<% unless event.from_hour.nil? && event.to_hour.nil? %> +<% if event.has_hours? && event.has_specific_time_zone? %> <br> <%= t('admin.communication.website.agenda.events.formatted_time_zone', time_zone: event.time_zone) %> <% end %> \ No newline at end of file diff --git a/app/views/admin/communication/websites/agenda/events/_dates_static.html.erb b/app/views/admin/communication/websites/agenda/events/_dates_static.html.erb index 703d8eb353d11ae8b7f5e76b76a251ee4f6c9b8a..e6d436b85a9658533003b4986f99e01aa222882d 100644 --- a/app/views/admin/communication/websites/agenda/events/_dates_static.html.erb +++ b/app/views/admin/communication/websites/agenda/events/_dates_static.html.erb @@ -26,8 +26,8 @@ indentation = ' ' * depth <%= indentation %> hour: <%= event.to_hour.strftime "%H:%M" %> <% end %> <%= indentation %> add_to_calendar: -<%= indentation %> google: "<%= event.cal.google_url.html_safe %>" -<%= indentation %> yahoo: "<%= event.cal.yahoo_url.html_safe %>" -<%= indentation %> office: "<%= event.cal.office365_url.html_safe %>" -<%= indentation %> outlook: "<%= event.cal.outlook_com_url.html_safe %>" -<%= indentation %> ical: "<%= event.cal.ical_url.html_safe %>" +<%= indentation %> google: "<%= event.cal_google_url.html_safe %>" +<%= indentation %> yahoo: "<%= event.cal_yahoo_url.html_safe %>" +<%= indentation %> office: "<%= event.cal_office_url.html_safe %>" +<%= indentation %> outlook: "<%= event.cal_outlook_url.html_safe %>" +<%= indentation %> ical: "<%= event.cal_ical_url.html_safe %>" diff --git a/app/views/admin/education/programs/_form.html.erb b/app/views/admin/education/programs/_form.html.erb index 8e07bec089633a10e49897b81faca8cad8a37339..d12264e1807defb7e55ab1ca16043b5898e2877e 100644 --- a/app/views/admin/education/programs/_form.html.erb +++ b/app/views/admin/education/programs/_form.html.erb @@ -110,9 +110,20 @@ <div class="col-xxl-6"> <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :pricing %> </div> + <div class="col-xxl-6"> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :pricing_initial %> + </div> + <div class="col-xxl-6"> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :pricing_continuing %> + </div> + <div class="col-xxl-6"> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :pricing_apprenticeship %> + </div> <div class="col-xxl-6"> <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :registration %> - <%= f.input :registration_url %> + </div> + <div class="col-xxl-6"> + <%= f.input :registration_url %> </div> <div class="col-xxl-6"> <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :accessibility %> diff --git a/app/views/admin/education/programs/show.html.erb b/app/views/admin/education/programs/show.html.erb index cecf882d285418e1a74fcd373ac86185aaa3daae..92a209d813c04777d57951cf46bc94985f5fd883 100644 --- a/app/views/admin/education/programs/show.html.erb +++ b/app/views/admin/education/programs/show.html.erb @@ -99,6 +99,9 @@ <%= render 'admin/application/property/text', object: @program, property: :registration %> <%= render 'admin/application/property/text', object: @program, property: :other %> <%= render 'admin/application/property/text', object: @program, property: :pricing %> + <%= render 'admin/application/property/text', object: @program, property: :pricing_initial %> + <%= render 'admin/application/property/text', object: @program, property: :pricing_continuing %> + <%= render 'admin/application/property/text', object: @program, property: :pricing_apprenticeship %> <%= render 'admin/application/property/text', object: @program, property: :accessibility %> <%= render 'admin/application/property/text', object: @program, property: :contacts %> <% if @program.registration_url.present? %> diff --git a/app/views/admin/education/programs/static.html.erb b/app/views/admin/education/programs/static.html.erb index 8ad8110960304e1c974095e0243f83bcfd109bfa..aa8841780ba7af0eba07e421ca9a55f5a339b5b5 100644 --- a/app/views/admin/education/programs/static.html.erb +++ b/app/views/admin/education/programs/static.html.erb @@ -80,6 +80,9 @@ apprenticeship: <%= @about.apprenticeship %> :pedagogy, :prerequisites, :pricing, + :pricing_initial, + :pricing_continuing, + :pricing_apprenticeship, :registration, :results ].each do |property| %> diff --git a/config/locales/education/en.yml b/config/locales/education/en.yml index 38766f83388f7d5f72d3860bfed9a8b73cd842dd..d6e98ff69e9d61d03e32aa8eaa4631c0a3c8b8c5 100644 --- a/config/locales/education/en.yml +++ b/config/locales/education/en.yml @@ -62,7 +62,10 @@ en: pedagogy: Méthodes mobilisées prerequisites: Prérequis presentation: In brief - pricing: Tarifs + pricing: Costs + pricing_initial: Costs for initial training + pricing_continuing: Costs for continuous training + pricing_apprenticeship: Costs for apprenticeship published: Published? registration: Modalités et délais d’accès registration_url: Registration link (URL) diff --git a/config/locales/education/fr.yml b/config/locales/education/fr.yml index 4e2252160d136362df4cff92f0e9131ea04d8415..c51ffe26f3071d94b72a7fe567c95a1ed8b25fa4 100644 --- a/config/locales/education/fr.yml +++ b/config/locales/education/fr.yml @@ -62,7 +62,10 @@ fr: pedagogy: Méthodes mobilisées prerequisites: Prérequis presentation: En bref - pricing: Tarifs + pricing: Coûts + pricing_initial: Coûts de la formation initiale + pricing_continuing: Coûts de la formation continue + pricing_apprenticeship: Coûts de l'apprentissage published: Publiée ? registration: Modalités et délais d’accès registration_url: Lien d'inscription (URL) diff --git a/db/migrate/20240208131753_add_add_to_calendar_urls_to_communication_website_agenda_events.rb b/db/migrate/20240208131753_add_add_to_calendar_urls_to_communication_website_agenda_events.rb new file mode 100644 index 0000000000000000000000000000000000000000..cfa277e17c74f5b377d4f75b48d4805115ca5b67 --- /dev/null +++ b/db/migrate/20240208131753_add_add_to_calendar_urls_to_communication_website_agenda_events.rb @@ -0,0 +1,7 @@ +class AddAddToCalendarUrlsToCommunicationWebsiteAgendaEvents < ActiveRecord::Migration[7.1] + def change + add_column :communication_website_agenda_events, :add_to_calendar_urls, :jsonb + Communication::Website::Agenda::Event.reset_column_information + Communication::Website::Agenda::Event.find_each(&:save) + end +end diff --git a/db/migrate/20240209135241_add_pricing_fields_to_education_programs.rb b/db/migrate/20240209135241_add_pricing_fields_to_education_programs.rb new file mode 100644 index 0000000000000000000000000000000000000000..b2f1305d3eba441826a9f4632bf5e388a5bdb853 --- /dev/null +++ b/db/migrate/20240209135241_add_pricing_fields_to_education_programs.rb @@ -0,0 +1,7 @@ +class AddPricingFieldsToEducationPrograms < ActiveRecord::Migration[7.1] + def change + add_column :education_programs, :pricing_continuing, :text + add_column :education_programs, :pricing_apprenticeship, :text + add_column :education_programs, :pricing_initial, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 3a415f4c60a1657c084d9af38cbc3bc55f114c60..5915dd513b1b224872cd3e782b104235926f5291 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.1].define(version: 2024_02_07_085338) do +ActiveRecord::Schema[7.1].define(version: 2024_02_09_135241) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -311,6 +311,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_07_085338) do t.string "slug" t.string "subtitle" t.string "time_zone" + t.jsonb "add_to_calendar_urls" t.index ["communication_website_id"], name: "index_agenda_events_on_communication_website_id" t.index ["language_id"], name: "index_communication_website_agenda_events_on_language_id" t.index ["original_id"], name: "index_communication_website_agenda_events_on_original_id" @@ -679,6 +680,9 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_07_085338) do t.boolean "apprenticeship" t.string "registration_url" t.text "summary" + t.text "pricing_continuing" + t.text "pricing_apprenticeship" + t.text "pricing_initial" t.index ["diploma_id"], name: "index_education_programs_on_diploma_id" t.index ["parent_id"], name: "index_education_programs_on_parent_id" t.index ["slug"], name: "index_education_programs_on_slug"