Skip to content
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

V2 spell class mapping #525

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api_v2/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class LanguageAdmin(admin.ModelAdmin):
admin.site.register(ItemSet, admin_class=FromDocumentModelAdmin)

admin.site.register(SpellSchool)
admin.site.register(Spell)

admin.site.register(Race, admin_class=RaceAdmin)

Expand Down
18 changes: 18 additions & 0 deletions api_v2/migrations/0113_spell_classes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2024-08-27 00:30

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0112_ability_skill'),
]

operations = [
migrations.AddField(
model_name='spell',
name='classes',
field=models.ManyToManyField(to='api_v2.CharacterClass'),
),
]
3 changes: 3 additions & 0 deletions api_v2/models/spell.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .abstracts import HasName, HasDescription
from .abstracts import distance_field, distance_unit_field
from .document import FromDocument
from .characterclass import CharacterClass


from .enums import SPELL_TARGET_TYPE_CHOICES
Expand Down Expand Up @@ -125,6 +126,8 @@ class Spell(HasName, HasDescription, FromDocument):
help_text='Whether the effect requires concentration to be maintained.',
default=False)

classes = models.ManyToManyField(CharacterClass)

def casting_options(self):
"""Options for casting the spell."""
return self.spellcastingoption_set
Expand Down
1 change: 1 addition & 0 deletions api_v2/views/spell.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Meta:
'key': ['in', 'iexact', 'exact' ],
'name': ['iexact', 'exact','contains'],
'document__key': ['in','iexact','exact'],
'classes__key': ['in','iexact','exact']
}

class SpellViewSet(viewsets.ReadOnlyModelViewSet):
Expand Down
Loading
Loading