Skip to content

Feature: split V2 Item model into Item and MagicItem models#889

Merged
calumbell merged 4 commits into
open5e:stagingfrom
calumbell:feature/magicitem-model
Apr 5, 2026
Merged

Feature: split V2 Item model into Item and MagicItem models#889
calumbell merged 4 commits into
open5e:stagingfrom
calumbell:feature/magicitem-model

Conversation

@calumbell
Copy link
Copy Markdown
Contributor

Description

This PR takes the Item endpoint and splits it into Item (for mundane items) and MagicItem (for magic items)

This work was undertaken because of issues encountered while working on the implementation of crossreferences (PR #876). With the current setup of the API, it was not possible to create crossreferences to the /magicitems endpoint because it is an alias of the /items, and there is no distinct Magic Items table in the DB. This meant that the front-end would need to perform and additional fetch for each magic item crossreference on a page to put together the link, which would be very slow and inefficient.

Both Item and MagicItem inherit from the same abstract base class BaseItem, which stores all the fields ones would expect any item to have (the Item endpoint doesn't actually add any additional fields to the base-class). Therefore, for API consumers, any application that works with Item data (ie. an inventory management system) should be able to easily substitute a MagicItem in place of an Item because the former contains all fields defined in the later.

Note to reviewers

The large number of lines changed is due to our existing Item data getting split into mundane and magic items. You can see how this was achieved by checking out the split_magic_mundane_items_v2.py script in scripts/data_manipulation/converters/

Probably a better use of your time to focus on the changes made to V2 Models, Serializers and Views.

Other notes

While working on this PR I encountered a bug with Django getting V1 and V2 endpoints mixed up (more details #888). Instead of fixing this bug here, I have updated updated the V1 test_root approved file data to reflect the new shape of the API response, but that doesn't mean it is at a point where we wnt it to be.

@calumbell calumbell merged commit a0194df into open5e:staging Apr 5, 2026
3 checks passed
Copilot AI mentioned this pull request Apr 14, 2026
3 tasks
eepMoody added a commit that referenced this pull request Apr 15, 2026
* fixed parsing reaction conditions without parentheses (#842)

* Fix spell data regressions and omissions (#844)

* Fix spell data regressions from PR #842 and update newrelic API

* add missing higher-leve options

* add tests for duplicate or missing higher_level values

* Add missing casting options for deepm and spells-that-dont-suck

* fix freezing sphere being merged with freedom of movement

* Convert distance fields to integer (#845)

* Fix spell data regressions from PR #842 and update newrelic API

* add missing higher-leve options

* add tests for duplicate or missing higher_level values

* Add missing casting options for deepm and spells-that-dont-suck

* fix freezing sphere being merged with freedom of movement

* convert ambiguously precise fields to integers

* update test cases to reflect integers

* update decimal speed fallbacks

* fixed bugs in srd-2024 CreatureAction data (closes #847) (#849)

* fixed markdown errors in Creature spellcasting traits/actions (#855)

* updated srd-2014 dragon breath weapon recharge data (closes #848) (#853)

* removed prepended asterisks from toh/tdcs FeatBenefit 'desc' fields (closes #851) (#852)

* fixed bugs in srd-2024 spell markdown (closes #857)

* updated monster conversion script to scrap input md for bonus actions and reactions

* added missing srd-2024 creature reactions

* removed Mithral and Adamantine Hide Armor from srd-2014 dataset (closes #829)

* bugfix: added missing dash to bfrd mechanist starting equipment markdown

* added 2024 champion subclass data to ClassFeatureItem.json

* added srd-2024 College of Lore data to ClassFeatureItem.json

* replaced casting_times of 'bonus_action' w/ 'bonus-action' as per model spec

* wrote exclude_fields_mixin (and mvd mixins to own dir)

* added ExcludeFieldsMixin to model viewsets

* added missing srd-2024 dragon attack data to CreatureAttackAction

* removed /manifest from url, updated test cases to reflect rmvl

* rmv'd ManifestViewSet

* removed ManifestSerializer

* removed Manifest model

* rmv'd manifest from v1 API schema

* removed /version endpoint

* added character creation rules from srd-2024 (#878)

* Added filter on monsters for environments (#884)

* fixed typo in srd-2024 Adult Green Dragon spellcasting action (#891)

* [BUGFIX] Fixed data errors on `/v2/rulesets/srd_combat-sequence` (#893)

* removed references to <srd:opportunity-attacks> in all open5e data

* fixed ruleset/srd_combat-sequence blockquote markdown

* added missing ClassFeatureItem for Fighter two extra attacks action (#895)

* removed server/vector_index.pkl from repo (#883)

* removed leading slashes on Image file_urls (#886)

* [CI/CD] Upgrade Github Action versions to Node 24 compatable versions (#901)

* updated checkout github action to v6

* updated setup-python gh action to v6

* updated upload-artifact gh action to v6

* updated build-push-action gh action to v7

* Feature: split V2 Item model into Item and MagicItem models (#889)

* split v2 Item endpoint into Item and MagicItem endpoints

* removed vector_index from commit

* rmv'd accidently commited DDT config

* updated buggy test case, see issue #888

* [BUGFIX] `GameContentSerializer` now inherits from `ModelSerializer` (#899)

* GameContentSerializer now inherits from ModelSerializer

* removed 'url' from GameContent Meta->fields prop

* updated v2 tests to reflect removal of URL from many responses

* fixed failing test

* rmvd url field from MagicItemSerializer

* Bugfix: seperated mixed up V1/V2 endpoints (#890)

* updated api/urls.py to stop v1 and v2 endpoints getting mixed up

* updated v1 tests to check against endpoints behind /v1/ subroute

* [BUGFIX] Fixed EagerLoadingMixin early return error (#898)

* fixed bug in EagerLoadingMixin conditional logic, closes #897

* fixed EagerLoadingMixin missing base case, added docstring

* Bump django from 5.2.1 to 5.2.12 (#904)

Bumps [django](https://github.com/django/django) from 5.2.1 to 5.2.12.
- [Commits](django/django@5.2.1...5.2.12)

---
updated-dependencies:
- dependency-name: django
  dependency-version: 5.2.12
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump requests from 2.32.3 to 2.33.0 (#905)

Bumps [requests](https://github.com/psf/requests) from 2.32.3 to 2.33.0.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](psf/requests@v2.32.3...v2.33.0)

---
updated-dependencies:
- dependency-name: requests
  dependency-version: 2.33.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump urllib3 from 2.4.0 to 2.6.3 (#906)

Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.4.0 to 2.6.3.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](urllib3/urllib3@2.4.0...2.6.3)

---
updated-dependencies:
- dependency-name: urllib3
  dependency-version: 2.6.3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump django from 5.2.12 to 5.2.13 (#908)

Bumps [django](https://github.com/django/django) from 5.2.12 to 5.2.13.
- [Commits](django/django@5.2.12...5.2.13)

---
updated-dependencies:
- dependency-name: django
  dependency-version: 5.2.13
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fixed bug in srd-2014 skeleton resistances/immunities (#907)

* fixed markdown bugs in srd-2014 brass dragons (#912)

* updated srd-2024 goliath giant ancestry markdown: added missing list bullets (#909)

* consolidated CRs into single 'challenge_rating' field (#910)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Blake Watson <blake@blakewatson.com>
Co-authored-by: calum <47755775+calumbell@users.noreply.github.com>
Co-authored-by: calumbell <calumabell@googlemail.com>
Co-authored-by: August Johnson <augustjohnson@users.noreply.github.com>
Co-authored-by: Steven Noto <stevennoto@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants