Beispiel #1
0
    def publish_related_blogs(self, theme):
        from liveblog.blogs.tasks import publish_blog_embed_on_s3
        blogs = get_resource_service('blogs').find({'blog_preferences.theme': theme.get('name')})
        outputs = get_resource_service('outputs').find({'theme': theme.get('name')})
        countdown = 1
        step = STEPS.get('default')
        if theme.get('seoTheme'):
            step = STEPS.get('seoTheme')
        if theme.get('ampTheme'):
            step = STEPS.get('ampTheme')

        for blog in blogs:
            publish_blog_embed_on_s3.apply_async(args=[blog.get('_id')], countdown=countdown)
            countdown += step

        for output in outputs:
            publish_blog_embed_on_s3.apply_async(args=[output.get('blog')],

                                                 kwargs={
                                                     'theme': output.get('theme', None),
                                                     'output': output},
                                                 countdown=countdown)
            countdown += step

        return blogs
Beispiel #2
0
 def on_created(self, outputs):
     for output in outputs:
         if output.get('blog'):
             publish_blog_embed_on_s3.apply_async(args=[output.get('blog')],
                                                  kwargs={'output': output},
                                                  countdown=2)