mute user: Add model and makemigrations.

This commit adds a new database table to support
muting users, and generates a migration file for
the same.
This commit is contained in:
Abhijeet Prasad Bodas
2021-03-27 16:13:03 +05:30
committed by Tim Abbott
parent c6dfe7bf40
commit 89f6139505
2 changed files with 59 additions and 0 deletions

View File

@@ -1845,6 +1845,18 @@ class MutedTopic(models.Model):
return f"<MutedTopic: ({self.user_profile.email}, {self.stream.name}, {self.topic_name}, {self.date_muted})>"
class MutedUser(models.Model):
user_profile = models.ForeignKey(UserProfile, related_name="+", on_delete=CASCADE)
muted_user_profile = models.ForeignKey(UserProfile, related_name="+", on_delete=CASCADE)
date_muted: datetime.datetime = models.DateTimeField(default=timezone_now)
class Meta:
unique_together = ("user_profile", "muted_user_profile")
def __str__(self) -> str:
return f"<MutedUser: {self.user_profile.email} -> {self.muted_user_profile.email}>"
class Client(models.Model):
id: int = models.AutoField(auto_created=True, primary_key=True, verbose_name="ID")
name: str = models.CharField(max_length=30, db_index=True, unique=True)