Fix chat_box schema
This commit is contained in:
parent
289e9ab7db
commit
bce34a0c40
2 changed files with 28 additions and 3 deletions
24
chat_box/migrations/0009_auto_20220618_1452.py
Normal file
24
chat_box/migrations/0009_auto_20220618_1452.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Generated by Django 2.2.25 on 2022-06-18 07:52
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("chat_box", "0008_ignore"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="ignore",
|
||||
name="user",
|
||||
field=models.OneToOneField(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="ignored_chat_users",
|
||||
to="judge.Profile",
|
||||
verbose_name="user",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -6,7 +6,7 @@ from django.utils.translation import gettext_lazy as _
|
|||
from judge.models.profile import Profile
|
||||
|
||||
|
||||
__all__ = ["Message"]
|
||||
__all__ = ["Message", "Room", "UserRoom", "Ignore"]
|
||||
|
||||
|
||||
class Room(models.Model):
|
||||
|
@ -57,11 +57,12 @@ class UserRoom(models.Model):
|
|||
|
||||
|
||||
class Ignore(models.Model):
|
||||
user = models.ForeignKey(
|
||||
user = models.OneToOneField(
|
||||
Profile,
|
||||
related_name="ignored_chat_users",
|
||||
verbose_name=_("user"),
|
||||
on_delete=CASCADE,
|
||||
db_index=True,
|
||||
)
|
||||
ignored_users = models.ManyToManyField(Profile)
|
||||
|
||||
|
@ -79,7 +80,7 @@ class Ignore(models.Model):
|
|||
@classmethod
|
||||
def get_ignored_users(self, user):
|
||||
try:
|
||||
return self.objects.filter(user=user)[0].ignored_users.all()
|
||||
return self.objects.get(user=user).ignored_users.all()
|
||||
except:
|
||||
return Profile.objects.none()
|
||||
|
||||
|
|
Loading…
Reference in a new issue