Skip to content

Conversation

@fbacall
Copy link
Member

@fbacall fbacall commented Jul 1, 2025

Summary of changes

  • Prevents a new profile record being created each time the user updates their profile.
  • Fixes trainer language filter options being blank
  • Fixes trainer filters showing even when no trainers in the list
  • Fixes 500 when trying to edit profile as an admin
  • Refactors trainer/profile reindexing behaviour (no longer requires full reindex when a single record changes)

Motivation and context

User noticed trainer language select on profile edit page was showing Yes/No options instead of languages, ran into other issues whilst debugging.

Checklist

  • I have read and followed the CONTRIBUTING guide.
  • I confirm that I have the authority necessary to make this contribution on behalf of its copyright owner and agree
    to license it to the TeSS codebase under the
    BSD license.

@fbacall fbacall requested a review from Copilot July 1, 2025 16:37
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 refines profile updating, trainer filtering, and search indexing to prevent duplicate records, correct filter options, and optimize Solr reindexing.

  • Adds a profile ID check to user updates to block creation of new profile records
  • Fixes language select options and conditional display of trainer filters
  • Refactors Solr reindex callbacks from individual models into a single after_commit in Profile

Reviewed Changes

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

Show a summary per file
File Description
app/controllers/users_controller.rb Added check_profile_id before_action to forbid mismatched IDs
app/views/users/_form.html.erb Updated scraper-email checkbox and replaced language select input
app/models/profile.rb & trainer.rb Removed per-model callbacks; unified reindex_trainer callback
app/models/concerns/searchable.rb Revised public filtering logic for Trainer/Profile searches
app/helpers/search_helper.rb Enhanced facet_title to gracefully handle blank language names
config/locales/en.yml Added translations for scraper emails and profile language label
test/test_helper.rb Stubbed external HTTP requests to example.com
test/fixtures/users.yml Introduced admin_trainer fixture for admin tests
test/fixtures/profiles.yml Added admin_trainer_profile fixture
test/controllers/users_controller_test.rb Updated profile update tests and added forbidden-ID test
test/controllers/trainers_controller_test.rb Adjusted expected trainer count and inclusion assertion
Comments suppressed due to low confidence (2)

config/locales/en.yml:974

  • These keys live under en.user and en.profile, but SimpleForm will look under simple_form.labels.user.check_broken_scrapers and simple_form.labels.profile.language. Consider nesting these translations under simple_form.labels to match SimpleForm’s lookup path.
        check_broken_scrapers: Receive emails with scrapers that have not found anything last period.

app/views/users/_form.html.erb:40

  • The variable user_f isn’t defined in this form; it looks like you intended to use f.input for the user builder. Replace user_f.input with f.input or properly define user_f via fields_for.
          <%= user_f.input :check_broken_scrapers %>

end

if attribute_method?(:public) && !user&.is_admin? # Find a better way of checking this
if name == 'Trainer' || name == 'Profile'
Copy link

Copilot AI Jul 1, 2025

Choose a reason for hiding this comment

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

[nitpick] This branch forces all searches for Trainer/Profile to only show public records, even for admins. Document this behavior or refine the condition so that admins can still see private items when intended.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@fbacall fbacall merged commit c0a0d98 into tess-1.5 Jul 3, 2025
8 checks passed
@fbacall fbacall deleted the profile-form-fixes branch July 3, 2025 14:29
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.

2 participants