Skip to content

Feature: Primary Client POC#841

Merged
chrismaddalena merged 11 commits intomasterfrom
feature/client-poc-primary
Mar 11, 2026
Merged

Feature: Primary Client POC#841
chrismaddalena merged 11 commits intomasterfrom
feature/client-poc-primary

Conversation

@chrismaddalena
Copy link
Collaborator

This closes #789 by adding a primary field to the ClientContact model and supporting JavaScript and validation code for handling the field in forms. This field works like the field on the ProjectContact model with some adjustments.

This PR includes the following changes and behavior:

  1. Adds the primary field to the ClientContact (just like ProjectContact)
  2. Adds the new primary field to the ClientContactForm (just like ProjectContactForm)
  3. Adds the necessary form validation to BaseClientContactInlineFormSet and JavaScript for handling what happens if a user selects multiple primary contacts in the formset (just like ProjectContactForm and BaseProjectContactInlineFormSet)
  4. If a user adds a ClientContact to a project and the ProjectContact entries for a project do not already have a primary contact set for the project, carries-over the ClientContact entry's primary status

Copilot AI review requested due to automatic review settings March 10, 2026 23:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements “Primary Client POC” by adding a primary flag to ClientContact and wiring it through Django forms/formset validation, UI templates/JS behavior, and an AJAX flow that can carry a client contact’s primary status into a project contact when appropriate.

Changes:

  • Add primary boolean field to ClientContact (with migration) and update factories/tests accordingly.
  • Add inline formset validation and UI toggle behavior to ensure only one primary client contact can be selected in formsets.
  • Update AJAX “assign project contact” flow to optionally inherit primary onto ProjectContact when the project has no primary yet.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ghostwriter/rolodex/models.py Adds ClientContact.primary; adjusts model metadata (currently also changes plural labels).
ghostwriter/rolodex/migrations/0060_alter_clientcontact_options_and_more.py Adds DB field and alters model options (currently includes plural-label changes).
ghostwriter/rolodex/forms_client.py Adds “single primary” validation to client contact inline formset and adds a toggle control to the form layout.
ghostwriter/rolodex/views.py Updates AJAX project-contact assignment to conditionally inherit primary and avoid copying primary directly.
ghostwriter/factories.py Updates ClientContactFactory to include primary.
ghostwriter/rolodex/tests/test_models.py Adds model tests for default/set behavior of primary.
ghostwriter/rolodex/tests/test_forms.py Updates form helper to include primary and adds validation test for multiple primary contacts.
ghostwriter/rolodex/tests/test_views.py Adds tests for primary inheritance behavior during AJAX assignment.
ghostwriter/rolodex/templates/rolodex/client_form.html Adds JS handler to enforce a single selected primary toggle in the formset UI.
ghostwriter/rolodex/templates/rolodex/client_detail.html Adds a “Primary” column indicator for client contacts (and removes phone from the table).
ghostwriter/rolodex/templates/snippets/project_contacts_table.html Adds screen-reader-only text for primary/non-primary indicators.
ghostwriter/shepherd/templates/snippets/client_contact_detail_modal.html Adds phone display to the contact details modal (helps offset phone removal from the table).

@chrismaddalena chrismaddalena self-assigned this Mar 10, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

ghostwriter/shepherd/templates/snippets/client_contact_detail_modal.html:26

  • The modal checks poc.note, but ClientContact uses the description field (no note attribute). As-is, the “No additional information available.” branch will always render for client contacts. Update the template to read and sanitize poc.description (consistent with how the form stores rich text).
        {% if poc.note %}
          <p>{{ poc.note|bleach|safe }}</p>
        {% else %}
          <p>No additional information available.</p>
        {% endif %}

@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 98.54015% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.60%. Comparing base (184b6be) to head (f79cf2d).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
ghostwriter/rolodex/forms_client.py 94.11% 1 Missing ⚠️
ghostwriter/rolodex/forms_project.py 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #841      +/-   ##
==========================================
+ Coverage   91.56%   91.60%   +0.03%     
==========================================
  Files         372      373       +1     
  Lines       21364    21488     +124     
==========================================
+ Hits        19563    19685     +122     
- Misses       1801     1803       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

@chrismaddalena chrismaddalena merged commit 86a1e36 into master Mar 11, 2026
9 checks passed
@chrismaddalena chrismaddalena deleted the feature/client-poc-primary branch March 11, 2026 17:24
@chrismaddalena chrismaddalena mentioned this pull request Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow designation of Primary Contact at the Client Level

2 participants