-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix3 #1722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix3 #1722
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Generated by Django 6.0.5 on 2026-05-13 10:43 | ||
|
|
||
| import django.db.models.deletion | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| initial = True | ||
|
|
||
| dependencies = [ | ||
| ] | ||
|
|
||
|
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CHECKLIST ITEM #3 violation: |
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name='Guild', | ||
| 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, null=True)), | ||
| ], | ||
| ), | ||
| migrations.CreateModel( | ||
| name='Race', | ||
| fields=[ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CHECKLIST ITEM #3 violation: |
||
| ('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
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CHECKLIST ITEM #3 violation: |
||
| ], | ||
| ), | ||
| migrations.CreateModel( | ||
| 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(blank=True, max_length=255)), | ||
| ('created_at', models.DateTimeField(auto_now_add=True)), | ||
| ('guild', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='db.guild')), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Migration file must be updated to include |
||
| ('race', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='db.race')), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Migration file must be updated to include |
||
| ], | ||
| ), | ||
| 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)), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Migration file must be updated to include |
||
| ('race', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='db.race')), | ||
|
Comment on lines
+39
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Migration file needs to be regenerated after adding |
||
| ], | ||
| ), | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,30 @@ | ||
| 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) | ||
| race = models.ForeignKey( | ||
| Race, on_delete=models.CASCADE | ||
|
Comment on lines
+12
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CHECKLIST ITEM #3 VIOLATION: Missing
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CHECKLIST ITEM #3 violation: This ForeignKey is missing
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing |
||
| ) | ||
|
|
||
|
|
||
| class Guild(models.Model): | ||
| name = models.CharField(max_length=255, unique=True) | ||
| description = models.TextField(blank=True, null=True) | ||
|
|
||
|
|
||
| class Player(models.Model): | ||
| nickname = models.CharField(max_length=255, unique=True) | ||
| email = models.EmailField(max_length=255, unique=False) | ||
| bio = models.CharField(max_length=255, blank=True) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CHECKLIST ITEM #3 violation: This ForeignKey is missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing |
||
| race = models.ForeignKey(Race, on_delete=models.CASCADE) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CHECKLIST ITEM #3 VIOLATION: Missing |
||
| guild = models.ForeignKey( | ||
| Guild, on_delete=models.SET_NULL, null=True, blank=True | ||
|
Comment on lines
+27
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CHECKLIST ITEM #3 VIOLATION: Missing
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CHECKLIST ITEM #3 violation: This ForeignKey is missing
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing |
||
| ) | ||
| created_at = models.DateTimeField(auto_now_add=True) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,43 @@ | ||
| import init_django_orm # noqa: F401 | ||
|
|
||
| import json | ||
| from db.models import Race, Skill, Player, Guild | ||
|
|
||
|
|
||
| def main() -> None: | ||
| pass | ||
| with open("players.json", "r") as f: | ||
| all_players_data = json.load(f) | ||
|
|
||
| for player_nickname, player_details in all_players_data.items(): | ||
| race_obj, _ = Race.objects.get_or_create( | ||
| name=player_details["race"]["name"], | ||
| defaults={ | ||
|
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CHECKLIST ITEM #3 violation: Missing |
||
| "description": player_details["race"].get("description", "") | ||
| } | ||
| ) | ||
|
|
||
| for skill_info in player_details["race"]["skills"]: | ||
| Skill.objects.get_or_create( | ||
| name=skill_info["name"], | ||
| race=race_obj, | ||
| defaults={"bonus": skill_info.get("bonus", "")} | ||
| ) | ||
| guild_obj = None | ||
| if player_details.get("guild"): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CHECKLIST ITEM #3 violation: Missing |
||
| guild_obj, _ = Guild.objects.get_or_create( | ||
| name=player_details["guild"]["name"], | ||
| defaults={ | ||
|
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CHECKLIST ITEM #3 violation: Missing |
||
| "description": player_details["guild"].get("description")} | ||
| ) | ||
|
|
||
| Player.objects.get_or_create( | ||
| nickname=player_nickname, | ||
| defaults={ | ||
| "email": player_details["email"], | ||
| "bio": player_details.get("bio", ""), | ||
| "race": race_obj, | ||
| "guild": guild_obj, | ||
| } | ||
| ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Migration needs updating after adding related_name to Player.guild ForeignKey in models.py |
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Migration needs updating after adding related_name to Player.race ForeignKey in models.py |
||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
related_nameon ForeignKey field (checklist item #3 requires this for all ForeignKey fields to access related models on Many side)