From 798defc046c8cc524a90370d39d23dd5fadcb08a Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Bodas Date: Fri, 23 Jul 2021 18:45:54 +0530 Subject: [PATCH] models: Rename MutedTopic to UserTopic. Part of #19272 We still keep refering to this model with "MutedTopic" to reduce the diff size of this commit. The alias will be removed in the next commit. This commit skips on renaming the `date_muted` field to something more general. That will be done in further commits, along with the code and API changes. --- .../0340_rename_mutedtopic_to_usertopic.py | 21 +++++++++++++++++++ zerver/models.py | 12 +++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 zerver/migrations/0340_rename_mutedtopic_to_usertopic.py diff --git a/zerver/migrations/0340_rename_mutedtopic_to_usertopic.py b/zerver/migrations/0340_rename_mutedtopic_to_usertopic.py new file mode 100644 index 0000000000..891207e3e6 --- /dev/null +++ b/zerver/migrations/0340_rename_mutedtopic_to_usertopic.py @@ -0,0 +1,21 @@ +# Generated by Django 3.2.5 on 2021-07-23 13:15 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("zerver", "0339_remove_realm_add_emoji_by_admins_only"), + ] + + operations = [ + migrations.RenameModel( + old_name="MutedTopic", + new_name="UserTopic", + ), + migrations.AlterModelTable( + name="usertopic", + table="zerver_mutedtopic", + ), + ] diff --git a/zerver/models.py b/zerver/models.py index c8c340b58d..c4ed3a2aac 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -2128,7 +2128,7 @@ post_save.connect(flush_stream, sender=Stream) post_delete.connect(flush_stream, sender=Stream) -class MutedTopic(models.Model): +class UserTopic(models.Model): id: int = models.AutoField(auto_created=True, primary_key=True, verbose_name="ID") user_profile: UserProfile = models.ForeignKey(UserProfile, on_delete=CASCADE) stream: Stream = models.ForeignKey(Stream, on_delete=CASCADE) @@ -2144,8 +2144,16 @@ class MutedTopic(models.Model): class Meta: unique_together = ("user_profile", "stream", "topic_name") + # This model was originally called "MutedTopic". We + # generalized it to "UserTopic", but have not yet done the + # database migration to rename the table and indexes. + db_table = "zerver_mutedtopic" + def __str__(self) -> str: - return f"" + return f"" + + +MutedTopic = UserTopic class MutedUser(models.Model):