Phase 2: Split names_controller into smaller controllers#258
Open
lmrodriguezr wants to merge 11 commits into
Open
Phase 2: Split names_controller into smaller controllers#258lmrodriguezr wants to merge 11 commits into
lmrodriguezr wants to merge 11 commits into
Conversation
This controller contains shared logic, before_actions, and private methods used by all Names-related controllers. It centralizes authentication, setup, and helper methods to avoid repetition.
This controller handles the core CRUD operations for Names: - index, show, new, create, update, destroy - autocomplete It inherits from Names::BaseController to reuse shared logic.
This controller handles filtering and listing names by status, user, or type: - user, observing, submitted, endorsed, draft, unranked, unknown_proposal, type_genomes It inherits from Names::BaseController and reuses the index logic.
This controller handles actions related to publication associations: - proposed_in, not_validly_proposed_in, emended_in, assigned_in, corrigendum_in, corrigendum It inherits from Names::BaseController.
This controller handles actions related to changing the status of a name: - return, validate, endorse, claim, unclaim, demote, temporary_editable It inherits from Names::BaseController.
This controller handles actions related to user interactions: - transfer_user, transfer_user_commit, observe, unobserve, new_correspondence It inherits from Names::BaseController.
This controller handles the network visualization action: - network It inherits from Names::BaseController.
This controller handles the wiki action: - wiki It inherits from Names::BaseController.
This controller handles utility actions: - autocomplete, linkout, etymology_sandbox, syllabify, quality_checks It inherits from Names::BaseController.
This controller handles actions related to editing name attributes: - edit, edit_description, edit_notes, edit_rank, edit_links, edit_type, edit_redirect, autofill_etymology, edit_etymology, edit_parent It inherits from Names::BaseController.
This change updates the routes to use the new Names:: namespace for controllers. - Standard REST actions (index, show, new, create, update, destroy) are mapped to Names::MainController. - Custom actions are explicitly mapped to their respective controllers (e.g., filtering, publications, status). - The existing route structure and URLs remain unchanged.
| def observe | ||
| @name.add_observer(current_user) | ||
| if params[:from] && RedirectSafely.safe?(params[:from]) | ||
| redirect_to(params[:from]) |
| def unobserve | ||
| @name.observers.delete(current_user) | ||
| if params[:from] && RedirectSafely.safe?(params[:from]) | ||
| redirect_to(params[:from]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements Phase 2 of the code reorganization plan for the SeqCode Registry. It splits the large
names_controller.rbinto smaller, focused controllers under theNames::namespace, improving maintainability and readability.📌 Changes Made
1. New Base Controller
app/controllers/names/base_controller.rb: Contains shared logic,before_actions, and private methods used by allNames::controllers. This includes:authenticate_can_edit!,authenticate_owner_or_curator!).set_name,set_tutorial).name_params,change_status,add_automatic_correspondence).2. New Split Controllers
All new controllers inherit from
Names::BaseControllerand handle specific groups of actions:Names::MainControllerindex,show,new,create,update,destroy,autocompleteNames::FilteringControlleruser,submitted,endorsed,draft,unranked,unknown_proposal,type_genomesNames::PublicationsControllerproposed_in,not_validly_proposed_in,emended_in,assigned_in,corrigendum_in,corrigendumNames::StatusControllerreturn,validate,endorse,claim,unclaim,demote,temporary_editableNames::UserActionsControllertransfer_user,transfer_user_commit,observe,unobserve,new_correspondenceNames::NetworkControllernetworkNames::WikiControllerwikiNames::UtilityControllerautocomplete,linkout,etymology_sandbox,syllabify,quality_checksNames::EditingControlleredit,edit_description,edit_notes,edit_rank,edit_links,edit_type,edit_redirect,autofill_etymology,edit_etymology,edit_parent3. Updated Routes
config/routes.rbfile has been updated to explicitly map actions to their respective controllers using thecontroller:option.index,show,new,create) are mapped toNames::MainControllerviacontroller: 'names/main'.submitted,validate) are explicitly mapped to their respective controllers (e.g.,controller: 'names/filtering').🎯 Goals Achieved
names_controller.rb(500+ lines) is now split into smaller, focused controllers (~50-100 lines each).Names::BaseController.🔜 Next Steps
FastJSONAPI) for consistency./v1/names) and add request specs for all endpoints.📚 Related Issues/PRs
names_controller.rbfile.Reviewers: Please focus on the new controller structure and route mappings. The changes are backward-compatible and do not break existing functionality.