Repository navigation
Olivia/28-add-villages-and-supplyitems - #38
Open
oliviamrkw wants to merge 6 commits into
Open
oliviamrkw wants to merge 6 commits into
oliviamrkw wants to merge 6 commits into
Conversation
oliviamrkw
requested review from
CaellumYHL,
FakeDeepLearner and
Ginni-2007
and removed request for
FakeDeepLearner
November 22, 2026 19:55
CaellumYHL
requested changes
Nov 27, 2026
CaellumYHL
left a comment
Collaborator
There was a problem hiding this comment.
Overall looks good, just a couple nit-picks before it's ready to merge.
| class Village(StandardModel): | ||
| """A village within a region. Sites can optionally be linked to one.""" | ||
|
|
||
| region = models.ForeignKey(Region, on_delete=models.PROTECT, related_name="villages") |
Collaborator
There was a problem hiding this comment.
Could you prevent changing a village’s region when it would cause linked farms to point to a different region? Right now moving a village from Atlántida to Yoro leaves its existing farms pointing to Atlántida so the location data is inconsistent.
| villages = {} | ||
| for region_name, names in VILLAGES.items(): | ||
| for name in names: | ||
| village, _ = Village.objects.get_or_create(region=regions[region_name], name=name) |
Collaborator
There was a problem hiding this comment.
Could you use case-insensitive name lookups here and in the supply-item lookup? So that we dont have to worry about capitals messing up the database models
3 of 5 tasks
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.
What this changes
Closes #27
Village(unique name per region, ignoring case) and an optionalvillageonSite, which must be in the site's regionSupplyItem.quantity_kindcomes from the unit (count= positive whole numbers,measure= positive decimals) and is not editablevillage({id, name, region}ornull)GET /api/supply-items/(login required, active items only)seed_projects, plus migration0002_village_supplyitem.pyand testsHow to test it
docker compose up -dfrom the repo rootdocker compose exec backend python src/manage.py migrate accountsdocker compose exec backend python src/manage.py migrate admindocker compose exec backend python src/manage.py migrate sessionsdocker compose exec backend python src/manage.py migrate projectsdocker compose exec backend python src/manage.py seed_projects, thendocker compose exec backend python src/manage.py createsuperuser/admin/, set "Finca Las Palmas" (Yoro) to the village "El Naranjo" (Atlántida). It should be rejectedGET /api/supply-items/returns 401 logged out and 5 active items with a token.GET /api/projects/1/sites/showsvillageon each farm (nullfor Finca Las Palmas)docker compose exec backend python -m pytest tests/test_village_supply_models.py tests/test_village_supply_api.py --nomigrations(51 passed)Checklist
cd backend && python -m pytest).env, credentials, or LAN IP in the diffNotes for the reviewer
projects/0001, so it should rebase onto this branch