diff --git a/temba/api/v2/fields.py b/temba/api/v2/fields.py index 9f61c5fa3a4..3d48ee80c7c 100644 --- a/temba/api/v2/fields.py +++ b/temba/api/v2/fields.py @@ -1,6 +1,5 @@ from rest_framework import fields, relations, serializers -from django.contrib.auth.models import User from django.db.models import Q from django.utils.translation import gettext_lazy as _ @@ -9,6 +8,7 @@ from temba.contacts.models import URN, Contact, ContactField as ContactFieldModel, ContactGroup, ContactURN from temba.flows.models import Flow from temba.msgs.models import Attachment, Label, Media, Msg +from temba.orgs.models import User from temba.tickets.models import Ticket, Topic from temba.utils import languages from temba.utils.uuid import find_uuid, is_uuid diff --git a/temba/api/v2/serializers.py b/temba/api/v2/serializers.py index df1ee920531..72b5037272e 100644 --- a/temba/api/v2/serializers.py +++ b/temba/api/v2/serializers.py @@ -9,7 +9,6 @@ from rest_framework import serializers from django.conf import settings -from django.contrib.auth.models import User from temba import mailroom from temba.archives.models import Archive @@ -22,7 +21,7 @@ from temba.locations.models import AdminBoundary from temba.mailroom import modifiers from temba.msgs.models import Broadcast, Label, Media, Msg, OptIn -from temba.orgs.models import Org, OrgRole +from temba.orgs.models import Org, OrgRole, User from temba.tickets.models import Ticket, Topic from temba.utils import json from temba.utils.fields import NameValidator diff --git a/temba/contacts/tasks.py b/temba/contacts/tasks.py index 0e195d3d4c8..65b8e830096 100644 --- a/temba/contacts/tasks.py +++ b/temba/contacts/tasks.py @@ -3,8 +3,7 @@ from celery import shared_task -from django.contrib.auth.models import User - +from temba.orgs.models import User from temba.utils.crons import cron_task from .models import Contact, ContactGroup, ContactGroupCount, ContactImport diff --git a/temba/mailroom/events.py b/temba/mailroom/events.py index 81beb69ade2..b4c04069cc5 100644 --- a/temba/mailroom/events.py +++ b/temba/mailroom/events.py @@ -4,7 +4,6 @@ import iso8601 from django.conf import settings -from django.contrib.auth.models import User from django.urls import reverse from django.utils import timezone @@ -14,7 +13,7 @@ from temba.flows.models import FlowExit, FlowRun from temba.ivr.models import Call from temba.msgs.models import Msg, OptIn -from temba.orgs.models import Org +from temba.orgs.models import Org, User from temba.tickets.models import Ticket, TicketEvent, Topic diff --git a/temba/msgs/migrations/0276_alter_broadcast_created_by_and_more.py b/temba/msgs/migrations/0276_alter_broadcast_created_by_and_more.py new file mode 100644 index 00000000000..8d62be0dc71 --- /dev/null +++ b/temba/msgs/migrations/0276_alter_broadcast_created_by_and_more.py @@ -0,0 +1,41 @@ +# Generated by Django 5.1.2 on 2024-11-19 21:36 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("msgs", "0275_alter_broadcast_status"), + ("orgs", "0159_usersettings_is_system"), + ] + + operations = [ + migrations.AlterField( + model_name="broadcast", + name="created_by", + field=models.ForeignKey( + null=True, on_delete=django.db.models.deletion.PROTECT, related_name="+", to="orgs.user" + ), + ), + migrations.AlterField( + model_name="broadcast", + name="modified_by", + field=models.ForeignKey( + null=True, on_delete=django.db.models.deletion.PROTECT, related_name="+", to="orgs.user" + ), + ), + migrations.AlterField( + model_name="media", + name="created_by", + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to="orgs.user"), + ), + migrations.AlterField( + model_name="msg", + name="created_by", + field=models.ForeignKey( + db_index=False, null=True, on_delete=django.db.models.deletion.PROTECT, to="orgs.user" + ), + ), + ] diff --git a/temba/msgs/models.py b/temba/msgs/models.py index 06aa8673bee..a5512179f24 100644 --- a/temba/msgs/models.py +++ b/temba/msgs/models.py @@ -11,7 +11,6 @@ import iso8601 from django.conf import settings -from django.contrib.auth.models import User from django.contrib.postgres.fields import ArrayField from django.core.files.storage import default_storage from django.db import models @@ -23,7 +22,7 @@ from temba import mailroom from temba.channels.models import Channel, ChannelLog from temba.contacts.models import Contact, ContactGroup, ContactURN -from temba.orgs.models import DependencyMixin, Export, ExportType, Org +from temba.orgs.models import DependencyMixin, Export, ExportType, Org, User from temba.schedules.models import Schedule from temba.utils import languages, on_transaction_commit from temba.utils.export.models import MultiSheetExporter diff --git a/temba/notifications/migrations/0029_alter_notification_user.py b/temba/notifications/migrations/0029_alter_notification_user.py new file mode 100644 index 00000000000..e0c66d07a66 --- /dev/null +++ b/temba/notifications/migrations/0029_alter_notification_user.py @@ -0,0 +1,22 @@ +# Generated by Django 5.1.2 on 2024-11-19 21:36 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("notifications", "0028_delete_notificationcount"), + ("orgs", "0159_usersettings_is_system"), + ] + + operations = [ + migrations.AlterField( + model_name="notification", + name="user", + field=models.ForeignKey( + on_delete=django.db.models.deletion.PROTECT, related_name="notifications", to="orgs.user" + ), + ), + ] diff --git a/temba/notifications/models.py b/temba/notifications/models.py index 7b7b71c4fd6..7d92fd22b94 100644 --- a/temba/notifications/models.py +++ b/temba/notifications/models.py @@ -1,7 +1,6 @@ import logging from abc import abstractmethod -from django.contrib.auth.models import User from django.db import models from django.db.models import Q from django.urls import reverse @@ -9,7 +8,7 @@ from temba.channels.models import Channel from temba.contacts.models import ContactImport -from temba.orgs.models import Export, Org +from temba.orgs.models import Export, Org, User from temba.utils.email import EmailSender logger = logging.getLogger(__name__)