Skip to content
Snippets Groups Projects
Unverified Commit cbc291d0 authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

people

parent b9f3b0d5
No related branches found
No related tags found
No related merge requests found
Showing
with 55 additions and 12 deletions
......@@ -71,8 +71,8 @@ module Communication::Website::WithAbouts
people += about.university_people_through_administrators
people += about.university_people_through_administrators.map(&:administrator)
elsif about_journal?
people += research_articles.collect(&:persons).flatten
people += research_articles.collect(&:persons).flatten.map(&:researcher)
people += research_articles.collect(&:people).flatten
people += research_articles.collect(&:people).flatten.map(&:researcher)
end
people.uniq.compact
end
......
......@@ -53,7 +53,7 @@ module Communication::Website::WithMenuItems
end
def menu_item_kind_researchers?
research_articles.collect(&:persons).flatten.any?
research_articles.collect(&:people).flatten.any?
end
def menu_item_kind_teachers?
......
......@@ -45,7 +45,7 @@ class Research::Journal::Article < ApplicationRecord
belongs_to :journal, foreign_key: :research_journal_id
belongs_to :volume, foreign_key: :research_journal_volume_id, optional: true
belongs_to :updated_by, class_name: 'User'
has_and_belongs_to_many :persons,
has_and_belongs_to_many :people,
class_name: 'University::Person',
join_table: :research_journal_articles_researchers,
association_foreign_key: :researcher_id
......@@ -65,8 +65,8 @@ class Research::Journal::Article < ApplicationRecord
[self] +
active_storage_blobs +
other_articles_in_the_volume +
persons +
persons.map(&:researcher)
people +
people.map(&:researcher)
end
def to_s
......
......@@ -35,7 +35,7 @@ class Research::Journal::Volume < ApplicationRecord
belongs_to :journal, foreign_key: :research_journal_id
has_many :articles, foreign_key: :research_journal_volume_id, dependent: :nullify
has_many :websites, -> { distinct }, through: :journal
has_many :researchers, through: :articles
has_many :people, -> { distinct }, through: :articles
before_validation :set_published_at, if: :published_changed?
......
class University::Person::Involvement < ApplicationRecord
belongs_to :university
belongs_to :person
belongs_to :target
end
......@@ -40,7 +40,7 @@ class University::Person::Researcher < University::Person
def for_website?(website)
is_researcher && website.about_journal? && website.research_articles
.joins(:persons)
.joins(:people)
.where(university_people: { id: id })
.any?
end
......
......@@ -30,7 +30,7 @@
<%= f.input :published %>
<%= f.input :published_at, html5: true %>
<%= f.input :keywords, as: :text, input_html: { rows: 2 } %>
<%= f.association :persons, collection: current_university.people.researchers.ordered, as: :check_boxes %>
<%= f.association :people, collection: current_university.people.researchers.ordered, as: :check_boxes %>
</div>
</div>
</div>
......
......@@ -40,10 +40,10 @@
<h3 class="h5"><%= Research::Journal::Article.human_attribute_name('keywords') %></h3>
<p><%= @article.keywords %></p>
<% end %>
<% if @article.persons.any? %>
<% if @article.people.any? %>
<h3 class="h5"><%= Research::Journal::Article.human_attribute_name('researchers') %></h3>
<ul class="list-unstyled mb-0">
<% @article.persons.each do |person| %>
<% @article.people.each do |person| %>
<li><%= link_to person, admin_research_researcher_path(person) %></li>
<% end %>
</ul>
......
......@@ -14,7 +14,7 @@ pdf: "<%= @article.pdf.blob_id %>"
keywords: >
<%= @article.keywords %>
researchers:
<% @article.persons.each do |person| %>
<% @article.people.each do |person| %>
- "<%= person.slug %>"
<% end %>
abstract: "<%= @article.abstract %>"
......
class CreateUniversityPersonInvolvements < ActiveRecord::Migration[6.1]
def change
create_table :university_person_involvements, id: :uuid do |t|
t.references :university, null: false, foreign_key: true, type: :uuid
t.references :person, null: false, foreign_key: true, type: :uuid
t.integer :kind
t.references :target, null: false, foreign_key: true, type: :uuid
t.text :description
t.integer :position
t.timestamps
end
end
end
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
university: one
person: one
kind: 1
target: one
description: MyText
position: 1
two:
university: two
person: two
kind: 1
target: two
description: MyText
position: 1
require "test_helper"
class University::Person::InvolvementTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment