-
Notifications
You must be signed in to change notification settings - Fork 211
Add revert functionality to admin crops page #4346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This change adds a "Revert" button to the admin crops page, allowing crop wranglers to revert changes to a previous version. It introduces a new `Admin::VersionsController` with a `revert` action that uses `paper_trail`'s `reify` method to restore a previous version of a `Crop` object. The view is updated to include a "Revert" button, which is guarded by a `can?(:wrangle, Crop)` check to ensure only authorized users can see it. The controller also includes an authorization check to prevent unauthorized users from accessing the revert action directly. A feature spec is added to test the new functionality, including the authorization logic.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
* Update crops_helper.rb * feat: Add contribution links and conditional edit form This commit introduces a series of changes to encourage user contributions for missing crop data. On the crop show page, it adds links for logged-in users to: - Add a description if one is not present. - Add a YouTube video if one is not present. - Add more attributes in the predictions section if any are missing. On the crop edit page, the form now conditionally displays fields. For standard users, it only shows fields for attributes that are currently empty. For privileged users (wranglers), it displays all fields, allowing them to edit existing data. * feat: Add schema.org markup to crop pages Adds schema.org markup to the crop pages using the BioChemEntity type. The taxonomicRange attribute is used to list the scientific names of the crop, which will improve SEO. * feat: Add Wikidata ID to scientific names This commit introduces the ability to store and display the Wikidata ID for scientific names. Changes include: - A database migration to add the `wikidata_id` column to the `scientific_names` table. - An update to the `scientific_names_controller` to permit the `wikidata_id` parameter. - An update to the scientific name form to include a field for the Wikidata ID. - An update to the crop show page to display a link to the Wikidata page for a scientific name. * Delete db/migrate/20251129185029_add_wikidata_id_to_scientific_names.rb * Update _schema_org.html.haml * Move to crops helper * Add more schema.org * Specific form links * Styling * Render images * Document future * Render less on some pages * Fix rendering * Add version tracking to crops model (#4343) * feat: Add version tracking to Crop model This commit introduces version tracking for the Crop model using the PaperTrail gem. Key changes include: - Integrating `has_paper_trail` into the `Crop` model. - Adding a "History" section to the crop show page to display a timeline of changes for that specific crop. - Creating a new admin page for users with the "crop_wrangler" role to view a log of all recent crop edits, creations, and deletions. - Fixing several N+1 query performance issues by eager-loading associated `Member` records in both the `CropsController` and the new `Admin::CropsController`. - Refactoring view logic into a shared partial to reduce code duplication. * Add papertrail * Admin UI * Add papertrail DB * Add papertrail DB * Rearrange * Fix permissions * Fix permissions * Fix UI * Fix UI --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Daniel O'Connor <daniel.oconnor@gmail.com> * Add revert functionality to admin crops page (#4346) * feat(admin): add revert functionality to crops page This change adds a "Revert" button to the admin crops page, allowing crop wranglers to revert changes to a previous version. It introduces a new `Admin::VersionsController` with a `revert` action that uses `paper_trail`'s `reify` method to restore a previous version of a `Crop` object. The view is updated to include a "Revert" button, which is guarded by a `can?(:wrangle, Crop)` check to ensure only authorized users can see it. The controller also includes an authorization check to prevent unauthorized users from accessing the revert action directly. A feature spec is added to test the new functionality, including the authorization logic. * Consistent UX * Specs --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Daniel O'Connor <daniel.oconnor@gmail.com> --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This change adds a "Revert" button to the admin crops page, allowing crop wranglers to revert changes to a previous version. It includes a new controller, route, and view changes, as well as a feature spec to test the functionality and authorization.
PR created automatically by Jules for task 5607519147618842969 started by @CloCkWeRX