Skip to content

Commit

Permalink
Stable item category.
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Nov 5, 2023
1 parent 157ad5e commit 966d738
Show file tree
Hide file tree
Showing 10 changed files with 1,887 additions and 1,793 deletions.
3 changes: 2 additions & 1 deletion api_v2/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class FromDocumentModelAdmin(admin.ModelAdmin):


class ItemModelAdmin(admin.ModelAdmin):
list_display = ['key', 'category', 'name']
list_display = ['key', 'name']


class TraitInline(admin.TabularInline):
Expand Down Expand Up @@ -77,6 +77,7 @@ class LanguageAdmin(admin.ModelAdmin):
admin.site.register(Weapon, admin_class=FromDocumentModelAdmin)
admin.site.register(Armor, admin_class=FromDocumentModelAdmin)

admin.site.register(ItemCategory)
admin.site.register(Item, admin_class=ItemModelAdmin)
admin.site.register(ItemSet, admin_class=FromDocumentModelAdmin)

Expand Down
18 changes: 18 additions & 0 deletions api_v2/migrations/0023_rename_category_item_category_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2023-11-04 23:57

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0022_condition'),
]

operations = [
migrations.RenameField(
model_name='item',
old_name='category',
new_name='category_text',
),
]
23 changes: 23 additions & 0 deletions api_v2/migrations/0024_itemcategory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.20 on 2023-11-05 00:06

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0023_rename_category_item_category_text'),
]

operations = [
migrations.CreateModel(
name='ItemCategory',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Name of the item.', max_length=100)),
],
options={
'abstract': False,
},
),
]
23 changes: 23 additions & 0 deletions api_v2/migrations/0025_auto_20231105_0009.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.20 on 2023-11-05 00:09

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0024_itemcategory'),
]

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

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0025_auto_20231105_0009'),
]

operations = [
migrations.AddField(
model_name='itemcategory',
name='document',
field=models.ForeignKey(default='srd', on_delete=django.db.models.deletion.CASCADE, to='api_v2.document'),
preserve_default=False,
),
migrations.AlterField(
model_name='itemcategory',
name='key',
field=models.CharField(help_text='Unique key for the Item.', max_length=100, primary_key=True, serialize=False),
),
]
1 change: 1 addition & 0 deletions api_v2/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from .abilities import Abilities

from .item import ItemCategory
from .item import Item
from .item import ItemSet

Expand Down
5 changes: 4 additions & 1 deletion api_v2/models/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from .abstracts import Object, HasName, HasDescription
from .document import FromDocument

class ItemCategory(HasName, FromDocument):
"""A class describing categories of items."""
pass

class Item(Object, HasDescription, FromDocument):
"""
Expand Down Expand Up @@ -61,7 +64,7 @@ class Item(Object, HasDescription, FromDocument):
('tools', 'Tools')
]

category = models.CharField(
category_text = models.CharField(
null=False,
choices=CATEGORY_CHOICES,
max_length=100,
Expand Down
2 changes: 1 addition & 1 deletion api_v2/views/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Meta:
'weight': ['exact', 'range', 'gt', 'gte', 'lt', 'lte'],
'rarity': ['exact', 'in', ],
'requires_attunement': ['exact'],
'category': ['in', 'iexact', 'exact'],
#'category': ['in', 'iexact', 'exact'],
'document__key': ['in','iexact','exact']
}

Expand Down
Loading

0 comments on commit 966d738

Please sign in to comment.