Ejemplo n.º 1
0
def send_place_updates(sender, instance, **kwargs):
    place = instance
    for subscription in ChannelSubscription.objects.recent().filter(
            user__in=place.group.members.all()).distinct():
        payload = PlaceSerializer(place,
                                  context={
                                      'request':
                                      MockRequest(user=subscription.user)
                                  }).data
        send_in_channel(subscription.reply_channel,
                        topic='places:place',
                        payload=payload)
Ejemplo n.º 2
0
def place_subscription_updated(sender, instance, **kwargs):
    place = instance.place
    user = instance.user
    payload = PlaceSerializer(place,
                              context={
                                  'request': MockRequest(user=user)
                              }).data
    for subscription in ChannelSubscription.objects.recent().filter(
            user=user).distinct():
        send_in_channel(subscription.reply_channel,
                        topic='places:place',
                        payload=payload)
Ejemplo n.º 3
0
 def test_place_instantiation(self):
     MockRequest = namedtuple('Request', ['user'])
     serializer = PlaceSerializer(
         self.place, context={'request': MockRequest(user=UserFactory())})
     self.assertEqual(serializer.data['name'], self.place.name)