Skip to content

Commit

Permalink
Dawntrail + Plugin Setup (#75)
Browse files Browse the repository at this point in the history
* added authtoken to settings

* add token to user serializer

* add token stuff to the frontend

* adding view and tests to create tokens for a user

* generate token working with autoreload

* updated changelog

* adding extra import names and classes for when Gear have unique names

* added initial test for plugin imports

* using new extra_import fields in import view

* add 400 test for plugin import

* don't use integrity errors to add gear / tier data. it increments the ID counter even if nothing is added

* moved ew gear files to a subdir

command updated to search through subdirs of gear path

* added placeholder file for 7.01

* updated job file, not 100% sure on names

* prepping files for 7.0x

* added placeholder tier info

* remove unused imports in seed command file

* remove changes that are later than 7.0 so we can deploy for 7.0 release

* updated changelog for 7.0 changes

* got proper 7.0 names

* fixing changelog

* fix typo

* added temp flat colour job icons for pct/vpr

* fix add extra item names command

* bump to DT release date

* bump to today since i slept instead of deploying yesterday :)

* fix tests

* add authtoken to test_settings

* update requirements for security

* Revert "update requirements for security"

This reverts commit abedc80.
  • Loading branch information
freyamade authored Jun 29, 2024
1 parent 0425f9a commit 65e9a7f
Show file tree
Hide file tree
Showing 54 changed files with 849 additions and 170 deletions.
36 changes: 36 additions & 0 deletions backend/api/management/commands/add_extra_names_to_gear.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from os import scandir
# lib
import yaml
from django.conf import settings
from django.core.management.base import BaseCommand
# local
from api import models


class Command(BaseCommand):
help = 'Add Extra Names to Gear Objects'

def handle(self, *args, **options):
gear_data_dir = settings.BASE_DIR / 'api/management/commands/seed_data/gear'

# Get Gear data, double check that the Gear has the required information
with scandir(gear_data_dir) as expac_dirs:
for expac_dir in expac_dirs:
if not expac_dir.is_dir():
continue

with scandir(expac_dir.path) as gear_files:
for file in gear_files:
with open(file, 'r') as f:
data = yaml.safe_load(f)
for item in data:
obj = models.Gear.objects.get(name=item['name'], item_level=item['item_level'])
changed = False
if len(obj.extra_import_names) == 0 and len(item.get('extra_import_names', [])) > 0:
changed = True
obj.extra_import_names = item['extra_import_names']
if len(obj.extra_import_classes) == 0 and len(item.get('extra_import_classes', [])) > 0:
changed = True
obj.extra_import_classes = item['extra_import_classes']
if changed:
obj.save()
22 changes: 12 additions & 10 deletions backend/api/management/commands/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import yaml
from django.conf import settings
from django.core.management.base import BaseCommand
from django.db import IntegrityError, transaction
# local
from api import models

Expand All @@ -22,11 +21,16 @@ def handle(self, *args, **options):
self.stdout.write(self.style.HTTP_REDIRECT('Seeding Tiers'))
self.import_file(f, models.Tier)

with scandir(gear_data_dir) as gear_files:
for file in gear_files:
self.stdout.write(self.style.HTTP_REDIRECT(f'Seeding Gear from {file.name}'))
with open(gear_data_dir / file.name, 'r') as f:
self.import_file(f, models.Gear)
with scandir(gear_data_dir) as expac_dirs:
for expac_dir in expac_dirs:
if not expac_dir.is_dir():
continue

with scandir(expac_dir.path) as gear_files:
for file in gear_files:
self.stdout.write(self.style.HTTP_REDIRECT(f'Seeding Gear from {file.name}'))
with open(file.path, 'r') as f:
self.import_file(f, models.Gear)

# Lastly we import the Job data.
# This is handled *slightly* differently because the 'ordering' key in this file will most likely change
Expand All @@ -41,10 +45,8 @@ def import_file(self, file, model):
data = yaml.safe_load(file)
for item in data:
self.stdout.write(f'\t{item["name"]}')
try:
with transaction.atomic():
model.objects.create(**item)
except IntegrityError:
_, created = model.objects.get_or_create(**item)
if not created:
self.stdout.write('\t\tSkipping, as it is already in the DB.')

def import_jobs(self, file):
Expand Down
69 changes: 69 additions & 0 deletions backend/api/management/commands/seed_data/gear/6-ew/6.0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
- has_accessories: True
has_armour: False
has_weapon: False
item_level: 560
name: 'The Last'
- has_accessories: False
has_armour: True
has_weapon: True
item_level: 560
name: 'Endwalker AF'
extra_import_classes:
# Armour
- Reverence
- Pummeler's
- Ignominy
- Allegiance
- Tiamat
- Reaper's
- Anchorite's
- Saotome
- Hachiya
- Brioso
- Pioneer's
- Etoile
- Spaekona's
- Convoker's
- Atrophy
- Theophany
- Academic's
- Astronomia
- Didact's
extra_import_names:
# Weapons
- Lightbringer
- Gigantaxe
- Chaosbringer
- Hyperion
- Abel's Lance
- Burning Fists
- Murasame
- Mutsunokami
- Perseus's Bow
- Ataktos
- Terpsichore
- Asura's Rod
- Abraxas
- Wild Rose
- Xoanon
- Epeolatry
- Diana
- Death Sickle
- Hagneia
- Hero's Shield

- has_accessories: True
has_armour: True
has_weapon: True
item_level: 570
name: 'Moonward'
- has_accessories: True
has_armour: False
has_weapon: False
item_level: 580
name: 'Eternal Dark'
- has_accessories: False
has_armour: False
has_weapon: True
item_level: 580
name: 'Divine Light'
77 changes: 77 additions & 0 deletions backend/api/management/commands/seed_data/gear/6-ew/6.4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
- has_accessories: True
has_armour: True
has_weapon: True
item_level: 640
name: 'Diadochos'
- has_accessories: True
has_armour: True
has_weapon: False
item_level: 640
name: 'Anabaseios'
- has_accessories: False
has_armour: False
has_weapon: True
item_level: 645
name: 'Voidcast'
- has_accessories: True
has_armour: True
has_weapon: True
item_level: 650
name: 'Credendum'
extra_import_names:
- Polaris Point
- Wrathgrinder
- Blood Rapture
- Cerberus Fang
- Night's Wolf
- Avatar's Scythe
- Dragon's Beard Fists
- Higan Shigan
- Shinobi Knives
- Bluebird's Nest
- Vitória do Povo
- Twin Moons
- Ignis Malus
- Encounter in Lilies
- Lamplight Crook
- Bunny's Crescent
- Faerie Fancy
- Stargazer
- Isnae Phis
- Vessel
- has_accessories: True
has_armour: True
has_weapon: True
item_level: 660
name: 'Augmented Credendum'
extra_import_names:
- Augmented Polaris Point
- Augmented Wrathgrinder
- Augmented Blood Rapture
- Augmented Cerberus Fang
- Augmented Night's Wolf
- Augmented Avatar's Scythe
- Augmented Dragon's Beard Fists
- Augmented Higan Shigan
- Augmented Shinobi Knives
- Augmented Bluebird's Nest
- Augmented Vitória do Povo
- Augmented Twin Moons
- Augmented Ignis Malus
- Augmented Encounter in Lilies
- Augmented Lamplight Crook
- Augmented Bunny's Crescent
- Augmented Faerie Fancy
- Augmented Stargazer
- Augmented Isnae Phis
- Augmented Vessel
- has_accessories: True
has_armour: True
has_weapon: False
item_level: 660
name: 'Ascension'
- has_accessories: False
has_armour: False
has_weapon: True
item_level: 665
name: 'Ascension'
25 changes: 0 additions & 25 deletions backend/api/management/commands/seed_data/gear/6.0.yml

This file was deleted.

35 changes: 0 additions & 35 deletions backend/api/management/commands/seed_data/gear/6.4.yml

This file was deleted.

Loading

0 comments on commit 65e9a7f

Please sign in to comment.