-
-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: 0ssigeno <[email protected]>
- Loading branch information
Showing
13 changed files
with
133 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
authentication/migrations/0003_userprofile_is_robot_userprofile_task_priority_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated by Django 4.2.11 on 2024-04-04 08:16 | ||
|
||
from django.conf import settings | ||
import django.core.validators | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('authentication', '0002_migrate_from_durin'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='userprofile', | ||
name='is_robot', | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AddField( | ||
model_name='userprofile', | ||
name='task_priority', | ||
field=models.IntegerField(default=10, validators=[django.core.validators.MaxValueValidator(10), django.core.validators.MinValueValidator(1)]), | ||
), | ||
migrations.AlterField( | ||
model_name='userprofile', | ||
name='user', | ||
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL), | ||
), | ||
] |
24 changes: 24 additions & 0 deletions
24
authentication/migrations/0004_alter_userprofile_company_name_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 4.2.11 on 2024-04-04 08:27 | ||
|
||
import django.core.validators | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('authentication', '0003_userprofile_is_robot_userprofile_task_priority_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='userprofile', | ||
name='company_name', | ||
field=models.CharField(max_length=32, null=True, validators=[django.core.validators.MinLengthValidator(3)]), | ||
), | ||
migrations.AlterField( | ||
model_name='userprofile', | ||
name='company_role', | ||
field=models.CharField(max_length=32, null=True, validators=[django.core.validators.MinLengthValidator(3)]), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Generated by Django 4.2.11 on 2024-04-04 07:46 | ||
|
||
from django.conf import settings | ||
from django.db import migrations | ||
|
||
|
||
def migrate(apps, schema_editor): | ||
User = apps.get_model(*settings.AUTH_USER_MODEL.split(".")) | ||
Profile = apps.get_model("authentication", "UserProfile") | ||
for user in User.objects.all(): | ||
is_robot = user.username.endswith("Ingestor") | ||
Profile.objects.create( | ||
user=user, task_priority=7 if is_robot else 10, is_robot=is_robot | ||
) | ||
|
||
|
||
def reverse_migrate(apps, schema_editor): | ||
Profile = apps.get_model("authentication", "UserProfile") | ||
Profile.objects.all().delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
("authentication", "0004_alter_userprofile_company_name_and_more"), | ||
] | ||
|
||
operations = [migrations.RunPython(migrate, reverse_migrate)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.conf import settings | ||
from django.db.models.signals import post_save | ||
from django.dispatch import receiver | ||
|
||
from authentication.models import UserProfile | ||
|
||
|
||
@receiver(post_save, sender=settings.AUTH_USER_MODEL) | ||
def post_save_user(sender, instance, created, **kwargs): | ||
if created: | ||
UserProfile.objects.create(user=instance) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters