Skip to content

Commit

Permalink
Merging in the major changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
augustjohnson committed Jun 17, 2024
1 parent 1f3a175 commit 6a6b6d1
Show file tree
Hide file tree
Showing 121 changed files with 27,478 additions and 28,548 deletions.
36 changes: 14 additions & 22 deletions api_v2/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,36 @@ class ItemModelAdmin(admin.ModelAdmin):
list_display = ['key', 'name']


class TraitInline(admin.TabularInline):
model = Trait


class RaceAdmin(admin.ModelAdmin):
inlines = [
TraitInline,
]


class CapabilityInline(admin.TabularInline):
model = Capability
class FeatBenefitInline(admin.TabularInline):
model = FeatBenefit
exclude = ('name',)


class FeatAdmin(admin.ModelAdmin):
inlines = [
CapabilityInline,
FeatBenefitInline
]
list_display = ['key', 'name']


class TraitInline(admin.TabularInline):
model = Trait
class RaceTraitInline(admin.TabularInline):
model = RaceTrait


class RaceAdmin(admin.ModelAdmin):
inlines = [
TraitInline,
RaceTraitInline,
]


class BenefitInline(admin.TabularInline):
model = Benefit
class BackgroundBenefitInline(admin.TabularInline):
model = BackgroundBenefit


class BackgroundAdmin(admin.ModelAdmin):
model = Background
inlines = [
BenefitInline
BackgroundBenefitInline
]

class DamageTypeAdmin(admin.ModelAdmin):
Expand Down Expand Up @@ -98,6 +88,8 @@ class LanguageAdmin(admin.ModelAdmin):

admin.site.register(Condition)

admin.site.register(FeatureItem)
admin.site.register(Feature)
admin.site.register(CharacterClass)
admin.site.register(ClassFeatureItem)
admin.site.register(ClassFeature)
admin.site.register(CharacterClass)

admin.site.register(Environment)
3 changes: 2 additions & 1 deletion api_v2/management/commands/buildindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def load_v1_content(self, model):

def load_v2_content(self, model):
results = []
standard_v2_models = ['Item','Spell','Creature','CharacterClass','Race','Feat','Condition','Background']
standard_v2_models = ['Item','Spell','Creature','CharacterClass','Race','Feat','Condition','Background','Environment']

if model.__name__ in standard_v2_models:
for o in model.objects.all():
Expand Down Expand Up @@ -149,6 +149,7 @@ def handle(self, *args, **options):
self.load_content(v2.Feat,"v2")
self.load_content(v2.Condition,"v2")
self.load_content(v2.Background,"v2")
self.load_content(v2.Environment,"v2")

# Take the content table's current data and load it into the index.
self.load_index()
Expand Down
34 changes: 7 additions & 27 deletions api_v2/management/commands/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,16 @@ def handle(self, *args, **options) -> None:

for model in app_models:
SKIPPED_MODEL_NAMES = ['Document', 'Ruleset', 'License', 'Publisher','SearchResult']
CHILD_MODEL_NAMES = ['Trait', 'Capability', 'Benefit', 'FeatureItem', 'CastingOption']
CHILD_MODEL_NAMES = ['RaceTrait', 'FeatBenefit', 'BackgroundBenefit', 'ClassFeatureItem', 'SpellCastingOption','CreatureAction']
CHILD_CHILD_MODEL_NAMES = ['CreatureActionAttack']

if model._meta.app_label == 'api_v2' and model.__name__ not in SKIPPED_MODEL_NAMES:
modelq=None
if model.__name__ in CHILD_CHILD_MODEL_NAMES:
modelq = model.objects.filter(parent__parent__document=doc).order_by('pk')
if model.__name__ in CHILD_MODEL_NAMES:
if model.__name__ == 'Trait':
modelq = model.objects.filter(race__document=doc).order_by('pk')
if model.__name__ == 'Capability':
modelq = model.objects.filter(feat__document=doc).order_by('pk')
if model.__name__ == 'Benefit':
modelq = model.objects.filter(background__document=doc).order_by('pk')
if model.__name__ == 'CastingOption':
modelq = model.objects.filter(spell__document=doc).order_by('pk')
if model.__name__ == 'FeatureItem':
modelq = model.objects.filter(feature__document=doc).order_by('pk')
else:
modelq = model.objects.filter(parent__document=doc).order_by('pk')
if modelq is None:
modelq = model.objects.filter(document=doc).order_by('pk')
model_path = get_filepath_by_model(
model.__name__,
Expand Down Expand Up @@ -176,18 +171,3 @@ def write_queryset_data(filepath, queryset):
output_filepath = filepath
with open(output_filepath, 'w', encoding='utf-8') as f:
serializers.serialize("json", queryset, indent=2, stream=f)


def get_model_queryset_by_document(model, doc):
print("Getting the queryset for: {}".format(model.__name__))

if model.__name__ in ['Trait']:
return model.objects.filter(race__document=doc).order_by('pk')

if model.__name__ in ['BackgroundBenefit']:
return model.objects.filter(background__document=doc).order_by('pk')

if model.__name__ in ['FeatBenefit']:
return model.objects.filter(feat__document=doc).order_by('pk')

return model.objects.filter(document=doc).order_by('pk')
18 changes: 18 additions & 0 deletions api_v2/migrations/0074_rename_background_benefit_parent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2024-05-24 14:21

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0073_auto_20240403_0010'),
]

operations = [
migrations.RenameField(
model_name='benefit',
old_name='background',
new_name='parent',
),
]
17 changes: 17 additions & 0 deletions api_v2/migrations/0075_rename_benefit_backgroundbenefit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.20 on 2024-05-24 14:22

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0074_rename_background_benefit_parent'),
]

operations = [
migrations.RenameModel(
old_name='Benefit',
new_name='BackgroundBenefit',
),
]
23 changes: 23 additions & 0 deletions api_v2/migrations/0076_auto_20240524_1727.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.20 on 2024-05-24 17:27

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0075_rename_benefit_backgroundbenefit'),
]

operations = [
migrations.RemoveField(
model_name='backgroundbenefit',
name='id',
),
migrations.AddField(
model_name='backgroundbenefit',
name='key',
field=models.CharField(default=1, help_text='Unique key for the Document.', max_length=100, primary_key=True, serialize=False),
preserve_default=False,
),
]
17 changes: 17 additions & 0 deletions api_v2/migrations/0077_rename_featureitem_classfeatureitem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.20 on 2024-05-25 11:50

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0076_auto_20240524_1727'),
]

operations = [
migrations.RenameModel(
old_name='FeatureItem',
new_name='ClassFeatureItem',
),
]
17 changes: 17 additions & 0 deletions api_v2/migrations/0078_rename_feature_classfeature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.20 on 2024-05-25 11:52

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0077_rename_featureitem_classfeatureitem'),
]

operations = [
migrations.RenameModel(
old_name='Feature',
new_name='ClassFeature',
),
]
23 changes: 23 additions & 0 deletions api_v2/migrations/0079_auto_20240525_1155.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.20 on 2024-05-25 11:55

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0078_rename_feature_classfeature'),
]

operations = [
migrations.RenameField(
model_name='classfeature',
old_name='characterclass',
new_name='parent',
),
migrations.RenameField(
model_name='classfeatureitem',
old_name='feature',
new_name='parent',
),
]
23 changes: 23 additions & 0 deletions api_v2/migrations/0080_auto_20240525_1218.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.20 on 2024-05-25 12:18

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0079_auto_20240525_1155'),
]

operations = [
migrations.RemoveField(
model_name='classfeatureitem',
name='id',
),
migrations.AddField(
model_name='classfeatureitem',
name='key',
field=models.CharField(default=1, help_text='Unique key for the Document.', max_length=100, primary_key=True, serialize=False),
preserve_default=False,
),
]
17 changes: 17 additions & 0 deletions api_v2/migrations/0081_rename_capability_featbenefit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.20 on 2024-05-27 15:57

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0080_auto_20240525_1218'),
]

operations = [
migrations.RenameModel(
old_name='Capability',
new_name='FeatBenefit',
),
]
18 changes: 18 additions & 0 deletions api_v2/migrations/0082_rename_feat_featbenefit_parent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2024-05-27 16:02

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0081_rename_capability_featbenefit'),
]

operations = [
migrations.RenameField(
model_name='featbenefit',
old_name='feat',
new_name='parent',
),
]
17 changes: 17 additions & 0 deletions api_v2/migrations/0083_rename_trait_racetrait.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.20 on 2024-05-27 16:36

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0082_rename_feat_featbenefit_parent'),
]

operations = [
migrations.RenameModel(
old_name='Trait',
new_name='RaceTrait',
),
]
18 changes: 18 additions & 0 deletions api_v2/migrations/0084_rename_race_racetrait_parent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2024-05-27 16:40

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0083_rename_trait_racetrait'),
]

operations = [
migrations.RenameField(
model_name='racetrait',
old_name='race',
new_name='parent',
),
]
17 changes: 17 additions & 0 deletions api_v2/migrations/0085_rename_castingoption_spellcastingoption.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.20 on 2024-05-27 16:59

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0084_rename_race_racetrait_parent'),
]

operations = [
migrations.RenameModel(
old_name='CastingOption',
new_name='SpellCastingOption',
),
]
18 changes: 18 additions & 0 deletions api_v2/migrations/0086_rename_spell_spellcastingoption_parent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2024-05-27 17:03

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0085_rename_castingoption_spellcastingoption'),
]

operations = [
migrations.RenameField(
model_name='spellcastingoption',
old_name='spell',
new_name='parent',
),
]
Loading

0 comments on commit 6a6b6d1

Please sign in to comment.