Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.
Ruby agplai-assistantdockerdsgvogdprhotwireissue-trackerjira-alternativeknowledge-basellmmcp-servermeeting-notesopen-sourceproject-managementredmine-alternativeruby-on-railsself-hostedticketingtime-tracking
Address review round 1 of linking a meeting participant
Guido Boyke0e05b95f9018
diff --git a/app/helpers/meeting_participant_links_helper.rb b/app/helpers/meeting_participant_links_helper.rbindex 178e8b8..4d2f616 100644--- a/app/helpers/meeting_participant_links_helper.rb+++ b/app/helpers/meeting_participant_links_helper.rb@@ -89,7 +89,7 @@ module MeetingParticipantLinksHelperdef participant_directory_entry(directory, participant)if participant.user_id- directory.member_entry(participant.user_id)+ directory.member_entry(participant.user_id) || directory.former_member_entry(participant.user_id)elsif participant.person_iddirectory.person_entry(participant.person_id)enddiff --git a/app/models/meeting_participant.rb b/app/models/meeting_participant.rbindex 9278b67..ffe032a 100644--- a/app/models/meeting_participant.rb+++ b/app/models/meeting_participant.rb@@ -65,9 +65,11 @@ class MeetingParticipant < ApplicationRecord# External (name-only) participants in the given projects — the ONE definition of# "an external participation eligible to be claimed", shared by the claim matcher# (counts them) and the claim actor (links them). Callers pass an already- # access-scoped project_ids list.+ # access-scoped project_ids list. A name linked to a contact of the people+ # directory (person_id) is that contact, not a free name: one key per+ # participant, the link dialog relinks it.scope :external_in_projects, lambda { |project_ids|- where(user_id: nil).joins(:meeting).where(meetings: { project_id: project_ids })+ where(user_id: nil, person_id: nil).joins(:meeting).where(meetings: { project_id: project_ids })}# Normalization contract: PersonName.normalize, the one normalizer shareddiff --git a/app/services/actors/link_meeting_participant.rb b/app/services/actors/link_meeting_participant.rbindex 45b199a..37f6dd8 100644--- a/app/services/actors/link_meeting_participant.rb+++ b/app/services/actors/link_meeting_participant.rb@@ -72,6 +72,7 @@ module Actorsdef link_to_entry(entry)if entry.member?refuse!(:member_already_participant) if taken_by_another?(entry.user.id)+ refuse!(:member_name_taken) if name_taken_by_another?(entry.user.display_name)@participant.update!(user_id: entry.user.id, person_id: nil)else@participant.update!(person_id: entry.person.id)@@ -85,6 +86,15 @@ module Actors@meeting.meeting_participants.where(user_id: user_id).where.not(id: @participant.id).exists?end+ # The meeting form labels a member chip with the member's profile name+ # (MeetingsController#meeting_participant_options); a second participant of+ # that name would make every later save of the meeting fail on its unique+ # name (SaveMeeting#guard_against_duplicates!).+ def name_taken_by_another?(name)+ @meeting.meeting_participants.where(normalized_name: PersonName.normalize(name))+ .where.not(id: @participant.id).exists?+ end+def created_entryrefuse!(:not_allowed) unless PersonPolicy.manage_allowed?(current_user, organisation)diff --git a/app/services/people/directory.rb b/app/services/people/directory.rbindex 1d9081b..035dcd2 100644--- a/app/services/people/directory.rb+++ b/app/services/people/directory.rb@@ -80,6 +80,12 @@ module Peopleeveryone.find { |entry| entry.person&.id == person_id.to_s }end+ # The contact entry of a former member: their row, which keeps the meetings+ # they still carry by account (People::Contacts reads the row's user_id).+ def former_member_entry(user_id)+ everyone.find { |entry| !entry.member? && entry.person&.user_id == user_id.to_s }+ end+# The entries matching the search, without last contacts: the list of the# dialog that links a meeting participant (S2b).def candidatesdiff --git a/config/locales/services.de.yml b/config/locales/services.de.ymlindex a8fb96a..1eaf3d9 100644--- a/config/locales/services.de.yml+++ b/config/locales/services.de.yml@@ -52,6 +52,7 @@ de:nothing_picked: "Wähle eine Person aus oder lege eine neue an."member_participant: "Dieser Teilnehmer ist ein Mitglied und über sein Konto verknüpft."member_already_participant: "Dieses Mitglied nimmt schon an dem Meeting teil."+ member_name_taken: "Ein anderer Teilnehmer trägt schon den Namen dieses Mitglieds. Entferne ihn zuerst aus dem Meeting."not_allowed: "Du darfst keine Personen anlegen."move_meeting:same_project: "Das Meeting liegt schon in diesem Projekt."diff --git a/config/locales/services.en.yml b/config/locales/services.en.ymlindex 900cec9..39908f3 100644--- a/config/locales/services.en.yml+++ b/config/locales/services.en.yml@@ -52,6 +52,7 @@ en:nothing_picked: "Pick a person or create a new one."member_participant: "This participant is a member and is linked through their account."member_already_participant: "This member already takes part in the meeting."+ member_name_taken: "Another participant already carries the name of this member. Remove them from the meeting first."not_allowed: "You may not create people."move_meeting:same_project: "The meeting is already in this project."diff --git a/spec/requests/organisations/meeting_participant_links_spec.rb b/spec/requests/organisations/meeting_participant_links_spec.rbindex 9e20b18..e74fc47 100644--- a/spec/requests/organisations/meeting_participant_links_spec.rb+++ b/spec/requests/organisations/meeting_participant_links_spec.rb@@ -109,6 +109,17 @@ RSpec.describe 'Organisations::MeetingParticipantLinks', :ci_guard, type: :requeexpect(response.body).to include(CGI.escapeHTML(organisation_people_path(organisation, person_id: row.id)))end+ it 'links the chip of a former member to the row that keeps their meetings' do+ former = member_with(create(:role, organisation: organisation), first_name: 'Fritz')+ row = create(:person, organisation: organisation, name: 'Fritz Beispiel', user: former)+ Membership.where(user: former, organisation: organisation).update_all(active: false)+ create(:meeting_participant, meeting: meeting, display_name: 'Fritz Beispiel', user: former)+ sign_in admin+ show_meeting++ expect(response.body).to include(CGI.escapeHTML(organisation_people_path(organisation, person_id: row.id)))+ end+it 'keeps a chip as text when its person is a row the viewer may not see' dohidden_member = member_with(create(:role, organisation: organisation), first_name: 'Hanna')create(:project_permission, user: hidden_member, project: create(:project, organisation: organisation),@@ -212,7 +223,7 @@ RSpec.describe 'Organisations::MeetingParticipantLinks', :ci_guard, type: :requeexpect(response).to have_http_status(:ok)expect(participant.reload.person_id).to eq(contact.id)expect(response.body).to include("turbo-stream action=\"replace\" target=\"#{ActionView::RecordIdentifier.dom_id(meeting, :participants)}\"")- expect(response.body).to include('action="remove" target="meeting-participant-link-modal-')+ expect(response.body).to include("action=\"remove\" target=\"meeting-participant-link-modal-#{meeting.id}-#{modal_token}\"")expect(response.body).to include(CGI.escapeHTML(organisation_people_path(organisation, person_id: contact.id)))get organisation_people_path(organisation, person_id: contact.id), headers: { 'Turbo-Frame' => Organisations::PeopleController::DETAIL_FRAME_ID }@@ -237,7 +248,7 @@ RSpec.describe 'Organisations::MeetingParticipantLinks', :ci_guard, type: :requepost_link("member:#{colleague.id}")expect(response).to have_http_status(:unprocessable_content)- expect(response.body).to include('action="replace" target="meeting-participant-link-modal-')+ expect(response.body).to include("action=\"replace\" target=\"meeting-participant-link-modal-#{meeting.id}-#{modal_token}\"")expect(response.body).to include(I18n.t('services.actors.link_meeting_participant.member_already_participant'))expect(participant.reload.user_id).to be_nilend@@ -388,15 +399,19 @@ RSpec.describe 'Organisations::MeetingParticipantLinks', :ci_guard, type: :requeexpect(participant.reload.person_id).to eq(contact.id)end- it 'keeps a member link, which the form sends as user_id' do+ # The form labels a member chip with the member's profile name, so the row is kept by+ # its member, not by its name (SaveMeeting#match_participant_rows).+ it 'keeps a member link, which the form sends as user_id under the profile name' docolleague = member_with(create(:role, organisation: organisation), first_name: 'Carl')+ create(:project_permission, user: colleague, project: project, meetings_access: :read_only)sign_in adminpost_link("member:#{colleague.id}")- edit_with(display_name: 'J. Weber (Hoster)', user_id: colleague.id)+ edit_with(display_name: colleague.display_name, user_id: colleague.id)expect(response).to have_http_status(:ok)expect(participant.reload.user_id).to eq(colleague.id)+ expect(meeting.meeting_participants.count).to eq(1)endendenddiff --git a/spec/services/actors/claim_meeting_participants_spec.rb b/spec/services/actors/claim_meeting_participants_spec.rbindex 777bfda..6ff36b0 100644--- a/spec/services/actors/claim_meeting_participants_spec.rb+++ b/spec/services/actors/claim_meeting_participants_spec.rb@@ -66,9 +66,10 @@ RSpec.describe Actors::ClaimMeetingParticipants doexpect(row.display_name).to eq('karl krause')end- # The claim writes user_id only. A row linked to the people directory keeps- # its person_id (meeting_participants.person_id, set by the link dialog).- it 'leaves person_id untouched' do+ # One key per participant (S2b): a row linked to a contact of the people+ # directory (person_id, set by the link dialog) is that contact. The claim+ # leaves it alone instead of giving it a second key; the dialog relinks it.+ it 'leaves a row linked to a contact alone' dotarget = memberperson = create(:person, organisation: organisation, name: 'Karl Krause')row = external_row(writable_project, 'Karl Krause')@@ -76,7 +77,7 @@ RSpec.describe Actors::ClaimMeetingParticipants dodescribed_class.new(user: target, normalized_name: 'Karl Krause', current_user: actor).call- expect(MeetingParticipant.where(id: row.id).pluck(:user_id, :person_id)).to eq([[target.id, person.id]])+ expect(MeetingParticipant.where(id: row.id).pluck(:user_id, :person_id)).to eq([[nil, person.id]])endit 'matches across umlaut spellings (member "Jörg Groß" ~ external "Joerg Gross")' dodiff --git a/spec/services/actors/link_meeting_participant_spec.rb b/spec/services/actors/link_meeting_participant_spec.rbindex 43ec314..1219e97 100644--- a/spec/services/actors/link_meeting_participant_spec.rb+++ b/spec/services/actors/link_meeting_participant_spec.rb@@ -98,6 +98,18 @@ RSpec.describe Actors::LinkMeetingParticipant, :ci_guard doexpect(result.errors).to eq([I18n.t('services.actors.link_meeting_participant.member_already_participant')])expect(participant.reload.user_id).to be_nilend++ # The meeting form labels a member chip with the member's profile name: a second+ # participant of that name would make every later save of the meeting fail.+ it 'refuses a member whose name another participant of the meeting carries' do+ create(:meeting_participant, meeting: meeting, display_name: colleague.display_name)++ result = link(member_id: colleague.id)++ expect(result.code).to eq(:member_name_taken)+ expect(result.errors).to eq([I18n.t('services.actors.link_meeting_participant.member_name_taken')])+ expect(participant.reload.user_id).to be_nil+ endenddescribe 'a participant that is a member' dodiff --git a/spec/services/meetings/participant_claim_matches_spec.rb b/spec/services/meetings/participant_claim_matches_spec.rbindex bba5236..5e46aa7 100644--- a/spec/services/meetings/participant_claim_matches_spec.rb+++ b/spec/services/meetings/participant_claim_matches_spec.rb@@ -127,6 +127,16 @@ RSpec.describe Meetings::ParticipantClaimMatches doexpect(matches).to be_emptyend+ # One key per participant (S2b): a name linked to a contact of the people+ # directory is that contact, not a free name a member could claim.+ it 'never matches a participant linked to a contact' do+ named_member('Karl', 'Krause')+ meeting = external_in(writable_project, 'Karl Krause')+ meeting.meeting_participants.first.update!(person: create(:person, organisation: organisation, name: 'Karl Krause'))++ expect(matches).to be_empty+ end+it 'returns one suggestion per member for real doppelgängers' dotwin_a = named_member('Karl', 'Krause')twin_b = named_member('Karl', 'Krause')diff --git a/spec/system/meeting_participant_link_spec.rb b/spec/system/meeting_participant_link_spec.rbindex 964e6e6..6cd2e30 100644--- a/spec/system/meeting_participant_link_spec.rb+++ b/spec/system/meeting_participant_link_spec.rb@@ -56,7 +56,7 @@ RSpec.describe 'Linking a meeting participant to a person', type: :system doexpect(page).to have_no_css('[role="dialog"]')expect(page).to have_link(I18n.t("#{pl}.open_person", name: 'J. Weber (Hoster)'))expect(participant.reload.person.name).to eq('Jonas Weber')- expect(page.evaluate_script('document.activeElement.id')).to eq(trigger_id)+ expect(page).to have_css("##{trigger_id}:focus")endit 'closes on Escape without linking' do@@ -65,8 +65,11 @@ RSpec.describe 'Linking a meeting participant to a person', type: :system dofind('[role="dialog"] input[type="search"]').send_keys(:escape)+ # The dialog owns that Escape: the meeting behind stays open, and the focus is back on+ # the button that opened the dialog (the title alone also stands in the list row).expect(page).to have_no_css('[role="dialog"]')- expect(page).to have_text('Hosting-Abstimmung')+ # Waits: the controller hands the focus back after the frame is emptied.+ expect(page).to have_css("##{trigger_id}:focus")expect(participant.reload.person_id).to be_nilendend