Beispiel #1
0
def update_feed_for_active_transmissions(transmission_id=None):
    start_date = timezone.now() - datetime.timedelta(hours=4)
    end_date = timezone.now() + datetime.timedelta(hours=4)
    if not transmission_id:
        active_transmissions = Transmission.objects.filter(
            match__match_time__range=(start_date, end_date),
            event_type__slug="soccer",
            published=True)
    else:
        active_transmissions = Transmission.objects.filter(pk=transmission_id)

    # print active_transmissions

    for transmission in active_transmissions:
        get_match(country=transmission.match.category.country.name.lower(),
                  match_id=[transmission.match.g_static_id],
                  cat_id=transmission.match.category.g_id
                  if transmission.match.category else None,
                  get_players=True)

        data = json.dumps(data_match(transmission.match.id))
        redis = Db('goalservematch', transmission.match.id)
        redis.publish(data)

    log_it('update_feed_for_active_transmissions')
Beispiel #2
0
def update_feed_for_active_transmissions(transmission_id=None):
    start_date = timezone.now() - datetime.timedelta(hours=4)
    end_date = timezone.now() + datetime.timedelta(hours=4)
    if not transmission_id:
        active_transmissions = Transmission.objects.filter(
            match__match_time__range=(start_date, end_date),
            event_type__slug="soccer",
            published=True
        )
    else:
        active_transmissions = Transmission.objects.filter(pk=transmission_id)

    # print active_transmissions

    for transmission in active_transmissions:
        get_match(country=transmission.match.category.country.name.lower(),
                  match_id=[transmission.match.g_static_id],
                  cat_id=transmission.match.category.g_id if transmission.match.category else None,
                  get_players=True)

        data = json.dumps(data_match(transmission.match.id))
        redis = Db('goalservematch', transmission.match.id)
        redis.publish(data)

    log_it('update_feed_for_active_transmissions')
Beispiel #3
0
    def post(self, request, *args, **kwargs):
        msg = request.POST['message']
        obj = Message.objects.create(message=msg, user=request.user,
                                     event=self.get_object(), published=True)
        if obj.published:
            redis = Db(self.__class__.__name__, self.get_object().id)
            redis.publish(msg)

        return HttpResponse(msg)
Beispiel #4
0
 def save(self, *args, **kwargs):
     self.channel_long_slug = self.container.channel_long_slug
     self.slug = self.container.slug
     super(Notification, self).save(*args, **kwargs)
     _db = Db(self.container.get_absolute_url(),
              self.container.id)
     message = self.message
     if self.type == "json":
         message = json.dumps(self.message)
     _db.publish(json.dumps({
         "action": self.action,
         "id": self.id,
         "published": self.published,
         "date": self.date_available.strftime("%D %T"),
         "message": message}))
Beispiel #5
0
 def save(self, *args, **kwargs):
     self.channel_long_slug = self.container.channel_long_slug
     self.slug = self.container.slug
     super(Notification, self).save(*args, **kwargs)
     _db = Db(self.container.get_absolute_url(), self.container.id)
     message = self.message
     if self.type == "json":
         message = json.dumps(self.message)
     _db.publish(
         json.dumps({
             "action": self.action,
             "id": self.id,
             "published": self.published,
             "date": self.date_available.strftime("%D %T"),
             "message": message
         }))
     _db.close()
Beispiel #6
0
    def post(self, request, *args, **kwargs):
        msg = request.POST.get('message', None)
        id = request.POST.get('id_message', None)
        event = self.get_object()
        redis = Db(self.__class__.__name__, self.get_object().id)
        if request.POST.get('stream', None):
            redis.publish(json.dumps({"event": "stream"}))
            return HttpResponse('stream')
        _list = {k: v for k, v in request.POST.iteritems()}
        if id:
            obj = Message.objects.get(id=id)
            published = request.POST.get('published', True)
            if published == 'false':
                published = False
            else:
                published = True
            obj.published = published
            if msg:
                obj.message = msg
            obj.user = request.user
            obj.save()
            redis.publish(
                json.dumps({
                    "event": "update",
                    "id": id,
                    "published": published,
                    "msg": msg
                }))
        else:
            obj = Message.objects.create(message=msg,
                                         user=request.user,
                                         event=event,
                                         published=True)
            id = obj.id
            redis.publish(
                json.dumps({
                    "event": "message",
                    "id": id,
                    "msg": msg
                }))
            _list['id_message'] = id

        event.create_event(_list)
        return HttpResponse(msg)