Skip to content

Commit

Permalink
Use temba.orgs.models.User consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Nov 19, 2024
1 parent 6289531 commit 0fbb678
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 11 deletions.
2 changes: 1 addition & 1 deletion temba/api/v2/fields.py
Original file line number Diff line number Diff line change
@@ -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 _

Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions temba/api/v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions temba/contacts/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions temba/mailroom/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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


Expand Down
41 changes: 41 additions & 0 deletions temba/msgs/migrations/0276_alter_broadcast_created_by_and_more.py
Original file line number Diff line number Diff line change
@@ -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"
),
),
]
3 changes: 1 addition & 2 deletions temba/msgs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
22 changes: 22 additions & 0 deletions temba/notifications/migrations/0029_alter_notification_user.py
Original file line number Diff line number Diff line change
@@ -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"
),
),
]
3 changes: 1 addition & 2 deletions temba/notifications/models.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
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
from django.utils import timezone

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__)
Expand Down

0 comments on commit 0fbb678

Please sign in to comment.