27 Commits

Author SHA1 Message Date
google-labs-jules[bot]
460daf36f9 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>
2025-11-30 15:05:13 +10:30
google-labs-jules[bot]
13a8276313 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>
2025-11-30 14:47:46 +10:30
google-labs-jules[bot]
449ab1f6c0 Add ability to create companion plantings
This change adds the ability for crop wranglers to create and manage companion plantings for crops.

- Adds a `source_url` to the `CropCompanion` model to store an optional reference URL.
- Restricts the management of companion plantings to users with the `crop_wrangler` role.
- Creates a new admin interface for managing companion plantings for a specific crop.
- Updates the crop show page to display companions from both the crop and its parent crop.
2025-09-21 00:49:11 +00:00
Daniel O'Connor
b77df88df9 Issues/1475: Ensure we have pagination (#3193)
* Paginate, 100 at a time

* Limited i18n

* Paginate roles

* Pagination

* Pagination

* i18n and pagination

* Paginate alternate names

* Silence code climate

* Rewrite coverage as a feature

* Remove coverage in favour of crops/scientific_name_spec

* Add missing admin link

* Rewrite coverage as feature

* Rewrite coverage

---------

Co-authored-by: Brenda Wallace <brenda@wallace.net.nz>
2024-01-21 14:19:36 +10:30
Daniel O'Connor
a8b8a58f33 Various rspec autocorrections 2022-11-08 00:09:50 +10:30
Brenda
7257b2ada1 Update with frozen literals 2020-01-10 16:50:52 +13:00
Brenda Wallace
abd91fa37b Use bang! to indicate method can explode 2019-10-21 14:43:46 +13:00
Brenda Wallace
fc07571ee1 Rename is_admin? to admin?. 2019-10-19 10:25:17 +13:00
Brenda Wallace
5a6d0f6342 Check admin before roles controller runs 2019-10-19 10:22:27 +13:00
Brenda Wallace
2ddddb1652 Updated specs for admin editing roles 2019-10-19 10:16:02 +13:00
codefactor-io
6d472c5d66 [CodeFactor] Apply fixes 2019-10-07 23:35:39 +00:00
Brenda Wallace
3422a0d899 Administer member's roles 2019-10-06 14:19:39 +13:00
Brenda Wallace
b3520a1b3f Search for members in admin/members#index 2019-08-20 15:09:39 +00:00
Brenda Wallace
eda3639708 Discard members on ban 2019-07-21 17:23:28 +12:00
Brenda Wallace
c8e47e800e Moved admin ban code to admin controler 2019-07-16 20:54:32 +12:00
Brenda Wallace
b2537638ed Move member banning to admin/members controller 2019-07-16 18:56:49 +12:00
Brenda Wallace
42de726405 Removing shop, products, accounts, orders 2018-02-09 10:53:05 +13:00
Brenda Wallace
25d2773464 Use nested module/class definitions instead of compact style. 2017-12-17 17:50:30 +13:00
Brenda Wallace
8a446ecbfc Member admin 2017-12-17 12:45:19 +13:00
Brenda Wallace
40a981c94d Removed unnecesary braces on hash args 2017-01-22 15:10:11 +13:00
Brenda Wallace
723ebff923 Spacing fixes 2016-11-26 12:13:17 +13:00
Brenda Wallace
62e7c716dd Removed extra empty blank lines 2016-11-26 12:06:02 +13:00
Daniel O'Connor
4b4e0cf69a $ rubocop --only HashSyntax --auto-correct
483 files inspected, 2018 offenses detected, 2018 offenses corrected
2016-05-19 15:53:11 -04:00
Skud
1adcedb534 moved admin order search into a model method 2013-09-13 13:38:11 +10:00
Skud
6c8f2b477f minor tweakage to admin/order/search 2013-06-04 21:15:29 +10:00
Skud
39d1a74745 misc tidying up 2013-06-04 20:27:56 +10:00
Skud
cbca8c19a5 added admin controller and index view 2013-05-31 10:23:06 +10:00