From abc48583411f5f545088f458d231f6aec98f1e66 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Wed, 18 Jan 2023 17:11:43 +0100 Subject: [PATCH] mastodon --- .../university/organizations_controller.rb | 2 +- .../admin/university/people_controller.rb | 2 +- app/models/university/organization.rb | 1 + app/models/university/person.rb | 68 ++++++++++--------- app/models/university/person/administrator.rb | 68 ++++++++++--------- app/models/university/person/alumnus.rb | 68 ++++++++++--------- app/models/university/person/author.rb | 68 ++++++++++--------- app/models/university/person/researcher.rb | 68 ++++++++++--------- app/models/university/person/teacher.rb | 68 ++++++++++--------- app/services/contact_details/mastodon.rb | 2 + .../university/organizations/_form.html.erb | 1 + .../university/organizations/show.html.erb | 15 +++- .../university/organizations/static.html.erb | 1 + .../admin/university/people/_form.html.erb | 1 + .../university/people/_main_infos.html.erb | 6 +- .../admin/university/people/static.html.erb | 1 + ...d_mastodon_to_persons_and_organizations.rb | 6 ++ db/schema.rb | 35 +++++++++- test/fixtures/university/organizations.yml | 1 + test/models/university/organization_test.rb | 1 + 20 files changed, 285 insertions(+), 198 deletions(-) create mode 100644 app/services/contact_details/mastodon.rb create mode 100644 db/migrate/20230118155630_add_mastodon_to_persons_and_organizations.rb diff --git a/app/controllers/admin/university/organizations_controller.rb b/app/controllers/admin/university/organizations_controller.rb index bdf31d437..3f56e5032 100644 --- a/app/controllers/admin/university/organizations_controller.rb +++ b/app/controllers/admin/university/organizations_controller.rb @@ -71,7 +71,7 @@ class Admin::University::OrganizationsController < Admin::University::Applicatio .permit( :name, :long_name, :slug, :meta_description, :summary, :active, :siren, :kind, :address, :zipcode, :city, :country, :text, - :url, :phone, :email, :linkedin, :twitter, + :url, :phone, :email, :linkedin, :twitter, :mastodon, :logo, :logo_delete, :logo_infos, :logo_on_dark_background, :logo_on_dark_background_delete, :logo_on_dark_background_infos, ) diff --git a/app/controllers/admin/university/people_controller.rb b/app/controllers/admin/university/people_controller.rb index 68c9d699b..0fde20c47 100644 --- a/app/controllers/admin/university/people_controller.rb +++ b/app/controllers/admin/university/people_controller.rb @@ -76,7 +76,7 @@ class Admin::University::PeopleController < Admin::University::ApplicationContro :address, :zipcode, :city, :country, :meta_description, :summary, :biography, :picture, :picture_delete, :picture_infos, - :habilitation, :tenure, :url, :linkedin, :twitter, + :habilitation, :tenure, :url, :linkedin, :twitter, :mastodon, :is_researcher, :is_teacher, :is_administration, :is_alumnus, :user_id ).merge(university_id: current_university.id) diff --git a/app/models/university/organization.rb b/app/models/university/organization.rb index ea328fbc3..46a5f668e 100644 --- a/app/models/university/organization.rb +++ b/app/models/university/organization.rb @@ -11,6 +11,7 @@ # kind :integer default("company") # linkedin :string # long_name :string +# mastodon :string # meta_description :text # name :string # nic :string diff --git a/app/models/university/person.rb b/app/models/university/person.rb index 4a7dc6a74..9fd05ac1e 100644 --- a/app/models/university/person.rb +++ b/app/models/university/person.rb @@ -2,38 +2,42 @@ # # Table name: university_people # -# id :uuid not null, primary key -# address :string -# biography :text -# birthdate :date -# city :string -# country :string -# email :string -# first_name :string -# gender :integer -# habilitation :boolean default(FALSE) -# is_administration :boolean -# is_alumnus :boolean default(FALSE) -# is_author :boolean -# is_researcher :boolean -# is_teacher :boolean -# last_name :string -# linkedin :string -# meta_description :text -# name :string -# phone_mobile :string -# phone_personal :string -# phone_professional :string -# slug :string -# summary :text -# tenure :boolean default(FALSE) -# twitter :string -# url :string -# zipcode :string -# created_at :datetime not null -# updated_at :datetime not null -# university_id :uuid not null, indexed -# user_id :uuid indexed +# id :uuid not null, primary key +# address :string +# biography :text +# birthdate :date +# city :string +# country :string +# email :string +# first_name :string +# gender :integer +# habilitation :boolean default(FALSE) +# hal_doc_identifier :string +# hal_form_identifier :string +# hal_person_identifier :string +# is_administration :boolean +# is_alumnus :boolean default(FALSE) +# is_author :boolean +# is_researcher :boolean +# is_teacher :boolean +# last_name :string +# linkedin :string +# mastodon :string +# meta_description :text +# name :string +# phone_mobile :string +# phone_personal :string +# phone_professional :string +# slug :string +# summary :text +# tenure :boolean default(FALSE) +# twitter :string +# url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# university_id :uuid not null, indexed +# user_id :uuid indexed # # Indexes # diff --git a/app/models/university/person/administrator.rb b/app/models/university/person/administrator.rb index 7344064b8..8532be880 100644 --- a/app/models/university/person/administrator.rb +++ b/app/models/university/person/administrator.rb @@ -2,38 +2,42 @@ # # Table name: university_people # -# id :uuid not null, primary key -# address :string -# biography :text -# birthdate :date -# city :string -# country :string -# email :string -# first_name :string -# gender :integer -# habilitation :boolean default(FALSE) -# is_administration :boolean -# is_alumnus :boolean default(FALSE) -# is_author :boolean -# is_researcher :boolean -# is_teacher :boolean -# last_name :string -# linkedin :string -# meta_description :text -# name :string -# phone_mobile :string -# phone_personal :string -# phone_professional :string -# slug :string -# summary :text -# tenure :boolean default(FALSE) -# twitter :string -# url :string -# zipcode :string -# created_at :datetime not null -# updated_at :datetime not null -# university_id :uuid not null, indexed -# user_id :uuid indexed +# id :uuid not null, primary key +# address :string +# biography :text +# birthdate :date +# city :string +# country :string +# email :string +# first_name :string +# gender :integer +# habilitation :boolean default(FALSE) +# hal_doc_identifier :string +# hal_form_identifier :string +# hal_person_identifier :string +# is_administration :boolean +# is_alumnus :boolean default(FALSE) +# is_author :boolean +# is_researcher :boolean +# is_teacher :boolean +# last_name :string +# linkedin :string +# mastodon :string +# meta_description :text +# name :string +# phone_mobile :string +# phone_personal :string +# phone_professional :string +# slug :string +# summary :text +# tenure :boolean default(FALSE) +# twitter :string +# url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# university_id :uuid not null, indexed +# user_id :uuid indexed # # Indexes # diff --git a/app/models/university/person/alumnus.rb b/app/models/university/person/alumnus.rb index 768ca1426..729d7b212 100644 --- a/app/models/university/person/alumnus.rb +++ b/app/models/university/person/alumnus.rb @@ -2,38 +2,42 @@ # # Table name: university_people # -# id :uuid not null, primary key -# address :string -# biography :text -# birthdate :date -# city :string -# country :string -# email :string -# first_name :string -# gender :integer -# habilitation :boolean default(FALSE) -# is_administration :boolean -# is_alumnus :boolean default(FALSE) -# is_author :boolean -# is_researcher :boolean -# is_teacher :boolean -# last_name :string -# linkedin :string -# meta_description :text -# name :string -# phone_mobile :string -# phone_personal :string -# phone_professional :string -# slug :string -# summary :text -# tenure :boolean default(FALSE) -# twitter :string -# url :string -# zipcode :string -# created_at :datetime not null -# updated_at :datetime not null -# university_id :uuid not null, indexed -# user_id :uuid indexed +# id :uuid not null, primary key +# address :string +# biography :text +# birthdate :date +# city :string +# country :string +# email :string +# first_name :string +# gender :integer +# habilitation :boolean default(FALSE) +# hal_doc_identifier :string +# hal_form_identifier :string +# hal_person_identifier :string +# is_administration :boolean +# is_alumnus :boolean default(FALSE) +# is_author :boolean +# is_researcher :boolean +# is_teacher :boolean +# last_name :string +# linkedin :string +# mastodon :string +# meta_description :text +# name :string +# phone_mobile :string +# phone_personal :string +# phone_professional :string +# slug :string +# summary :text +# tenure :boolean default(FALSE) +# twitter :string +# url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# university_id :uuid not null, indexed +# user_id :uuid indexed # # Indexes # diff --git a/app/models/university/person/author.rb b/app/models/university/person/author.rb index 71dbd704e..3a875d33f 100644 --- a/app/models/university/person/author.rb +++ b/app/models/university/person/author.rb @@ -2,38 +2,42 @@ # # Table name: university_people # -# id :uuid not null, primary key -# address :string -# biography :text -# birthdate :date -# city :string -# country :string -# email :string -# first_name :string -# gender :integer -# habilitation :boolean default(FALSE) -# is_administration :boolean -# is_alumnus :boolean default(FALSE) -# is_author :boolean -# is_researcher :boolean -# is_teacher :boolean -# last_name :string -# linkedin :string -# meta_description :text -# name :string -# phone_mobile :string -# phone_personal :string -# phone_professional :string -# slug :string -# summary :text -# tenure :boolean default(FALSE) -# twitter :string -# url :string -# zipcode :string -# created_at :datetime not null -# updated_at :datetime not null -# university_id :uuid not null, indexed -# user_id :uuid indexed +# id :uuid not null, primary key +# address :string +# biography :text +# birthdate :date +# city :string +# country :string +# email :string +# first_name :string +# gender :integer +# habilitation :boolean default(FALSE) +# hal_doc_identifier :string +# hal_form_identifier :string +# hal_person_identifier :string +# is_administration :boolean +# is_alumnus :boolean default(FALSE) +# is_author :boolean +# is_researcher :boolean +# is_teacher :boolean +# last_name :string +# linkedin :string +# mastodon :string +# meta_description :text +# name :string +# phone_mobile :string +# phone_personal :string +# phone_professional :string +# slug :string +# summary :text +# tenure :boolean default(FALSE) +# twitter :string +# url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# university_id :uuid not null, indexed +# user_id :uuid indexed # # Indexes # diff --git a/app/models/university/person/researcher.rb b/app/models/university/person/researcher.rb index db8d3308b..2a36ac064 100644 --- a/app/models/university/person/researcher.rb +++ b/app/models/university/person/researcher.rb @@ -2,38 +2,42 @@ # # Table name: university_people # -# id :uuid not null, primary key -# address :string -# biography :text -# birthdate :date -# city :string -# country :string -# email :string -# first_name :string -# gender :integer -# habilitation :boolean default(FALSE) -# is_administration :boolean -# is_alumnus :boolean default(FALSE) -# is_author :boolean -# is_researcher :boolean -# is_teacher :boolean -# last_name :string -# linkedin :string -# meta_description :text -# name :string -# phone_mobile :string -# phone_personal :string -# phone_professional :string -# slug :string -# summary :text -# tenure :boolean default(FALSE) -# twitter :string -# url :string -# zipcode :string -# created_at :datetime not null -# updated_at :datetime not null -# university_id :uuid not null, indexed -# user_id :uuid indexed +# id :uuid not null, primary key +# address :string +# biography :text +# birthdate :date +# city :string +# country :string +# email :string +# first_name :string +# gender :integer +# habilitation :boolean default(FALSE) +# hal_doc_identifier :string +# hal_form_identifier :string +# hal_person_identifier :string +# is_administration :boolean +# is_alumnus :boolean default(FALSE) +# is_author :boolean +# is_researcher :boolean +# is_teacher :boolean +# last_name :string +# linkedin :string +# mastodon :string +# meta_description :text +# name :string +# phone_mobile :string +# phone_personal :string +# phone_professional :string +# slug :string +# summary :text +# tenure :boolean default(FALSE) +# twitter :string +# url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# university_id :uuid not null, indexed +# user_id :uuid indexed # # Indexes # diff --git a/app/models/university/person/teacher.rb b/app/models/university/person/teacher.rb index 6dae6e68a..aaf4ac554 100644 --- a/app/models/university/person/teacher.rb +++ b/app/models/university/person/teacher.rb @@ -2,38 +2,42 @@ # # Table name: university_people # -# id :uuid not null, primary key -# address :string -# biography :text -# birthdate :date -# city :string -# country :string -# email :string -# first_name :string -# gender :integer -# habilitation :boolean default(FALSE) -# is_administration :boolean -# is_alumnus :boolean default(FALSE) -# is_author :boolean -# is_researcher :boolean -# is_teacher :boolean -# last_name :string -# linkedin :string -# meta_description :text -# name :string -# phone_mobile :string -# phone_personal :string -# phone_professional :string -# slug :string -# summary :text -# tenure :boolean default(FALSE) -# twitter :string -# url :string -# zipcode :string -# created_at :datetime not null -# updated_at :datetime not null -# university_id :uuid not null, indexed -# user_id :uuid indexed +# id :uuid not null, primary key +# address :string +# biography :text +# birthdate :date +# city :string +# country :string +# email :string +# first_name :string +# gender :integer +# habilitation :boolean default(FALSE) +# hal_doc_identifier :string +# hal_form_identifier :string +# hal_person_identifier :string +# is_administration :boolean +# is_alumnus :boolean default(FALSE) +# is_author :boolean +# is_researcher :boolean +# is_teacher :boolean +# last_name :string +# linkedin :string +# mastodon :string +# meta_description :text +# name :string +# phone_mobile :string +# phone_personal :string +# phone_professional :string +# slug :string +# summary :text +# tenure :boolean default(FALSE) +# twitter :string +# url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# university_id :uuid not null, indexed +# user_id :uuid indexed # # Indexes # diff --git a/app/services/contact_details/mastodon.rb b/app/services/contact_details/mastodon.rb new file mode 100644 index 000000000..51f60f796 --- /dev/null +++ b/app/services/contact_details/mastodon.rb @@ -0,0 +1,2 @@ +class ContactDetails::Mastodon < ContactDetails::Website +end \ No newline at end of file diff --git a/app/views/admin/university/organizations/_form.html.erb b/app/views/admin/university/organizations/_form.html.erb index 27ff1003e..2332c6f6e 100644 --- a/app/views/admin/university/organizations/_form.html.erb +++ b/app/views/admin/university/organizations/_form.html.erb @@ -38,6 +38,7 @@ <%= f.input :email %> <%= f.input :linkedin %> <%= f.input :twitter %> + <%= f.input :mastodon %> </div> </div> </div> diff --git a/app/views/admin/university/organizations/show.html.erb b/app/views/admin/university/organizations/show.html.erb index 69532f016..3bb0d28ad 100644 --- a/app/views/admin/university/organizations/show.html.erb +++ b/app/views/admin/university/organizations/show.html.erb @@ -21,7 +21,12 @@ <div class="card-body"> <div class="row"> <div class="col-md-6"> - <% [:address, :zipcode, :city, :country].each do |property| %> + <% [ + :address, + :zipcode, + :city, + :country + ].each do |property| %> <% value = @organization.send property %> <% next if value.blank? %> <h3 class="h5"> @@ -39,7 +44,13 @@ @organization.url, target: :_blank %></p> <% end %> - <% [:phone, :email, :linkedin, :twitter].each do |property| %> + <% [ + :phone, + :email, + :linkedin, + :twitter, + :mastodon + ].each do |property| %> <% value = @organization.send property %> <% next if value.blank? %> <h3 class="h5"> diff --git a/app/views/admin/university/organizations/static.html.erb b/app/views/admin/university/organizations/static.html.erb index 5f3c340a5..50fe16931 100644 --- a/app/views/admin/university/organizations/static.html.erb +++ b/app/views/admin/university/organizations/static.html.erb @@ -36,6 +36,7 @@ contact_details: <%= render 'admin/application/static/contact_detail', variable: :website, data: @about.url, kind: ContactDetails::Website %> <%= render 'admin/application/static/contact_detail', variable: :linkedin, data: @about.linkedin, kind: ContactDetails::Linkedin %> <%= render 'admin/application/static/contact_detail', variable: :twitter, data: @about.twitter, kind: ContactDetails::Twitter %> +<%= render 'admin/application/static/contact_detail', variable: :mastodon, data: @about.mastodon, kind: ContactDetails::Mastodon %> <%= render 'admin/application/static/contact_detail', variable: :phone, data: @about.phone, kind: ContactDetails::Phone %> <%= render 'admin/application/static/contact_detail', variable: :email, data: @about.email, kind: ContactDetails::Email %> <% if @about.logo.attached? %> diff --git a/app/views/admin/university/people/_form.html.erb b/app/views/admin/university/people/_form.html.erb index eb779753b..1c96a3da2 100644 --- a/app/views/admin/university/people/_form.html.erb +++ b/app/views/admin/university/people/_form.html.erb @@ -91,6 +91,7 @@ </div> <div class="col-md-6"> <%= f.input :twitter %> + <%= f.input :mastodon %> </div> </div> </div> diff --git a/app/views/admin/university/people/_main_infos.html.erb b/app/views/admin/university/people/_main_infos.html.erb index c5ba7226d..6ab39d44f 100644 --- a/app/views/admin/university/people/_main_infos.html.erb +++ b/app/views/admin/university/people/_main_infos.html.erb @@ -54,7 +54,11 @@ <% end %> <% unless person.twitter.blank? %> <h3 class="h5"><%= University::Person.human_attribute_name('twitter') %></h3> - <%= link_to person.twitter, "https://twitter.com/#{person.twitter}", target: '_blank' %> + <p><%= link_to person.twitter, "https://twitter.com/#{person.twitter}", target: '_blank' %></p> + <% end %> + <% unless person.mastodon.blank? %> + <h3 class="h5"><%= University::Person.human_attribute_name('mastodon') %></h3> + <p><%= link_to person.mastodon, person.mastodon, target: '_blank' %></p> <% end %> </div> </div> diff --git a/app/views/admin/university/people/static.html.erb b/app/views/admin/university/people/static.html.erb index 9aea1854f..5c3cb9a62 100644 --- a/app/views/admin/university/people/static.html.erb +++ b/app/views/admin/university/people/static.html.erb @@ -27,6 +27,7 @@ contact_details: <%= render 'admin/application/static/contact_detail', variable: :website, data: @about.url, kind: ContactDetails::Website %> <%= render 'admin/application/static/contact_detail', variable: :linkedin, data: @about.linkedin, kind: ContactDetails::Linkedin %> <%= render 'admin/application/static/contact_detail', variable: :twitter, data: @about.twitter, kind: ContactDetails::Twitter %> +<%= render 'admin/application/static/contact_detail', variable: :mastodon, data: @about.mastodon, kind: ContactDetails::Mastodon %> <%= render 'admin/application/static/contact_detail', variable: :phone, data: @about.phone_mobile, kind: ContactDetails::Phone %> <%= render 'admin/application/static/contact_detail', variable: :email, data: @about.email, kind: ContactDetails::Email %> <% if @about.best_picture.attached? %> diff --git a/db/migrate/20230118155630_add_mastodon_to_persons_and_organizations.rb b/db/migrate/20230118155630_add_mastodon_to_persons_and_organizations.rb new file mode 100644 index 000000000..200bf8065 --- /dev/null +++ b/db/migrate/20230118155630_add_mastodon_to_persons_and_organizations.rb @@ -0,0 +1,6 @@ +class AddMastodonToPersonsAndOrganizations < ActiveRecord::Migration[7.0] + def change + add_column :university_people, :mastodon, :string + add_column :university_organizations, :mastodon, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 042e3b820..317c9d831 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_01_12_151136) do +ActiveRecord::Schema[7.0].define(version: 2023_01_18_155630) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -639,6 +639,13 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_12_151136) do t.index ["university_id"], name: "index_research_laboratories_on_university_id" end + create_table "research_laboratories_publications", id: false, force: :cascade do |t| + t.uuid "research_publication_id", null: false + t.uuid "research_laboratory_id", null: false + t.index ["research_laboratory_id", "research_publication_id"], name: "index_laboratory_publication" + t.index ["research_publication_id", "research_laboratory_id"], name: "index_publication_laboratory" + end + 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 @@ -653,6 +660,27 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_12_151136) do t.index ["university_id"], name: "index_research_laboratory_axes_on_university_id" end + create_table "research_publications", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.string "docid" + t.jsonb "data" + t.string "title" + t.string "url" + t.string "ref" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "hal_url" + t.date "publication_date" + t.string "doi" + t.string "slug" + end + + create_table "research_publications_university_people", id: false, force: :cascade do |t| + t.uuid "research_publication_id", null: false + t.uuid "university_person_id", null: false + t.index ["research_publication_id", "university_person_id"], name: "index_publication_person" + t.index ["university_person_id", "research_publication_id"], name: "index_person_publication" + end + 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 @@ -719,6 +747,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_12_151136) do t.text "summary" t.string "twitter" t.string "linkedin" + t.string "mastodon" t.index ["university_id"], name: "index_university_organizations_on_university_id" end @@ -754,6 +783,10 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_12_151136) do t.string "zipcode" t.string "city" t.string "country" + t.string "hal_person_identifier" + t.string "hal_doc_identifier" + t.string "hal_form_identifier" + t.string "mastodon" t.index ["university_id"], name: "index_university_people_on_university_id" t.index ["user_id"], name: "index_university_people_on_user_id" end diff --git a/test/fixtures/university/organizations.yml b/test/fixtures/university/organizations.yml index 7bad432bc..a684cda0b 100644 --- a/test/fixtures/university/organizations.yml +++ b/test/fixtures/university/organizations.yml @@ -11,6 +11,7 @@ # kind :integer default("company") # linkedin :string # long_name :string +# mastodon :string # meta_description :text # name :string # nic :string diff --git a/test/models/university/organization_test.rb b/test/models/university/organization_test.rb index 051333211..56f0523c1 100644 --- a/test/models/university/organization_test.rb +++ b/test/models/university/organization_test.rb @@ -11,6 +11,7 @@ # kind :integer default("company") # linkedin :string # long_name :string +# mastodon :string # meta_description :text # name :string # nic :string -- GitLab