Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
52 changes: 52 additions & 0 deletions db/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Generated by Django 6.0.4 on 2026-05-04 16:56

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


class Migration(migrations.Migration):

initial = True

dependencies = [
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skill.race ForeignKey is missing related_name parameter per checklist item #3.

]

operations = [
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access data["race"]["name"] instead of using .get() method per checklist item #5.

migrations.CreateModel(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guild.name is missing unique=True - This is required per task requirements which state guild names must be unique.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access data["race"]["description"] instead of using .get() method per checklist item #5.

name='Guild',
fields=[
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access data["race"]["skills"] instead of using .get() method per checklist item #5.

('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('description', models.TextField(null=True)),
],
),
Comment on lines +21 to +22
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access skill_data["name"] and skill_data["bonus"] instead of using .get() method per checklist item #5.

migrations.CreateModel(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Player.race ForeignKey is missing related_name parameter per checklist item #3.

name='Race',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255, unique=True)),
('description', models.TextField(blank=True)),
],
Comment on lines +24 to +29
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Player.guild ForeignKey is missing related_name parameter per checklist item #3.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access data["guild"]["name"] instead of using .get() method per checklist item #5.

),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access data["guild"]["description"] instead of using .get() method per checklist item #5.

Comment on lines +29 to +30
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checklist item #5 violation: Use .get() method to check whether key exists. After line 26, use guild_data.get("name") instead of data["guild"]["name"].

migrations.CreateModel(
Comment on lines +30 to +31
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checklist item #5 violation: Use .get() method to check whether key exists. Use guild_data.get("description") instead of data["guild"]["description"].

name='Player',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nickname', models.CharField(max_length=255, unique=True)),
('email', models.EmailField(max_length=255)),
('bio', models.CharField(max_length=255)),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access data["email"] and data["bio"] instead of using .get() method per checklist item #5.

Comment on lines +36 to +37
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checklist item #5 violation: Use .get() method to check whether key exists. Access data.get("email") instead of data["email"].

('created_at', models.DateTimeField(auto_now_add=True)),
Comment on lines +37 to +38
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checklist item #5 violation: Use .get() method to check whether key exists. Access data.get("bio") instead of data["bio"].

('guild', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='db.guild')),
('race', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='db.race')),
],
),
migrations.CreateModel(
name='Skill',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255, unique=True)),
('bonus', models.CharField(max_length=255)),
('race', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='db.race')),
],
),
]
31 changes: 31 additions & 0 deletions db/models.py
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
from django.db import models


class Race(models.Model):
name = models.CharField(max_length=255, unique=True)
description = models.TextField(blank=True)


class Skill(models.Model):
name = models.CharField(max_length=255, unique=True)
bonus = models.CharField(max_length=255)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing related_name on Skill.race ForeignKey - required by CHECKLIST ITEM #3 to access related models on the Many side

race = models.ForeignKey(Race, on_delete=models.CASCADE, related_name='skills')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checklist item #5 violation: Use .get() method for dictionary access. Replace data["race"] with data.get("race").


Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access instead of .get() method. Per CHECKLIST ITEM #5, use data.get("race").get("name") or similar pattern.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checklist item #5 violation: Use .get() method for dictionary access. Replace data["race"]["description"] with chained .get() calls.

class Guild(models.Model):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guild.name is missing unique=True - the task requirements explicitly state guild names must be unique. This was flagged in the previous review and remains unfixed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access instead of .get() method for race description.

name = models.CharField(max_length=255, unique=True)
description = models.TextField(null=True)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access instead of .get() method for accessing skills list.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checklist item #5 violation: Use .get() method for dictionary access.


Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checklist item #2: Migration is out of sync with models. Guild.name is missing unique=True (line 18) and all ForeignKey fields are missing related_name (lines 38-39). Recreate the migration file.


Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access instead of .get() method for skill name.

class Player(models.Model):
nickname = models.CharField(max_length=255, unique=True)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access instead of .get() method for skill bonus.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checklist item #5 violation: Use .get() method for dictionary access on skill_data["name"] and skill_data["bonus"].

email = models.EmailField(max_length=255)
bio = models.CharField(max_length=255)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing related_name on Player.race ForeignKey - required by CHECKLIST ITEM #3

race = models.ForeignKey(Race, on_delete=models.CASCADE, related_name='players')
guild = models.ForeignKey(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing related_name on ForeignKey to Guild. Checklist item #3 requires adding related_name to ForeignKey fields to access related models on the Many side.

Guild,
on_delete=models.SET_NULL,
null=True,
blank=True,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access instead of .get() method for guild name.

related_name='players',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checklist item #5 violation: Use .get() method for dictionary access on data["guild"]["name"] and data["guild"]["description"].

)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access instead of .get() method for guild description.

created_at = models.DateTimeField(auto_now_add=True)
37 changes: 36 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
import json

import init_django_orm # noqa: F401

from db.models import Race, Skill, Player, Guild


def main() -> None:
pass
with open("players.json", "r") as file:
player_data = json.load(file)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing related_name on ForeignKey fields - per [CHECKLIST ITEM #3], all ForeignKey fields must have a related_name parameter. This applies to: Skill.race, Player.race, and Player.guild

for nickname, data in player_data.items():
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing related_name on Skill's race ForeignKey. Checklist item #3 requires adding related_name to ForeignKey fields.

race, created = Race.objects.get_or_create(
name=data["race"]["name"],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access is used instead of .get() method. Checklist item #5 requires using .get() to check whether a key is defined in the dictionary.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access instead of .get() - per [CHECKLIST ITEM #5], use .get() method to check whether key is defined. Use data.get("race") instead of data["race"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item #5: use .get() method for dictionary access. Replace data["race"]["name"] with data.get("race", {}).get("name") pattern.

defaults={"description": data["race"]["description"]}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access is used instead of .get() method. Checklist item #5 requires using .get() to check whether a key is defined in the dictionary.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guild.name is missing unique=True - this was flagged in the previous review and is still missing. Per task requirements, guild names must be unique.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access - should use .get() method

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item #5: use .get() method for dictionary access.

)
Comment on lines +15 to +16
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guild name field is missing unique=True. According to the task requirements, guild names must be unique. Add unique=True to match the requirement.


Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access - should use .get() method

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item #5: use .get() method for dictionary access.

for skill_data in data["race"]["skills"]:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migration file is out of sync with models. Guild.name is missing unique=True per task requirements. Per checklist item #2, you must regenerate migrations after changes in models.

Skill.objects.get_or_create(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access - should use .get() method

name=skill_data["name"],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access is used instead of .get() method for skill_data. Checklist item #5 requires using .get() to check whether a key is defined in the dictionary.

defaults={
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access - should use .get() method

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item #5: use .get() method for dictionary access.

"bonus": skill_data["bonus"],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access is used instead of .get() method for skill_data. Checklist item #5 requires using .get() to check whether a key is defined in the dictionary.

"race": race,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing related_name on Player.race ForeignKey field

}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing related_name on race ForeignKey. Checklist item #3 requires adding related_name to ForeignKey fields to access related models on the Many side.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing related_name on Player.guild ForeignKey field

)

guild_data = data.get("guild")
if guild_data:
guild, _ = Guild.objects.get_or_create(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access - should use .get() method

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item #5: use .get() method for dictionary access.

name=data["guild"]["name"],
Comment on lines +25 to +31
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing related_name on Player's guild ForeignKey. Checklist item #3 requires adding related_name to ForeignKey fields.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access is used instead of .get() method. Checklist item #5 requires using .get() to check whether a key is defined in the dictionary.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access - should use .get() method

defaults={"description": data["guild"]["description"]}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access is used instead of .get() method. Checklist item #5 requires using .get() to check whether a key is defined in the dictionary.

)

Player.objects.get_or_create(
nickname=nickname,
defaults={
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access - should use .get() method

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item #5: use .get() method for dictionary access.

"email": data["email"],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access is used instead of .get() method. Checklist item #5 requires using .get() to check whether a key is defined in the dictionary.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access - should use .get() method

"bio": data["bio"],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dictionary access is used instead of .get() method. Checklist item #5 requires using .get() to check whether a key is defined in the dictionary.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migration file is out of sync with models. Player.guild is missing related_name='players' per checklist item #3. Per checklist item #2, you must regenerate migrations after changes in models.

"race": race,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migration file is out of sync with models. Player.race is missing related_name='players' per checklist item #3. Per checklist item #2, you must regenerate migrations after changes in models.

"guild": guild,
}
)


if __name__ == "__main__":
Expand Down
Loading