diff --git a/Gemfile b/Gemfile index 63370895bb064f8f55e6fd88362e1ac62b1d9d79..2ba0ccf6973a7c30d1e4a6dd2c964e13108707d2 100644 --- a/Gemfile +++ b/Gemfile @@ -14,6 +14,7 @@ gem "bootstrap5-kaminari-views" gem "breadcrumbs_on_rails" gem "bugsnag" gem "cancancan", "3.3.0" +gem "caxlsx_rails", "~> 0.6.3" gem "cocoon", "~> 1.2" gem "country_select" gem "curation"#, path: "../../arnaudlevy/curation" diff --git a/Gemfile.lock b/Gemfile.lock index b067b14958b12f266689deb332dfa6dddaa31a27..5ace75a6610f1dbc53c84b0dd39bf5cc5fdf3353 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -145,6 +145,14 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + caxlsx (3.3.0) + htmlentities (~> 4.3, >= 4.3.4) + marcel (~> 1.0) + nokogiri (~> 1.10, >= 1.10.4) + rubyzip (>= 1.3.0, < 3) + caxlsx_rails (0.6.3) + actionpack (>= 3.1) + caxlsx (>= 3.0) cocoon (1.2.15) concurrent-ruby (1.2.0) countries (5.3.1) @@ -568,6 +576,7 @@ DEPENDENCIES byebug cancancan (= 3.3.0) capybara (>= 3.26) + caxlsx_rails (~> 0.6.3) cocoon (~> 1.2) country_select curation diff --git a/app/controllers/admin/communication/extranets/contacts_controller.rb b/app/controllers/admin/communication/extranets/contacts_controller.rb index d74dbda0e861fa1935b9d89dced9a2aa059aa2e7..53b19b0f630f3e392565e50583550e2ca4e459c8 100644 --- a/app/controllers/admin/communication/extranets/contacts_controller.rb +++ b/app/controllers/admin/communication/extranets/contacts_controller.rb @@ -1,7 +1,22 @@ class Admin::Communication::Extranets::ContactsController < Admin::Communication::Extranets::ApplicationController def index - @persons = current_university.people.ordered.page params[:persons_page] - @organizations = current_university.organizations.ordered.page params[:organizations_page] + @people = current_university.people.ordered + @organizations = current_university.organizations.ordered + respond_to do |format| + format.html { + @people = @people.page params[:persons_page] + @organizations = @organizations.page params[:organizations_page] + } + format.xlsx { + # could be 2 differents controllers in Contacts/People & Contacts/Organizations, each with an index export + @export = params['export'] + filename = "#{@export}-#{Time.now.strftime("%Y%m%d%H%M%S")}.xlsx" + response.headers['Content-Disposition'] = "attachment; filename=#{filename}" + render @export + } + end + + breadcrumb add_breadcrumb Communication::Extranet.human_attribute_name(:feature_contacts) end @@ -26,4 +41,4 @@ class Admin::Communication::Extranets::ContactsController < Admin::Communication object_id = params[:objectId] @object = object_type.constantize.find object_id end -end \ No newline at end of file +end diff --git a/app/models/communication/extranet.rb b/app/models/communication/extranet.rb index 268fc63728594c117c8da5fd5615e2f43d5293b4..efd6e6f0ae57398ed1b712c54477a77afdc4bc84 100644 --- a/app/models/communication/extranet.rb +++ b/app/models/communication/extranet.rb @@ -2,34 +2,35 @@ # # Table name: communication_extranets # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# color :string -# cookies_policy :text -# css :text -# feature_alumni :boolean default(FALSE) -# feature_contacts :boolean default(FALSE) -# feature_jobs :boolean default(FALSE) -# feature_library :boolean default(FALSE) -# feature_posts :boolean default(FALSE) -# has_sso :boolean default(FALSE) -# home_sentence :text -# host :string -# name :string -# privacy_policy :text -# registration_contact :string -# sass :text -# sso_button_label :string -# sso_cert :text -# sso_mapping :jsonb -# sso_name_identifier_format :string -# sso_provider :integer default("saml") -# sso_target_url :string -# terms :text -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# allow_experiences_modification :boolean default(TRUE) +# color :string +# cookies_policy :text +# css :text +# feature_alumni :boolean default(FALSE) +# feature_contacts :boolean default(FALSE) +# feature_jobs :boolean default(FALSE) +# feature_library :boolean default(FALSE) +# feature_posts :boolean default(FALSE) +# has_sso :boolean default(FALSE) +# home_sentence :text +# host :string +# name :string +# privacy_policy :text +# registration_contact :string +# sass :text +# sso_button_label :string +# sso_cert :text +# sso_mapping :jsonb +# sso_name_identifier_format :string +# sso_provider :integer default("saml") +# sso_target_url :string +# terms :text +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# university_id :uuid not null, indexed # # Indexes # diff --git a/app/models/concerns/with_country.rb b/app/models/concerns/with_country.rb new file mode 100644 index 0000000000000000000000000000000000000000..0dcc66b76dbd04da2e2792c032552d43353a022d --- /dev/null +++ b/app/models/concerns/with_country.rb @@ -0,0 +1,20 @@ +module WithCountry + extend ActiveSupport::Concern + + def country_name + return if country_iso.blank? + country_iso.translations[I18n.locale.to_s] || country_common_name + end + + def country_common_name + return if country_iso.blank? + country_iso.common_name || country_iso.iso_short_name + end + + private + + def country_iso + return @country_iso if defined?(@country_iso) + @country_iso ||= country.blank? ? nil : ISO3166::Country[country] + end +end diff --git a/app/models/concerns/with_geolocation.rb b/app/models/concerns/with_geolocation.rb index df92252bd5228b5eefd05626eeca2dc4a85820d6..2e975c0c70baf772f08fa5e373c9120009b76aa7 100644 --- a/app/models/concerns/with_geolocation.rb +++ b/app/models/concerns/with_geolocation.rb @@ -17,7 +17,7 @@ module WithGeolocation string += "#{address}<br>" if address.present? string += "#{address_additional}<br>" if address_additional.present? string += "#{zipcode} #{city}" - string += "<br>#{ISO3166::Country[country]}" if country + string += "<br>#{country_common_name}" if country string end @@ -42,4 +42,4 @@ module WithGeolocation def full_street_address_changed? address_changed? || zipcode_changed? || city_changed? end -end \ No newline at end of file +end diff --git a/app/models/education/school.rb b/app/models/education/school.rb index 78ab3e1fc5fbae0c810d23ff5a7feca6ab1d30a7..b98be91e95cdfe440cc1a17aac51e782080d4353 100644 --- a/app/models/education/school.rb +++ b/app/models/education/school.rb @@ -25,6 +25,7 @@ # class Education::School < ApplicationRecord include Sanitizable + include WithCountry include WithGit include Aboutable include WithPrograms # must come before WithAlumni and WithTeam diff --git a/app/models/research/laboratory.rb b/app/models/research/laboratory.rb index a70817fe92d6ce36ecdc4f0a4259a6b3b775099a..78a882d2565d6445604c5e37db9b8a4a3830257a 100644 --- a/app/models/research/laboratory.rb +++ b/app/models/research/laboratory.rb @@ -23,6 +23,7 @@ class Research::Laboratory < ApplicationRecord include Aboutable include Sanitizable + include WithCountry include WithGit belongs_to :university diff --git a/app/models/university.rb b/app/models/university.rb index 321f21333ed82efcb40e446851f6b5da3df545f0..832286fc48813ba4c745e414fb7d446a95739a5f 100644 --- a/app/models/university.rb +++ b/app/models/university.rb @@ -41,6 +41,7 @@ class University < ApplicationRecord # We don't include Sanitizable because too many complex attributes. We handle it below. include WithPeopleAndOrganizations include WithCommunication + include WithCountry include WithEducation include WithIdentifier include WithInvoice diff --git a/app/models/university/organization.rb b/app/models/university/organization.rb index 26ec7059d1f864b72ae4e27ff8894ce0e799b61a..54f1e9ba8afd6d5c1c2390e626813ce792d1177c 100644 --- a/app/models/university/organization.rb +++ b/app/models/university/organization.rb @@ -43,6 +43,7 @@ class University::Organization < ApplicationRecord include Sanitizable include WithBlobs include WithBlocks + include WithCountry include WithGeolocation include WithGit include WithPermalink diff --git a/app/models/university/person.rb b/app/models/university/person.rb index 59a9e253f76cc059df0e179dbfeccaf13e0dff9b..1475b5beeaa888976b69047a7edada51f60aed55 100644 --- a/app/models/university/person.rb +++ b/app/models/university/person.rb @@ -57,6 +57,7 @@ class University::Person < ApplicationRecord include WithUniversity include WithGit include WithBlobs + include WithCountry include WithEducation include WithExperiences include WithSlug diff --git a/app/views/admin/communication/extranets/contacts/index.html.erb b/app/views/admin/communication/extranets/contacts/index.html.erb index 9c0b638d69cc7b58fa37ec32d7e904833e08b193..d737b23932ba03a2c273dc7128da4c66f7b22592 100644 --- a/app/views/admin/communication/extranets/contacts/index.html.erb +++ b/app/views/admin/communication/extranets/contacts/index.html.erb @@ -1,29 +1,32 @@ <% content_for :title, Communication::Extranet.human_attribute_name(:feature_contacts) %> <%= render 'admin/communication/extranets/sidebar' do %> - <%= osuny_panel University::Person.model_name.human(count: 2) do %> + <% action = link_to t('export'), + admin_communication_extranet_contacts_path(extranet_id: @extranet.id, export: 'people', format: :xlsx), + class: button_classes('ms-1') if can?(:show, University::Person) %> + <%= osuny_panel University::Person.model_name.human(count: 2), action: action do %> <div class="table-responsive"> <table class="<%= table_classes%>"> <tbody> - <% @persons.each do |person| %> + <% @people.each do |person| %> <tr> <td><%= link_to person, [:admin, person] %></td> <td><%= person.email %></td> <td> <% if @extranet.connected?(person) %> - <%= link_to 'DƩconnecter', + <%= link_to 'DƩconnecter', disconnect_admin_communication_extranet_contacts_path( - extranet_id: @extranet.id, - objectId: person.id, + extranet_id: @extranet.id, + objectId: person.id, objectType: person.class ), class: button_classes_danger, method: :post %> <% else %> - <%= link_to 'Connecter', + <%= link_to 'Connecter', connect_admin_communication_extranet_contacts_path( - extranet_id: @extranet.id, - objectId: person.id, + extranet_id: @extranet.id, + objectId: person.id, objectType: person.class ), class: button_classes, @@ -35,9 +38,12 @@ </tbody> </table> </div> - <%= paginate @persons, theme: 'bootstrap-5', param_name: :persons_page %> + <%= paginate @people, theme: 'bootstrap-5', param_name: :persons_page %> <% end %> - <%= osuny_panel University::Organization.model_name.human(count: 2) do %> + <% action = link_to t('export'), + admin_communication_extranet_contacts_path(extranet_id: @extranet.id, export: 'organizations', format: :xlsx), + class: button_classes('ms-1') if can?(:show, University::Person) %> + <%= osuny_panel University::Organization.model_name.human(count: 2), action: action do %> <div class="table-responsive"> <table class="<%= table_classes%>"> <tbody> @@ -46,19 +52,19 @@ <td><%= link_to organization, [:admin, organization] %></td> <td> <% if @extranet.connected?(organization) %> - <%= link_to 'DƩconnecter', + <%= link_to 'DƩconnecter', disconnect_admin_communication_extranet_contacts_path( - extranet_id: @extranet.id, - objectId: organization.id, + extranet_id: @extranet.id, + objectId: organization.id, objectType: organization.class ), class: button_classes_danger, method: :post %> <% else %> - <%= link_to 'Connecter', + <%= link_to 'Connecter', connect_admin_communication_extranet_contacts_path( - extranet_id: @extranet.id, - objectId: organization.id, + extranet_id: @extranet.id, + objectId: organization.id, objectType: organization.class ), class: button_classes, @@ -72,4 +78,4 @@ </div> <%= paginate @organizations, theme: 'bootstrap-5', param_name: :organizations_page %> <% end %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/admin/communication/extranets/contacts/organizations.xlsx.axlsx b/app/views/admin/communication/extranets/contacts/organizations.xlsx.axlsx new file mode 100644 index 0000000000000000000000000000000000000000..a0e20d1940857097b2d9c4de0409c45f737f64b3 --- /dev/null +++ b/app/views/admin/communication/extranets/contacts/organizations.xlsx.axlsx @@ -0,0 +1,60 @@ +wb = xlsx_package.workbook +wb.add_worksheet(name: "index") do |sheet| + options = [ + University::Organization.human_attribute_name('name'), + University::Organization.human_attribute_name('address_name'), + University::Organization.human_attribute_name('address'), + University::Organization.human_attribute_name('address_additional'), + University::Organization.human_attribute_name('zipcode'), + University::Organization.human_attribute_name('city'), + University::Organization.human_attribute_name('country'), + University::Organization.human_attribute_name('kind'), + University::Organization.human_attribute_name('siren'), + University::Organization.human_attribute_name('phone'), + University::Organization.human_attribute_name('url'), + University::Organization.human_attribute_name('email'), + University::Organization.human_attribute_name('linkedin'), + University::Organization.human_attribute_name('twitter') + ] + + types = [ + :string, + :string, + :string, + :string, + :string, + :string, + :string, + :string, + :string, + :string, + :string, + :string, + :string, + :string, + :string + ] + + sheet.add_row options, types: Array.new(types.length) { |_| :string } + + @organizations.each do |organization| + infos = [ + organization.name, + organization.address_name, + organization.address, + organization.address_additional, + organization.zipcode, + organization.city, + organization.country_name, + organization.kind_i18n, + organization.siren, + organization.phone, + organization.url, + organization.email, + organization.linkedin, + organization.twitter.present? ? "@#{organization.twitter}" : '' + ] + + sheet.add_row infos, types: types + end +end diff --git a/app/views/admin/communication/extranets/contacts/people.xlsx.axlsx b/app/views/admin/communication/extranets/contacts/people.xlsx.axlsx new file mode 100644 index 0000000000000000000000000000000000000000..c140b04f01bedf73417b250998aaeba24e4b4ee3 --- /dev/null +++ b/app/views/admin/communication/extranets/contacts/people.xlsx.axlsx @@ -0,0 +1,62 @@ +wb = xlsx_package.workbook +wb.add_worksheet(name: "index") do |sheet| + options = [ + University::Person.human_attribute_name('last_name'), + University::Person.human_attribute_name('first_name'), + University::Person.human_attribute_name('email'), + University::Person.human_attribute_name('gender'), + University::Person.human_attribute_name('address'), + University::Person.human_attribute_name('zipcode'), + University::Person.human_attribute_name('city'), + University::Person.human_attribute_name('country'), + University::Person.human_attribute_name('birthdate'), + University::Person.human_attribute_name('phone_personal'), + University::Person.human_attribute_name('phone_professional'), + University::Person.human_attribute_name('phone_mobile'), + University::Person.human_attribute_name('url'), + University::Person.human_attribute_name('linkedin'), + University::Person.human_attribute_name('twitter') + ] + + types = [ + :string, + :string, + :string, + :string, + :string, + :string, + :string, + :string, + :string, + :string, + :string, + :string, + :string, + :string, + :string + ] + + sheet.add_row options, types: Array.new(types.length) { |_| :string } + + @people.each do |person| + infos = [ + person.last_name, + person.first_name, + person.email, + person.gender.present? ? t("activerecord.attributes.university/person.genders.#{person.gender}") : '', + person.address, + person.zipcode, + person.city, + person.country_name, + person.birthdate.present? ? l(person.birthdate, format: :birthday) : '', + person.phone_personal, + person.phone_professional, + person.phone_mobile, + person.url, + person.linkedin, + person.twitter.present? ? "@#{person.twitter}" : '' + ] + + sheet.add_row infos, types: types + end +end diff --git a/app/views/admin/education/schools/static.html.erb b/app/views/admin/education/schools/static.html.erb index bb1396b0e79a9e9e3f51b36b2821a731bf83d6e4..01bafc82144f5793d2658cc13da7e7ab18309292 100644 --- a/app/views/admin/education/schools/static.html.erb +++ b/app/views/admin/education/schools/static.html.erb @@ -9,7 +9,7 @@ zipcode: > city: > <%= @about.city %> country: > - <%= ISO3166::Country[@about.country].translations[@about.country.downcase] %> + <%= @about.country_common_name %> phone: > <%= @about.phone %> <% if administrator_involvements.any? %> diff --git a/app/views/admin/research/laboratories/static.html.erb b/app/views/admin/research/laboratories/static.html.erb index 01b70fa3db984a8df8b173f8ac1ed56dcd58aa4d..e294a824d91ba5419a878940eb7eeca6960545fe 100644 --- a/app/views/admin/research/laboratories/static.html.erb +++ b/app/views/admin/research/laboratories/static.html.erb @@ -8,5 +8,5 @@ zipcode: > city: > <%= @about.city %> country: > - <%= ISO3166::Country[@about.country].translations[@about.country.downcase] %> + <%= @about.country_common_name %> --- diff --git a/app/views/admin/university/organizations/show.html.erb b/app/views/admin/university/organizations/show.html.erb index 46dd34a5f1e7a11749586f6d6b25a1faf1b83bab..fdf5454779cb2c5be4806cf596f75e662efef0aa 100644 --- a/app/views/admin/university/organizations/show.html.erb +++ b/app/views/admin/university/organizations/show.html.erb @@ -26,7 +26,7 @@ <% if @organization.country.present? %> <div class="col-xxl-6"> <%= osuny_label University::Organization.human_attribute_name('country') %> - <p><%= ISO3166::Country[@organization.country].common_name %></p> + <p><%= @organization.country_name %></p> </div> <% end %> <% if @organization.geolocated? %> diff --git a/app/views/admin/university/people/_main_infos.html.erb b/app/views/admin/university/people/_main_infos.html.erb index caf29a011f6bd692f23ab23100d5f483841c730a..9211f6b14809bc4cfbae3d44673a34fb0d0f94eb 100644 --- a/app/views/admin/university/people/_main_infos.html.erb +++ b/app/views/admin/university/people/_main_infos.html.erb @@ -29,7 +29,7 @@ <p><%= l(person.birthdate, format: :birthday) %></p> </div> <% end %> - <% [:address, :zipcode, :city, :country].each do |property| %> + <% [:address, :zipcode, :city].each do |property| %> <% value = person.send property %> <% next if value.blank? %> <div class="col-md-6"> @@ -37,6 +37,12 @@ <p><%= value %></p> </div> <% end %> + <% if person.country.present? %> + <div class="col-md-6"> + <%= osuny_label University::Person.human_attribute_name(:country) %> + <p><%= person.country_name %></p> + </div> + <% end %> </div> <% unless person.biography.blank? %> <%= osuny_label University::Person.human_attribute_name('biography') %> diff --git a/app/views/extranet/organizations/show.html.erb b/app/views/extranet/organizations/show.html.erb index 0c6394a26b6b4c23d11efb0fd894d7e380ec959b..0042d2c29493816f9eccde170f0460bc4514713a 100644 --- a/app/views/extranet/organizations/show.html.erb +++ b/app/views/extranet/organizations/show.html.erb @@ -56,7 +56,7 @@ <% if @organization.country.present? %> <div class="col-xxl-6"> <%= osuny_label University::Organization.human_attribute_name('country') %> - <p><%= ISO3166::Country[@organization.country].common_name %></p> + <p><%= @organization.country_common_name %></p> </div> <% end %> <% if @organization.geolocated? %> diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index e7f0e9b1057fe98db3e11af11878db810b5d9ec4..07ca293a6920106c19334d1b478c93f9f6ea124a 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,6 +1,3 @@ # Be sure to restart your server when you modify this file. - -# Add new mime types for use in respond_to blocks: -# Mime::Type.register "text/richtext", :rtf -# Mime::Type.register "text/css", :css +Mime::Type.register "application/xls", :xlsx Mime::Type.register "application/xml", :xml, %w( text/xml application/x-xml ) diff --git a/config/locales/en.yml b/config/locales/en.yml index 56de4b0f1de4e3d1c3fffac4742cb6e1bf294c56..f06aaeeba4ceb0837df7712edc899d0aa6c93c2f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -173,6 +173,7 @@ en: finished: Finished finished_with_errors: Finished with errors pending: Pending + export: Export (xlsx) false: No featured_image: title: Image diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 711fa805dbedff947b0f666147be92f0b97f1ddb..f351c0fcd1bedd3c4f0e5b72ac865e71071d899f 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -173,6 +173,7 @@ fr: finished: TraitƩ finished_with_errors: TraitƩ avec des erreurs pending: En cours de traitement + export: Exporter (xlsx) false: Non featured_image: title: Image diff --git a/db/schema.rb b/db/schema.rb index 040c76bc824124dd0a1628dc2bb33a9b9b82a51f..36ef9f0312d8396ce0b564e9e59cc8b9dc1d1d73 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,13 +10,13 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do +ActiveRecord::Schema[7.0].define(version: 2023_03_09_143644) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" enable_extension "unaccent" - create_table "action_text_rich_texts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "action_text_rich_texts", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.string "name", null: false t.text "body" t.string "record_type", null: false @@ -26,7 +26,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true end - create_table "active_storage_attachments", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "active_storage_attachments", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false t.uuid "record_id", null: false @@ -36,7 +36,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true end - create_table "active_storage_blobs", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "active_storage_blobs", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.string "key", null: false t.string "filename", null: false t.string "content_type" @@ -50,13 +50,13 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_active_storage_blobs_on_university_id" end - create_table "active_storage_variant_records", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "active_storage_variant_records", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "blob_id", null: false t.string "variation_digest", null: false t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true end - create_table "administration_qualiopi_criterions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "administration_qualiopi_criterions", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.integer "number" t.text "name" t.text "description" @@ -64,7 +64,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.datetime "updated_at", null: false end - create_table "administration_qualiopi_indicators", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "administration_qualiopi_indicators", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "criterion_id", null: false t.integer "number" t.text "name" @@ -78,7 +78,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["criterion_id"], name: "index_administration_qualiopi_indicators_on_criterion_id" end - create_table "communication_blocks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_blocks", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "about_type" t.uuid "about_id" @@ -148,7 +148,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_communication_extranet_posts_on_university_id" end - create_table "communication_extranets", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_extranets", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.string "name" t.uuid "university_id", null: false t.string "host" @@ -176,11 +176,12 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.text "home_sentence" t.text "sass" t.text "css" + t.boolean "allow_experiences_modification", default: true t.index ["about_type", "about_id"], name: "index_communication_extranets_on_about" t.index ["university_id"], name: "index_communication_extranets_on_university_id" end - create_table "communication_website_categories", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_categories", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "communication_website_id", null: false t.string "name" @@ -214,22 +215,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["communication_website_post_id", "communication_website_category_id"], name: "post_category" end - create_table "communication_website_connections", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "university_id", null: false - t.uuid "website_id", null: false - t.string "object_type", null: false - t.uuid "object_id", null: false - t.string "source_type" - t.uuid "source_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["object_type", "object_id"], name: "index_communication_website_connections_on_object" - t.index ["source_type", "source_id"], name: "index_communication_website_connections_on_source" - t.index ["university_id"], name: "index_communication_website_connections_on_university_id" - t.index ["website_id"], name: "index_communication_website_connections_on_website_id" - end - - create_table "communication_website_git_files", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_git_files", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.string "previous_path" t.string "about_type", null: false t.uuid "about_id", null: false @@ -241,7 +227,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["website_id"], name: "index_communication_website_git_files_on_website_id" end - create_table "communication_website_imported_authors", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_imported_authors", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false t.uuid "author_id" @@ -257,7 +243,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["website_id"], name: "idx_communication_website_imported_auth_on_website" end - create_table "communication_website_imported_categories", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_imported_categories", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false t.uuid "category_id" @@ -275,7 +261,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["website_id"], name: "idx_communication_website_imported_cat_on_website" end - create_table "communication_website_imported_media", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_imported_media", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.string "identifier" t.jsonb "data" t.text "file_url" @@ -290,7 +276,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["website_id"], name: "index_communication_website_imported_media_on_website_id" end - create_table "communication_website_imported_pages", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_imported_pages", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false t.uuid "page_id" @@ -314,7 +300,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["website_id"], name: "index_communication_website_imported_pages_on_website_id" end - create_table "communication_website_imported_posts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_imported_posts", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false t.uuid "post_id" @@ -339,7 +325,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["website_id"], name: "index_communication_website_imported_posts_on_website_id" end - create_table "communication_website_imported_websites", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_imported_websites", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false t.integer "status", default: 0 @@ -349,7 +335,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["website_id"], name: "index_communication_website_imported_websites_on_website_id" end - create_table "communication_website_menu_items", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_menu_items", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false t.uuid "menu_id", null: false @@ -369,7 +355,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["website_id"], name: "index_communication_website_menu_items_on_website_id" end - create_table "communication_website_menus", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_menus", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "communication_website_id", null: false t.string "title" @@ -385,7 +371,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_communication_website_menus_on_university_id" end - create_table "communication_website_pages", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_pages", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "communication_website_id", null: false t.string "title" @@ -400,10 +386,10 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.text "github_path" t.string "featured_image_alt" t.text "text" + t.text "summary" t.string "breadcrumb_title" t.text "header_text" t.integer "kind" - t.text "summary" t.string "bodyclass" t.uuid "language_id", null: false t.text "featured_image_credit" @@ -431,7 +417,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["website_id"], name: "index_communication_website_permalinks_on_website_id" end - create_table "communication_website_posts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_posts", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "communication_website_id", null: false t.string "title" @@ -457,7 +443,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_communication_website_posts_on_university_id" end - create_table "communication_websites", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_websites", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "name" t.string "url" @@ -509,7 +495,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["priority", "run_at"], name: "delayed_jobs_priority" end - create_table "education_academic_years", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "education_academic_years", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.integer "year" t.datetime "created_at", null: false @@ -524,7 +510,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_person_id", "education_academic_year_id"], name: "index_person_academic_year" end - create_table "education_cohorts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "education_cohorts", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "program_id", null: false t.uuid "academic_year_id", null: false @@ -545,7 +531,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_person_id", "education_cohort_id"], name: "index_person_cohort" end - create_table "education_diplomas", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "education_diplomas", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.string "name" t.string "short_name" t.integer "level", default: 0 @@ -559,7 +545,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_education_diplomas_on_university_id" end - create_table "education_programs", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "education_programs", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "name" t.integer "capacity" @@ -619,7 +605,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["education_program_id", "user_id"], name: "index_education_programs_users_on_program_id_and_user_id" end - create_table "education_schools", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "education_schools", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "name" t.string "address" @@ -634,7 +620,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_education_schools_on_university_id" end - create_table "imports", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "imports", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.integer "number_of_lines" t.jsonb "processing_errors" t.integer "kind" @@ -647,7 +633,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["user_id"], name: "index_imports_on_user_id" end - create_table "languages", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "languages", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.string "name" t.string "iso_code" t.datetime "created_at", null: false @@ -714,7 +700,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_research_journal_paper_kinds_on_university_id" end - create_table "research_journal_papers", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "research_journal_papers", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.string "title" t.datetime "published_at", precision: nil t.uuid "university_id", null: false @@ -747,7 +733,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["researcher_id"], name: "index_research_journal_papers_researchers_on_researcher_id" end - create_table "research_journal_volumes", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "research_journal_volumes", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "research_journal_id", null: false t.string "title" @@ -767,7 +753,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_research_journal_volumes_on_university_id" end - create_table "research_journals", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "research_journals", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "title" t.text "meta_description" @@ -778,7 +764,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_research_journals_on_university_id" end - create_table "research_laboratories", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "research_laboratories", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "name" t.string "address" @@ -790,7 +776,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_research_laboratories_on_university_id" end - create_table "research_laboratory_axes", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "research_laboratory_axes", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "research_laboratory_id", null: false t.string "name" @@ -804,7 +790,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_research_laboratory_axes_on_university_id" end - create_table "research_theses", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "research_theses", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "research_laboratory_id", null: false t.uuid "author_id", null: false @@ -822,7 +808,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_research_theses_on_university_id" end - create_table "universities", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "universities", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.string "name" t.string "identifier" t.string "address" @@ -849,7 +835,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["default_language_id"], name: "index_universities_on_default_language_id" end - create_table "university_organizations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "university_organizations", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "name" t.string "long_name" @@ -880,7 +866,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_university_organizations_on_university_id" end - create_table "university_people", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "university_people", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "user_id" t.string "last_name" @@ -921,7 +907,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["user_id"], name: "index_university_people_on_user_id" end - create_table "university_person_experiences", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "university_person_experiences", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "person_id", null: false t.uuid "organization_id", null: false @@ -935,7 +921,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_university_person_experiences_on_university_id" end - create_table "university_person_involvements", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "university_person_involvements", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "person_id", null: false t.integer "kind" @@ -950,7 +936,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_university_person_involvements_on_university_id" end - create_table "university_roles", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "university_roles", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "target_type" t.uuid "target_id" @@ -962,7 +948,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_university_roles_on_university_id" end - create_table "users", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "users", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "first_name" t.string "last_name" @@ -1029,8 +1015,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do add_foreign_key "communication_website_categories", "education_programs", column: "program_id" add_foreign_key "communication_website_categories", "languages" add_foreign_key "communication_website_categories", "universities" - add_foreign_key "communication_website_connections", "communication_websites", column: "website_id" - add_foreign_key "communication_website_connections", "universities" add_foreign_key "communication_website_git_files", "communication_websites", column: "website_id" add_foreign_key "communication_website_imported_authors", "communication_website_imported_websites", column: "website_id" add_foreign_key "communication_website_imported_authors", "universities" diff --git a/test/fixtures/communication/extranets.yml b/test/fixtures/communication/extranets.yml index c4a72564511a4905256b44eff1b90d9ad95d76db..5b00f559b78ac19b9a3871e2736923e92e325c4b 100644 --- a/test/fixtures/communication/extranets.yml +++ b/test/fixtures/communication/extranets.yml @@ -2,34 +2,35 @@ # # Table name: communication_extranets # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# color :string -# cookies_policy :text -# css :text -# feature_alumni :boolean default(FALSE) -# feature_contacts :boolean default(FALSE) -# feature_jobs :boolean default(FALSE) -# feature_library :boolean default(FALSE) -# feature_posts :boolean default(FALSE) -# has_sso :boolean default(FALSE) -# home_sentence :text -# host :string -# name :string -# privacy_policy :text -# registration_contact :string -# sass :text -# sso_button_label :string -# sso_cert :text -# sso_mapping :jsonb -# sso_name_identifier_format :string -# sso_provider :integer default("saml") -# sso_target_url :string -# terms :text -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# allow_experiences_modification :boolean default(TRUE) +# color :string +# cookies_policy :text +# css :text +# feature_alumni :boolean default(FALSE) +# feature_contacts :boolean default(FALSE) +# feature_jobs :boolean default(FALSE) +# feature_library :boolean default(FALSE) +# feature_posts :boolean default(FALSE) +# has_sso :boolean default(FALSE) +# home_sentence :text +# host :string +# name :string +# privacy_policy :text +# registration_contact :string +# sass :text +# sso_button_label :string +# sso_cert :text +# sso_mapping :jsonb +# sso_name_identifier_format :string +# sso_provider :integer default("saml") +# sso_target_url :string +# terms :text +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# university_id :uuid not null, indexed # # Indexes # diff --git a/test/models/communication/extranet_test.rb b/test/models/communication/extranet_test.rb index 72be11939515c0927e5c3266698692eae000ee5a..0fbfb1c43e253bdc46da936417e5b507126faf56 100644 --- a/test/models/communication/extranet_test.rb +++ b/test/models/communication/extranet_test.rb @@ -2,34 +2,35 @@ # # Table name: communication_extranets # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# color :string -# cookies_policy :text -# css :text -# feature_alumni :boolean default(FALSE) -# feature_contacts :boolean default(FALSE) -# feature_jobs :boolean default(FALSE) -# feature_library :boolean default(FALSE) -# feature_posts :boolean default(FALSE) -# has_sso :boolean default(FALSE) -# home_sentence :text -# host :string -# name :string -# privacy_policy :text -# registration_contact :string -# sass :text -# sso_button_label :string -# sso_cert :text -# sso_mapping :jsonb -# sso_name_identifier_format :string -# sso_provider :integer default("saml") -# sso_target_url :string -# terms :text -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# allow_experiences_modification :boolean default(TRUE) +# color :string +# cookies_policy :text +# css :text +# feature_alumni :boolean default(FALSE) +# feature_contacts :boolean default(FALSE) +# feature_jobs :boolean default(FALSE) +# feature_library :boolean default(FALSE) +# feature_posts :boolean default(FALSE) +# has_sso :boolean default(FALSE) +# home_sentence :text +# host :string +# name :string +# privacy_policy :text +# registration_contact :string +# sass :text +# sso_button_label :string +# sso_cert :text +# sso_mapping :jsonb +# sso_name_identifier_format :string +# sso_provider :integer default("saml") +# sso_target_url :string +# terms :text +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# university_id :uuid not null, indexed # # Indexes #