diff --git a/app/controllers/admin/administration/members_controller.rb b/app/controllers/admin/administration/members_controller.rb index fb2384cad42f738c5bbd370eacb4073d9b0e5246..b683ef4b2dbb3f940a576022c6b3e4172a9b433c 100644 --- a/app/controllers/admin/administration/members_controller.rb +++ b/app/controllers/admin/administration/members_controller.rb @@ -56,7 +56,7 @@ class Admin::Administration::MembersController < Admin::Administration::Applicat def member_params params.require(:administration_member) - .permit(:first_name, :last_name, :biography, :slug, :user_id, + .permit(:first_name, :last_name, :email, :phone, :biography, :slug, :user_id, :is_author, :is_researcher, :is_teacher, :is_administrative) .merge(university_id: current_university.id) end diff --git a/app/models/administration/member.rb b/app/models/administration/member.rb index c8b5a5364faaff43fb7a5ec4efe43674ea2bfda4..d32c644687971a5e39c25a56a930d4db4e23c0f1 100644 --- a/app/models/administration/member.rb +++ b/app/models/administration/member.rb @@ -3,12 +3,14 @@ # Table name: administration_members # # id :uuid not null, primary key +# email :string # first_name :string # is_administrative :boolean # is_author :boolean # is_researcher :boolean # is_teacher :boolean # last_name :string +# phone :string # slug :string # created_at :datetime not null # updated_at :datetime not null @@ -44,6 +46,11 @@ class Administration::Member < ApplicationRecord join_table: :research_journal_articles_researchers, foreign_key: :researcher_id + validates_presence_of :first_name, :last_name + validates_uniqueness_of :email, scope: :university_id, allow_blank: true, if: :will_save_change_to_email? + validates_format_of :email, with: Devise::email_regexp, allow_blank: true, if: :will_save_change_to_email? + + scope :ordered, -> { order(:last_name, :first_name) } scope :administratives, -> { where(is_administrative: true) } scope :authors, -> { where(is_author: true) } diff --git a/app/views/admin/administration/members/_form.html.erb b/app/views/admin/administration/members/_form.html.erb index eaf9e8dd2cad6d366f06809fe3f728df065b939c..16d8ff2e4ea5cac1599601a02d35d773e6c60e29 100644 --- a/app/views/admin/administration/members/_form.html.erb +++ b/app/views/admin/administration/members/_form.html.erb @@ -14,6 +14,14 @@ <%= f.input :last_name %> </div> </div> + <div class="row"> + <div class="col-md-6"> + <%= f.input :email %> + </div> + <div class="col-md-6"> + <%= f.input :phone %> + </div> + </div> <%= f.input :biography, as: :rich_text_area %> </div> </div> diff --git a/app/views/admin/administration/members/show.html.erb b/app/views/admin/administration/members/show.html.erb index 85793fc7f31395b1d53fc56a6189bdcf725999f0..fd1391872a422841fc04c6da9d8ca969a1186a22 100644 --- a/app/views/admin/administration/members/show.html.erb +++ b/app/views/admin/administration/members/show.html.erb @@ -8,6 +8,14 @@ <h2 class="card-title mb-0 h5"><%= t('metadata') %></h2> </div> <div class="card-body"> + <% unless @member.email.blank? %> + <h3 class="h5"><%= Administration::Member.human_attribute_name('email') %></h3> + <p><%= link_to @member.email, "mailto:#{@member.email}", target: '_blank' %></p> + <% end %> + <% unless @member.phone.blank? %> + <h3 class="h5"><%= Administration::Member.human_attribute_name('phone') %></h3> + <p><%= link_to @member.phone, "tel:#{@member.phone}", target: '_blank' %></p> + <% end %> <h3 class="h5"><%= Administration::Member.human_attribute_name('biography') %></h3> <p><%= @member.biography %></p> <h3 class="h5"><%= Administration::Member.human_attribute_name('slug') %></h3> diff --git a/config/locales/administration/en.yml b/config/locales/administration/en.yml index 721be3c4f045c206a6e3b3810ba43b666c0160d8..8482258631f49e741203455d7ceb511bef483b3f 100644 --- a/config/locales/administration/en.yml +++ b/config/locales/administration/en.yml @@ -17,6 +17,7 @@ en: administration/member: abilities: Abilities biography: Biography + email: Email first_name: First name is_administrative: Administrative staff is_author: Author @@ -24,6 +25,7 @@ en: is_teacher: Teacher last_name: Last name name: Name + phone: Phone slug: Slug user: User administration/qualiopi/criterion: diff --git a/config/locales/administration/fr.yml b/config/locales/administration/fr.yml index c38d6f52a3e1668a30ef3a3735a9c29c78417dfc..84adfce3e9f0883698ae57cec7181e480cabed7e 100644 --- a/config/locales/administration/fr.yml +++ b/config/locales/administration/fr.yml @@ -17,6 +17,7 @@ fr: administration/member: abilities: Responsabilités biography: Biographie + email: Email first_name: Prénom is_administrative: Personnel administratif is_author: Auteur·rice @@ -24,6 +25,7 @@ fr: is_teacher: Enseignant·e last_name: Nom de famille name: Nom + phone: Téléphone slug: Slug user: Utilisateur administration/qualiopi/criterion: diff --git a/db/migrate/20211215104346_add_email_and_phone_to_administration_members.rb b/db/migrate/20211215104346_add_email_and_phone_to_administration_members.rb new file mode 100644 index 0000000000000000000000000000000000000000..ad067aecf865aba862a602525156ae6217865923 --- /dev/null +++ b/db/migrate/20211215104346_add_email_and_phone_to_administration_members.rb @@ -0,0 +1,6 @@ +class AddEmailAndPhoneToAdministrationMembers < ActiveRecord::Migration[6.1] + def change + add_column :administration_members, :phone, :string + add_column :administration_members, :email, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index bf36c61b9d795ff33f733600279146c65d8711f3..3e68dc191d15e178c4ea831ee3f2d84c9b118dbd 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.define(version: 2021_12_14_163501) do +ActiveRecord::Schema.define(version: 2021_12_15_104346) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -68,6 +68,8 @@ ActiveRecord::Schema.define(version: 2021_12_14_163501) do t.boolean "is_administrative" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.string "phone" + t.string "email" t.index ["university_id"], name: "index_administration_members_on_university_id" t.index ["user_id"], name: "index_administration_members_on_user_id" end