From 0471e8031f59e57e1a8123f7bde60820d8568d76 Mon Sep 17 00:00:00 2001 From: Conrad Date: Fri, 24 Jan 2020 07:33:50 +0100 Subject: [PATCH] Moved wear to itemtype --- src/core/admin.py | 4 +-- .../migrations/0008_auto_20200124_0556.py | 28 +++++++++++++++++++ src/core/models.py | 9 +++--- src/core/steam_api.py | 2 +- 4 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 src/core/migrations/0008_auto_20200124_0556.py diff --git a/src/core/admin.py b/src/core/admin.py index 4d3e029..1f3cb6f 100644 --- a/src/core/admin.py +++ b/src/core/admin.py @@ -5,7 +5,7 @@ from .models import ItemType, ItemInstance, Badge, Gamer # Register your models here. @admin.register(ItemType) class ItemTypeAdmin(admin.ModelAdmin): - list_display = ('paint_index', 'name', 'type', 'rarity', 'min_float', 'max_float', 'tradable') + list_display = ('paint_index', 'wear', 'name', 'type', 'rarity', 'min_float', 'max_float', 'tradable') list_editable = () @@ -16,7 +16,7 @@ class GamerAdmin(admin.ModelAdmin): @admin.register(ItemInstance) class ItemInstanceAdmin(admin.ModelAdmin): - list_display = ('item_class', 'instanceid', 'market_tradable_restriction', 'inspect_link', 'wear', 'float', 'paintseed', 'killeatervalue', 'customname') + list_display = ('item_class', 'instanceid', 'market_tradable_restriction', 'inspect_link', 'float', 'paintseed', 'killeatervalue', 'customname') @admin.register(Badge) diff --git a/src/core/migrations/0008_auto_20200124_0556.py b/src/core/migrations/0008_auto_20200124_0556.py new file mode 100644 index 0000000..23179c9 --- /dev/null +++ b/src/core/migrations/0008_auto_20200124_0556.py @@ -0,0 +1,28 @@ +# Generated by Django 3.0.2 on 2020-01-24 05:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0007_remove_gamer_api_key'), + ] + + operations = [ + migrations.RemoveField( + model_name='iteminstance', + name='wear', + ), + migrations.AddField( + model_name='itemtype', + name='wear', + field=models.CharField(default='Factory-New', max_length=100), + preserve_default=False, + ), + migrations.AlterField( + model_name='offer', + name='items_want', + field=models.ManyToManyField(related_name='WantedItems', to='core.ItemType'), + ), + ] diff --git a/src/core/models.py b/src/core/models.py index d7d14db..08e848d 100644 --- a/src/core/models.py +++ b/src/core/models.py @@ -19,6 +19,7 @@ BADGE_RARITIES = [ # Storing the classes of items for quick selection in some menues class ItemType(models.Model): paint_index = models.IntegerField(primary_key=True, unique=True) # Skin + wear = models.CharField(max_length=100) # tags > category = exterior > localized_tag_name classid = models.IntegerField() # Weapon Class appid = models.IntegerField() # The appid which items of this type belong to @@ -45,10 +46,10 @@ class ItemInstance(models.Model): instanceid = models.IntegerField(primary_key=True, unique=True) # 0 for something like cases, which will be excluded here market_tradable_restriction = models.CharField(max_length=1, null=True) # How long the item will be trade locked | null is not tradelocked inspect_link = models.URLField(max_length=512) - wear = models.CharField(max_length=100) # tags > category = exterior > localized_tag_name + float = models.FloatField() # Float of the object - paintseed = models.IntegerField() # Pattern ID - killeatervalue = models.IntegerField(null=True) # StatTrack | null is no StatTrack + paintseed = models.IntegerField() # Pattern ID | Migrate to type? + killeatervalue = models.IntegerField(null=True) # StatTrack | null is no StatTrack | Migrate to type? customname = models.CharField(max_length=128, null=True) # Nametag | null is no Nametag stickers = models.ManyToManyField(Stickers) @@ -103,7 +104,7 @@ class Gamer(models.Model): class Offer(models.Model): offeror = models.ForeignKey(Gamer, on_delete=models.CASCADE) items_give = models.ManyToManyField(ItemInstance, related_name='OfferedItems') - items_want = models.ManyToManyField(ItemInstance, related_name='WantedItems') + items_want = models.ManyToManyField(ItemType, related_name='WantedItems') created_at = models.DateTimeField(auto_now_add=True) diff --git a/src/core/steam_api.py b/src/core/steam_api.py index ea59d65..873ed41 100644 --- a/src/core/steam_api.py +++ b/src/core/steam_api.py @@ -61,6 +61,7 @@ def updateInventory(steamID, GAME_ID=730): break item_class = ItemType.objects.get_or_create( paint_index=item_infos['iteminfo']['paintindex'], + wear=item_infos['iteminfo']['wear_name'], classid=item['classid'], appid=item['appid'], tradable=(True if item['marketable'] == 1 else False), @@ -78,7 +79,6 @@ def updateInventory(steamID, GAME_ID=730): market_tradable_restriction=(item['owner_descriptions'][1]['value'] if 'owner_descriptions' in item else None), inspect_link=instance_data['actions'][0]['link'], - wear=item_infos['iteminfo']['wear_name'], float=item_infos['iteminfo']['floatvalue'], paintseed=item_infos['iteminfo']['paintseed'], killeatervalue=(item_infos['iteminfo']['killeatervalue'] if 'killeatervalue' in item_infos['iteminfo'] else None),