You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Board(SelfPublishModel, models.Model):
serializer_class = router_serializers.BoardRouterSerializer
title = models.CharField(max_length=20, verbose_name=u'Название')
members = models.ManyToManyField(to='user.User', related_name='boards', verbose_name=u'Участники')
def __unicode__(self):
return self.title
class User(SelfPublishModel, AbstractBaseUser):
serializer_class = router_serializers.UserRouterSerializer
email = models.EmailField(
verbose_name=u'Email',
max_length=255,
unique=True,
)
# Имя
first_name = models.CharField(max_length=15, verbose_name=u"Имя", blank=True)
and I made UserRouter, where watch users, who have at least one common board with current login user.
class UserRouter(ModelRouter):
...
def get_subscription_contexts(self, **kwargs):
return {'boards__id__in': self.connection.user.boards.all().values_list("id", flat=True)}
But there was one problem: it did not automatically update list of boards ids. So, i decided, if user id is permanently constant, then it will be better use it.
But there are another problem, which i found in channel_utils.py in function has_related_value. It checks condition in this line: getattr(obj, property_name).filter(**{filter_by_val: channel_val}).exists() . But there it is getting current user relationship objects. So, i changed this line to obj.__class__.objects.filter(pk=obj.pk, **{field: channel_val}).exists() and it begin works correctly (at least, i think so).
And i want to ask, is there any ways to make it without changing package code?
The text was updated successfully, but these errors were encountered:
I have two models: Board and User
and I made UserRouter, where watch users, who have at least one common board with current login user.
But there was one problem: it did not automatically update list of boards ids. So, i decided, if user id is permanently constant, then it will be better use it.
But there are another problem, which i found in channel_utils.py in function has_related_value. It checks condition in this line:
getattr(obj, property_name).filter(**{filter_by_val: channel_val}).exists()
. But there it is getting current user relationship objects. So, i changed this line toobj.__class__.objects.filter(pk=obj.pk, **{field: channel_val}).exists()
and it begin works correctly (at least, i think so).And i want to ask, is there any ways to make it without changing package code?
The text was updated successfully, but these errors were encountered: