Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/controllers/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ def person_params
affiliations_attributes: [
:id,
:organization_id,
:position,
:title,
:inactive,
:primary_contact,
Expand Down
2 changes: 1 addition & 1 deletion app/decorators/person_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def title
end

def detail(length: nil)
text = affiliations.active.map { |affiliation| "#{affiliation.title.presence || affiliation.position}, #{affiliation.organization.name}" }.join(", ")
text = affiliations.active.map { |affiliation| "#{affiliation.title}, #{affiliation.organization.name}" }.join(", ")
length ? text&.truncate(length) : text
end

Expand Down
3 changes: 0 additions & 3 deletions app/models/affiliation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ class Affiliation < ApplicationRecord
# Validations
validates_presence_of :organization_id

# Enum
enum :position, { default: 0, liaison: 1, leader: 2, assistant: 3 }

scope :active, -> {
where(inactive: false)
.where("end_date IS NULL OR end_date >= ?", Date.current)
Expand Down
4 changes: 2 additions & 2 deletions app/views/organizations/_affiliation_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
as: :text,
input_html: {
rows: 1,
value: f.object&.title || f.object&.position || "Facilitator",
value: f.object&.title || "Facilitator",
style: "height: 42px; min-height: 42px;",
data: {
inactive_toggle_target: "title",
Expand Down Expand Up @@ -83,6 +83,6 @@
</div>
<% else %>
<div class="ps-6 mb-4">
<li><%= f.object.organization&.name %> (<%= f.object.title || f.object.position %>)</li>
<li><%= f.object.organization&.name %> (<%= f.object.title %>)</li>
</div>
<% end %>
2 changes: 1 addition & 1 deletion app/views/organizations/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
<% else %>
<% f.object.user&.person&.affiliations&.each do |affiliation| %>
<div class="ps-6 mb-2">
<li><%= affiliation.title || affiliation.position %> - <%= person_profile_button(affiliation.user.person, subtitle: (affiliation.user.person.preferred_email if affiliation.user.person.profile_show_email? || allowed_to?(:manage?, Person))) if affiliation.persisted? && affiliation.user.person %></li>
<li><%= affiliation.title %> - <%= person_profile_button(affiliation.user.person, subtitle: (affiliation.user.person.preferred_email if affiliation.user.person.profile_show_email? || allowed_to?(:manage?, Person))) if affiliation.persisted? && affiliation.user.person %></li>
</div>
<% end %>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/people/_affiliation_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
as: :text,
input_html: {
rows: 1,
value: f.object.title || f.object.position || "Facilitator",
value: f.object.title || "Facilitator",
style: "height: 42px; min-height: 42px;",
data: {
inactive_toggle_target: "title",
Expand Down Expand Up @@ -85,6 +85,6 @@
</div>
<% else %>
<div class="ps-6 mb-4">
<li><%= f.object.organization&.name %> (<%= f.object.title || f.object.position %>)</li>
<li><%= f.object.organization&.name %> (<%= f.object.title %>)</li>
</div>
<% end %>
2 changes: 1 addition & 1 deletion app/views/people/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
<% else %>
<% f.object.affiliations.each do |affiliation| %>
<div class="ps-6 mb-2">
<li><%= affiliation.title || affiliation.position %> - <%= affiliation.persisted? ? (link_to affiliation.organization&.name, organization_path(affiliation.organization), class: "underline") : affiliation.organization&.name %></li>
<li><%= affiliation.title %> - <%= affiliation.persisted? ? (link_to affiliation.organization&.name, organization_path(affiliation.organization), class: "underline") : affiliation.organization&.name %></li>
</div>
<% end %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/_affiliation_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
as: :text,
input_html: {
rows: 1,
value: f.object.title || f.object.position,
value: f.object.title,
} %>
</div>

Expand Down
2 changes: 1 addition & 1 deletion spec/factories/affiliations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
association :organization
association :person

position { :default }
title { "Facilitator" }
end
end
4 changes: 0 additions & 4 deletions spec/models/affiliation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
# it { should validate_presence_of(:person_id) } # we needed to not have this to support nested attrs
end

describe 'enums' do
it { should define_enum_for(:position).with_values(default: 0, liaison: 1, leader: 2, assistant: 3) }
end

describe '.active' do
let!(:active_op) { create(:affiliation, inactive: false, end_date: nil) }
let!(:active_with_future_end) { create(:affiliation, inactive: false, end_date: 1.month.from_now) }
Expand Down