Coordinator Admin Tools - FreeUKGen/MyopicVicar GitHub Wiki

Coordinator Admin Tools

Part of Transcriber & Coordinator Workflow.

A grab-bag of smaller coordinator/admin utilities. Grouped together here because each is small on its own, not because they're related to each other.

ManageResource โ€” the actual post-login dashboard

Model: app/models/manage_resource.rb (a near-empty two-field shell: chapman_code, userid) ยท Controller: app/controllers/manage_resources_controller.rb

Despite the generic name, this is the main landing controller every user hits after logging in โ€” almost all the real logic lives in the controller, not the model.

  • new gatekeeps every login via is_ok_to_render_actions?: checks the user exists, is active, and isn't researcher/pending; also checks Rails.application.config.member_open (a site-wide maintenance-mode flag, with an exception for system_administrator/technical). For a multi-role user it resolves which role context to use (@current_role; see Authentication-System). On success it clears a pile of session state (clean_session, clean_session_for_syndicate, clean_session_for_county, clean_session_for_images) and renders the role-specific actions menu.
  • logout deliberately calls Devise's sign_out(:user) rather than just reset_session โ€” the code comments explain why: reset_session alone skips Warden's logout hooks, so a "remember me" cookie would otherwise silently sign the user back in.
  • selection translates a chosen menu option into a redirect via the UseridRole::OPTIONS_TRANSLATION lookup table.

Worth knowing: create has a commented-out line (#@user = UseridDetail.where(...)) immediately followed by using @user anyway โ€” presumably set by a before_action not visible in this file. Trace where @user actually comes from before relying on this action.

Routes: resources :manage_resources plus manage_resources/pages, manage_resources/logout, manage_resources/selection.

ManageCounty โ€” the county/syndicate coordinator's navigation hub

Model: app/models/manage_county.rb (near-empty session-driven view-model: chapman_code, action, places, plus one static Aโ€“Z pagination helper) ยท Controller: app/controllers/manage_counties_controller.rb

Not a persisted "county" record (that's the separate County model) โ€” this is a ~30-action session-state machine. A coordinator picks a county (new โ†’ create/selected โ†’ select_action), which sets session[:chapman_code]/session[:county]; every subsequent action reads that session state to filter Csvfile-System/Place/Image-Server-System records for that county โ€” batch review queues, image-group allocation/completion workflows, place-name curation, offline reports, and more.

Notable routing pattern: roughly 12 routes all point at the identical path manage_counties/selection (config/routes.rb, confirmed directly), disambiguated purely by custom constraints: classes (ManageCountiesBeingValidatedConstraint, ManageCountiesIncorporatedConstraint, etc. โ€” one class per action). There's no way to tell which controller action handles a given /manage_counties/selection request just from the URL โ€” you have to find and read the matching constraint class. This is the same "dispatch on a hidden discriminator" family of footgun documented on Message-System and Image-Server-System, pushed all the way down into the routing layer.

Worth knowing: a lot of behavior silently diverges per template_set via scattered # not applicable for CEN/# not applicable for REG comments across dozens of methods, rather than being centralized in one place โ€” easy to miss that an action you're editing has a FreeCEN-only or FreeREG-only branch buried in it.

ManageDocument โ€” trivial CMS page wrapper, with a broken route

Controller: app/controllers/manage_document_controller.rb (no model)

One real action, freecen_handbook, which pulls a Refinery CMS page (slug 'freecen-handbook') and renders it.

Confirmed routing bug: config/routes.rb has resources :manage_documents (plural), but the controller class is ManageDocumentController (singular). Rails generates its 7 standard RESTful routes expecting a ManageDocumentsController that doesn't exist โ€” hitting any of those would raise uninitialized constant. Only the one explicit custom route (manage_documents/freecen_handbook โ†’ manage_document#freecen_handbook) actually works.

S3bucket โ€” generic S3 browsing/caching helper

Model: app/models/s3bucket.rb ยท Controller: app/controllers/s3buckets_controller.rb (empty โ€” zero actions beyond the license header)

A thin wrapper around AWS S3 (via Fog::Storage) for browsing a bucket's directory listing and mirroring files down to a local /tmp/myopicvicar/ scratch directory. It's a plain library class used from other controllers, not through its own REST routes โ€” resources :s3buckets is routed, but every action would fail since the controller has nothing in it.

Key fields/methods: name (bucket name), prefixes (Array โ€” a cache of the bucket's top-level directory names, lazily computed and persisted via save! inside directories). ls(dir) lists files under a prefix but requires dir to already be present in the cached prefixes. flush_to_slash_tmp(dir) downloads every file under a prefix locally.

Worth knowing: the prefixes cache has no expiry/invalidation โ€” if the underlying S3 structure changes, it goes stale until something manually clears it, and ls silently returns nil for an uncached (possibly newly-added) directory rather than re-scanning.