models: Add backward relation to MutedUser foreign keys.

Updates the two UserProfile foreign key fields to have a backward
relation in the MutedUser model by changing the `related_name`
property.

This is a prep commit for removing users with a muted relationship
to the current user from read receipts.
This commit is contained in:
Lauryn Menard 2022-09-15 11:24:53 +02:00 committed by Tim Abbott
parent 13ffb36834
commit 5e58f86aa7
2 changed files with 39 additions and 2 deletions

View File

@ -0,0 +1,33 @@
# Generated by Django 4.0.7 on 2022-09-15 09:27
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("zerver", "0410_alter_stream_can_remove_subscribers_group"),
]
operations = [
migrations.AlterField(
model_name="muteduser",
name="muted_user",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="muted",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AlterField(
model_name="muteduser",
name="user_profile",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="muter",
to=settings.AUTH_USER_MODEL,
),
),
]

View File

@ -2674,8 +2674,12 @@ class UserTopic(models.Model):
class MutedUser(models.Model):
user_profile: UserProfile = models.ForeignKey(UserProfile, related_name="+", on_delete=CASCADE)
muted_user: UserProfile = models.ForeignKey(UserProfile, related_name="+", on_delete=CASCADE)
user_profile: UserProfile = models.ForeignKey(
UserProfile, related_name="muter", on_delete=CASCADE
)
muted_user: UserProfile = models.ForeignKey(
UserProfile, related_name="muted", on_delete=CASCADE
)
date_muted: datetime.datetime = models.DateTimeField(default=timezone_now)
class Meta: