Commit Graph
55 Commits
Author SHA1 Message Date
Brenda Wallace f2fa894ea3 Add packet_text attribute and authorization logic to SeedResource; implement request specs for packet text writing 2026-10-28 23:38:18 +13:00
Brenda Wallace 61552c13d3 Refactor pagination logic to ensure offset is treated as an integer and update API base URL for Codespaces 2026-10-26 17:28:28 +13:00
Brenda Wallace d3f61775b4 Enhance job validation and resource authorization for gardens; add tests for job creation and linking 2026-10-25 19:04:05 +13:00
Brenda Wallace 1135c763de Tidy API resources: read_only and owned macros, private hook helpers
Declare read-only resources and the owner relationship once each, make
the resource hook helpers private, simplify token auth, and cache the
generated API docs for an hour.
2026-10-25 11:48:28 +13:00
Brenda Wallace 086140205d fixing authorize in the APi 2026-10-25 11:44:02 +13:00
Brenda Wallace e7387a37e0 Add API tests for dashed keys, resource ownership, and write operations
- Implement tests for handling dashed attribute names in API responses and requests in `dashed_keys_request_spec.rb`.
- Enhance error handling tests in `errors_request_spec.rb` for invalid filters and attributes.
- Refactor garden, harvest, and seed request specs to use shared examples for resource write operations.
- Introduce shared examples in `api_writes.rb` to streamline testing of create, update, and delete actions across various resources.
- Update pagination and sorting tests to include new scenarios for offsets and computed attributes.
- Remove redundant code and improve test clarity by utilizing shared contexts and helper methods.
2026-10-24 18:19:11 +13:00
Brenda Wallace 200514c5cc Refactor API controllers and resources to remove redundant resource_class assignments and improve parameter handling in API documentation 2026-10-24 18:19:11 +13:00
Brenda Wallace 73f62d4983 Add API resources for photos, plantings, and seeds; update application configuration
- Introduced `PhotoResource`, `PlantingResource`, and `SeedResource` to manage respective models.
- Updated application configuration to include API base URL.
- Modified production and test environments to set API base URL dynamically.
- Removed outdated JSONAPI resources initializers and patches.
- Refactored routes to use resourceful routing for API endpoints.
- Updated request specs to reflect changes in API responses and relationships.
- Added helper methods for generating related links in request specs.
2026-10-24 18:19:11 +13:00
Brenda Wallace 1266c0e537 Add action attribute to Job model and update related files 2026-10-23 21:04:21 +13:00
Brenda Wallace d7d14cf65e Implement job linking functionality with crop suggestions and UI enhancements 2026-10-22 17:59:27 +13:00
Brenda Wallace a0b24381ac Refactor activities to jobs across the application
- Renamed all instances of 'Activity' to 'Job' in views, controllers, and models.
- Updated routes to reflect the change from activities to jobs.
- Modified database schema to rename the activities table to jobs and adjusted related columns.
- Updated locale files to change activity-related translations to jobs.
- Adjusted tests to ensure they reference jobs instead of activities.
- Removed the category field from jobs as they are now a plain list.
- Updated seed data and sample data generation to create jobs instead of activities.
2026-10-22 17:16:25 +13:00
Brenda Wallace 77bf9d5e92 Rename activities to jobs and update related files for consistency 2026-10-22 17:06:55 +13:00
Daniel O'Connor d9851231f2 Merge pull request #4274 from Growstuff/CloCkWeRX-patch-3
API > Render activities links under member
2025-09-29 01:11:24 +09:30
Daniel O'Connor 81b80d9bb7 Update activity_resource.rb 2025-09-29 00:12:51 +09:30
Daniel O'Connor f080a8a566 Update crop_resource.rb 2025-09-29 00:12:39 +09:30
Daniel O'Connor 5a436f9d7f Update garden_resource.rb 2025-09-29 00:12:32 +09:30
Daniel O'Connor a4fd1c4a8e Update harvest_resource.rb 2025-09-29 00:12:27 +09:30
Daniel O'Connor 7277cb3523 Update seed_resource.rb 2025-09-29 00:12:07 +09:30
Daniel O'Connor 522d10e053 Update photo_resource.rb 2025-09-29 00:11:41 +09:30
Daniel O'Connor f3a9b26c8e Update planting_resource.rb 2025-09-29 00:10:05 +09:30
google-labs-jules[bot] d8f5580ef9 Extend planting API to render garden id in relationships 2025-09-28 14:39:33 +00:00
Daniel O'Connor 54acc369ab Rubocop 2025-09-20 09:43:22 +00:00
google-labs-jules[bot]andDaniel O'Connor 02db5b8130 Add API token generation, authentication, and CRUD for a number of the API resources (#4237)
* feat: Add API token generation and authentication

This commit introduces API token generation and authentication for write operations.

- Adds a section to the user's profile edit page to generate and display an API token.
- Reuses the `authentications` table to store the API token, avoiding the need for a database migration.
- Implements token-based authentication for the API using the `Authorization: Token token=...` header.
- Enables write operations for all API resources and ensures they are protected by the new authentication mechanism.
- Adds feature and request specs to test the new functionality.

* feat: Add API token generation and authentication

This commit introduces API token generation and authentication for write operations.

- Adds a section to the user's profile edit page to generate and display an API token.
- Reuses the `authentications` table to store the API token, avoiding the need for a database migration.
- Implements token-based authentication for the API using the `Authorization: Token token=...` header.
- Enables write operations for all API resources and ensures they are protected by the new authentication mechanism.
- Adds feature and request specs to test the new functionality.

* Mark as editable

* Refactor

* WIP - Authentication

* Implement more test coverage

* Split 401 and 403

* Before Create hooks

* Update harvest specs, defaulting to the first plant part - this may not be right

* Update coverage

* Update coverage

* Rubocop

* Rubocop

* Rubocop

* Fix coverage

* For now, mark photos immutable again

* Fix specs

* Fix specs

* Rubocop

* Fix 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-09-10 19:50:06 +09:30
google-labs-jules[bot] e5c71f1dc4 Merge pull request #4230 from Growstuff/feature/add-more-filters
feat: Add more filters to API resources
2025-09-09 21:34:49 +09:30
Daniel O'Connor a21a9e7a09 Update garden_resource to filter by owner 2025-09-08 17:38:03 +09:30
google-labs-jules[bot] ba6ec689c5 Merge pull request #4150 from Growstuff/feature/failed-plantings
Add failed status to plantings
2025-08-27 23:42:53 +09:30
Daniel O'Connor 260f19e047 Add tests #3401 - wrong resources loaded (#3045)
* Prove broken

* Allow filter by owner id

* Specify FK

* Mark pending, and cover filter by member
2022-05-01 17:09:13 +09:30
Brenda Wallace 3604acdb67 Added crop.parent back into api 2020-06-15 10:34:35 +12:00
Brenda Wallace e10e4285ce Comment our crop parent on api resource until we can specify the model 2020-06-03 15:30:13 +12:00
Brenda 7257b2ada1 Update with frozen literals 2020-01-10 16:50:52 +13:00
Brenda Wallace 76ee0c1cd8 rubocop lint 2019-11-19 13:58:16 +13:00
Brenda Wallace 0c3149205b Put resources back into namespaces 2019-11-19 13:53:12 +13:00
Brenda Wallace 8fb4725f46 Merge remote-tracking branch 'upstream/dev' into api-docs
Conflicts:
	app/resources/api/v1/planting_resource.rb
2019-11-18 10:26:05 +13:00
Brenda Wallace 4f8830676e Swagger docs 2019-11-18 10:15:06 +13:00
Brenda Wallace 818a980f6d Move jsonapi resources files 2019-11-18 10:11:53 +13:00
Brenda Wallace df5b0499e4 Update spec for api resource 2019-11-16 13:05:40 +13:00
Brenda Wallace 535ddcdcff Added plantings to places map 2019-11-16 12:16:18 +13:00
Miles Gould ba1512a85a Delete duplicate percentage_grown attribute
Fixes #2031
2019-07-05 10:49:29 +00:00
Brenda Wallace 62f2fa134d Set planting.finished as a boolean 2019-03-20 15:01:33 +13:00
Brenda Wallace d07c97b6a6 Add filters for the members api 2019-03-20 15:01:33 +13:00
Brenda Wallace 572af9d135 Merge branch 'dev' into photos/seeds 2019-02-09 17:00:58 +13:00
Brenda Wallace 9a4f1058e1 Adding more attributes and filters to the api 2019-02-09 08:43:59 +13:00
Brenda Wallace 6167af700d Rubocop lint tidy 2019-02-05 12:37:09 +13:00
Brenda Wallace 18ab0c8697 Add photos back into crop resources 2019-02-05 10:22:58 +13:00
Brenda Wallace dbf707d80e Crops have seeds 2019-02-04 20:32:23 +13:00
Brenda Wallace c4a1806a87 Request spec for photos api 2017-11-17 22:01:37 +13:00
Brenda Wallace 5fec826c41 Add more attributes to crops 2017-11-13 19:19:18 +13:00
Brenda Wallace d8f5876518 Added predictions to planting api, and added specs 2017-11-13 19:19:18 +13:00
Brenda Wallace c9d5c42814 Plantings have many harvests 2017-11-13 19:19:18 +13:00
Brenda Wallace b60f47f502 Add more relationships to members on the api 2017-11-13 19:19:18 +13:00