From 3089c1fa01cafb2fd7b8578f1517fde65f475e63 Mon Sep 17 00:00:00 2001 From: corbz Date: Mon, 8 Jan 2024 00:40:45 +0000 Subject: [PATCH] added uuid for Department model --- .../migrations/0001_alter_user_icon.py | 19 ------------------- .../authentication/migrations/0001_initial.py | 7 ++++--- apps/authentication/models.py | 2 ++ 3 files changed, 6 insertions(+), 22 deletions(-) delete mode 100644 apps/authentication/migrations/0001_alter_user_icon.py diff --git a/apps/authentication/migrations/0001_alter_user_icon.py b/apps/authentication/migrations/0001_alter_user_icon.py deleted file mode 100644 index cf9aecb..0000000 --- a/apps/authentication/migrations/0001_alter_user_icon.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 3.2.16 on 2024-01-05 22:09 - -import apps.authentication.models -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('authentication', 'default_departments'), - ] - - operations = [ - migrations.AlterField( - model_name='user', - name='icon', - field=models.ImageField(default='users/default.webp', upload_to=apps.authentication.models.IconPathGenerator(), verbose_name='profile picture'), - ), - ] diff --git a/apps/authentication/migrations/0001_initial.py b/apps/authentication/migrations/0001_initial.py index 0b58d69..a7f8ba9 100644 --- a/apps/authentication/migrations/0001_initial.py +++ b/apps/authentication/migrations/0001_initial.py @@ -1,5 +1,6 @@ -# Generated by Django 3.2.16 on 2024-01-05 12:04 +# Generated by Django 3.2.16 on 2024-01-07 18:45 +import apps.authentication.models from django.db import migrations, models import django.db.models.deletion import django.utils.timezone @@ -18,7 +19,7 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Department', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('title', models.CharField(max_length=150)), ('icon', models.CharField(blank=True, max_length=32, null=True)), ], @@ -29,7 +30,7 @@ class Migration(migrations.Migration): ('password', models.CharField(max_length=128, verbose_name='password')), ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('icon', models.ImageField(default='users/default.webp', upload_to='users', verbose_name='profile picture')), + ('icon', models.ImageField(default='../static/assets/images/defaultuser.webp', storage=apps.authentication.models.OverwriteStorage(), upload_to=apps.authentication.models.IconPathGenerator(), verbose_name='profile picture')), ('email', models.EmailField(error_messages={'unique': 'A user with this email address already exists.'}, max_length=254, unique=True, verbose_name='email address')), ('forename', models.CharField(help_text='This should be your real first name.', max_length=150, verbose_name='first name')), ('surname', models.CharField(help_text='This should be your real last name.', max_length=150, verbose_name='last name')), diff --git a/apps/authentication/models.py b/apps/authentication/models.py index 49d1074..0f821aa 100644 --- a/apps/authentication/models.py +++ b/apps/authentication/models.py @@ -27,6 +27,8 @@ class IconPathGenerator: class Department(models.Model): + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) + title = models.CharField(max_length=150) icon = models.CharField(max_length=32, null=True, blank=True)