From 76714a773623991da95424668c78ca06d48ef16e Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Mon, 23 Dec 2019 10:15:09 -0600 Subject: [PATCH] Allow discord_uuid field to be blank on Player model --- GeoffreyApp/api/commands.py | 4 ++-- .../migrations/0004_auto_20191223_1610.py | 18 ++++++++++++++++++ GeoffreyApp/models.py | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 GeoffreyApp/migrations/0004_auto_20191223_1610.py diff --git a/GeoffreyApp/api/commands.py b/GeoffreyApp/api/commands.py index 1c7d54d..0df2b0c 100644 --- a/GeoffreyApp/api/commands.py +++ b/GeoffreyApp/api/commands.py @@ -138,7 +138,7 @@ def add_location(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None, loc_t @command(RequestTypes.POST) -def register(player_name, discord_uuid): +def register(player_name, discord_uuid=None): """ :request: POST :param player_name: Minecraft in-game name @@ -153,7 +153,7 @@ def register(player_name, discord_uuid): try: player = get_player(mc_uuid=mc_uuid) - if len(discord_uuid) != 0 and len(player.discord_uuid) == 0: + if discord_uuid is not None and player.discord_uuid == "": player.discord_uuid = discord_uuid player.save() return player.json diff --git a/GeoffreyApp/migrations/0004_auto_20191223_1610.py b/GeoffreyApp/migrations/0004_auto_20191223_1610.py new file mode 100644 index 0000000..1c52d14 --- /dev/null +++ b/GeoffreyApp/migrations/0004_auto_20191223_1610.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1.2 on 2019-12-23 16:10 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('GeoffreyApp', '0003_apitoken_model_api_perm'), + ] + + operations = [ + migrations.AlterField( + model_name='player', + name='discord_uuid', + field=models.CharField(blank=True, max_length=50, unique=True), + ), + ] diff --git a/GeoffreyApp/models.py b/GeoffreyApp/models.py index 31e9933..cf67a48 100644 --- a/GeoffreyApp/models.py +++ b/GeoffreyApp/models.py @@ -78,7 +78,7 @@ class Player(models.Model): Minecraft UUID """ - discord_uuid = models.CharField(max_length=50, unique=True) + discord_uuid = models.CharField(max_length=50, unique=True, blank=True) """ Discord UUID """