Add initial implementations for forms and organization apps with serializers, factories, and admin configurations
Some checks failed
CI/CD Pipeline / Run Tests (push) Failing after 45s
CI/CD Pipeline / Code Quality Checks (push) Failing after 48s
CI/CD Pipeline / Build Docker Images (push) Has been skipped
CI/CD Pipeline / Push to Gitea Registry (push) Has been skipped
CI/CD Pipeline / Deploy to Server (push) Has been skipped
Some checks failed
CI/CD Pipeline / Run Tests (push) Failing after 45s
CI/CD Pipeline / Code Quality Checks (push) Failing after 48s
CI/CD Pipeline / Build Docker Images (push) Has been skipped
CI/CD Pipeline / Push to Gitea Registry (push) Has been skipped
CI/CD Pipeline / Deploy to Server (push) Has been skipped
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
# Generated by Django 3.2.25 on 2026-03-28
|
||||
|
||||
from django.contrib.auth.hashers import make_password
|
||||
from django.db import migrations
|
||||
|
||||
TARGET_USERNAME = "admin"
|
||||
TARGET_EMAIL = "1@3.com"
|
||||
TARGET_PASSWORD = "12345678" # noqa: S105
|
||||
|
||||
|
||||
def create_or_update_admin_superuser(apps, schema_editor):
|
||||
User = apps.get_model("user", "User")
|
||||
Profile = apps.get_model("user", "Profile")
|
||||
db_alias = schema_editor.connection.alias
|
||||
manager = User.objects.using(db_alias)
|
||||
|
||||
email_user = manager.filter(email=TARGET_EMAIL).first()
|
||||
username_user = manager.filter(username=TARGET_USERNAME).first()
|
||||
|
||||
if email_user and username_user and email_user.pk != username_user.pk:
|
||||
user = email_user
|
||||
can_set_username = False
|
||||
elif email_user:
|
||||
user = email_user
|
||||
can_set_username = True
|
||||
elif username_user:
|
||||
user = username_user
|
||||
can_set_username = True
|
||||
else:
|
||||
user = User(email=TARGET_EMAIL, username=TARGET_USERNAME)
|
||||
can_set_username = True
|
||||
|
||||
user.email = TARGET_EMAIL
|
||||
if can_set_username:
|
||||
user.username = TARGET_USERNAME
|
||||
|
||||
user.is_staff = True
|
||||
user.is_superuser = True
|
||||
user.is_active = True
|
||||
user.password = make_password(TARGET_PASSWORD)
|
||||
user.save(using=db_alias)
|
||||
|
||||
Profile.objects.using(db_alias).get_or_create(
|
||||
user_id=user.pk,
|
||||
defaults={
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("user", "0004_alter_user_groups"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
create_or_update_admin_superuser,
|
||||
migrations.RunPython.noop,
|
||||
),
|
||||
]
|
||||
19
src/apps/user/migrations/0006_alter_user_groups.py
Normal file
19
src/apps/user/migrations/0006_alter_user_groups.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 3.2.25 on 2026-03-28 15:34
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('auth', '0012_alter_user_first_name_max_length'),
|
||||
('user', '0005_create_default_admin_superuser'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='user',
|
||||
name='groups',
|
||||
field=models.ManyToManyField(blank=True, help_text='', related_name='custom_user_set', related_query_name='custom_user', to='auth.Group', verbose_name='groups'),
|
||||
),
|
||||
]
|
||||
19
src/apps/user/migrations/0007_alter_user_groups.py
Normal file
19
src/apps/user/migrations/0007_alter_user_groups.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 3.2.25 on 2026-03-28 16:21
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('auth', '0012_alter_user_first_name_max_length'),
|
||||
('user', '0006_alter_user_groups'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='user',
|
||||
name='groups',
|
||||
field=models.ManyToManyField(blank=True, help_text='', related_name='custom_user_set', related_query_name='custom_user', to='auth.Group', verbose_name='groups'),
|
||||
),
|
||||
]
|
||||
24
src/apps/user/migrations/0008_auto_20260328_1630.py
Normal file
24
src/apps/user/migrations/0008_auto_20260328_1630.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# Generated by Django 3.2.25 on 2026-03-28 16:30
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('auth', '0012_alter_user_first_name_max_length'),
|
||||
('user', '0007_alter_user_groups'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='profile',
|
||||
name='mid_name',
|
||||
field=models.CharField(blank=True, max_length=50, null=True, verbose_name='middle name'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='user',
|
||||
name='groups',
|
||||
field=models.ManyToManyField(blank=True, help_text='', related_name='custom_user_set', related_query_name='custom_user', to='auth.Group', verbose_name='groups'),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user