(request, limit=20, nmin=1)
return post
Create one publication from Herald accepted submissions ( up to 'limit' ).
Create one publication from Herald accepted submissions ( up to 'limit' ).
Create one publication from Herald accepted submissions ( up to limit ) .
def herald_publisher(request, limit=20, nmin=1):
    """
    Create one publication from Herald accepted submissions ( up to 'limit' ).
    """

    # Reset status on published links.
    # SharedLink.objects.filter(status=SharedLink.PUBLISHED).update(status=SharedLink.ACCEPTED)

    heralds = SharedLink.objects.filter(status=SharedLink.ACCEPTED).order_by('-pk')[:limit]
    count = heralds.count()

    if count < nmin:
        logger.warning(f"Not enough stories to publish, minimum of {nmin} required.")
        return

    # Create herald content
    date = util.now()

    date_fmt = date.strftime("%A, %B %d, %Y")

    title = f"The Biostar Herald for {date_fmt}"

    port = f':{settings.HTTP_PORT}' if settings.HTTP_PORT else ''

    base_url = f"{settings.PROTOCOL}://{settings.SITE_DOMAIN}{port}"
    authors = set(h.author for h in heralds)
    editors = set(h.editor for h in heralds)

    subscribe_url = reverse('herald_subscribe')
    context = dict(heralds=heralds, title=title, site_domain=settings.SITE_DOMAIN, protocol=settings.PROTOCOL,
                   base_url=base_url, authors=authors, editors=editors, subscribe_url=subscribe_url)

    content = render_template(template="herald/herald_content.md", context=context)

    # Create herald post
    user = User.objects.filter(is_superuser=True).first()
    post = auth.create_post(title=title, content=content, author=user, tag_val='herald', ptype=Post.HERALD,
                            nodups=False, request=request)

    # Tie these submissions to herald post
    hpks = heralds.values_list('pk', flat=True)
    SharedLink.objects.filter(pk__in=hpks).update(status=SharedLink.PUBLISHED, post=post, lastedit_date=date)

    # Log the action
    auth.db_logger(user=user, text=f"published {count} submissions in {title}")

    # Create a herald blog post
    herald_blog(post=post)

    # Send out herald emails
    herald_emails.spool(uid=post.uid)

    # Clean up declined links
    remove_declined()

    return post
def herald_publisher ( request , limit = 20 , nmin = 1 ) : # Reset status on published links. # SharedLink.objects.filter(status=SharedLink.PUBLISHED).update(status=SharedLink.ACCEPTED) heralds = SharedLink . objects . filter ( status = SharedLink . ACCEPTED ) . order_by ( '-pk' ) [ : limit ] count = heralds . count ( ) if count < nmin : logger . warning ( f"Not enough stories to publish, minimum of {nmin} required." ) return # Create herald content date = util . now ( ) date_fmt = date . strftime ( "%A, %B %d, %Y" ) title = f"The Biostar Herald for {date_fmt}" port = f':{settings.HTTP_PORT}' if settings . HTTP_PORT else '' base_url = f"{settings.PROTOCOL}://{settings.SITE_DOMAIN}{port}" authors = set ( h . author for h in heralds ) editors = set ( h . editor for h in heralds ) subscribe_url = reverse ( 'herald_subscribe' ) context = dict ( heralds = heralds , title = title , site_domain = settings . SITE_DOMAIN , protocol = settings . PROTOCOL , base_url = base_url , authors = authors , editors = editors , subscribe_url = subscribe_url ) content = render_template ( template = "herald/herald_content.md" , context = context ) # Create herald post user = User . objects . filter ( is_superuser = True ) . first ( ) post = auth . create_post ( title = title , content = content , author = user , tag_val = 'herald' , ptype = Post . HERALD , nodups = False , request = request ) # Tie these submissions to herald post hpks = heralds . values_list ( 'pk' , flat = True ) SharedLink . objects . filter ( pk__in = hpks ) . update ( status = SharedLink . PUBLISHED , post = post , lastedit_date = date ) # Log the action auth . db_logger ( user = user , text = f"published {count} submissions in {title}" ) # Create a herald blog post herald_blog ( post = post ) # Send out herald emails herald_emails . spool ( uid = post . uid ) # Clean up declined links remove_declined ( ) return post