(uid, extra_context)
Notify users watching a given tag found in post.
Notify users watching a given tag found in post.
Notify users watching a given tag found in post .
def notify_watched_tags(uid, extra_context):
    """
    Notify users watching a given tag found in post.
    """
    from biostar.accounts.models import User
    from biostar.forum.models import Post
    from django.conf import settings

    post = Post.objects.filter(uid=uid).first()

    # Update template context with post
    extra_context.update(dict(post=post))

    users = [User.objects.filter(profile__watched__name__iexact=tag.name).distinct()
             for tag in post.root.tags.all()]

    # Flatten nested users queryset and get email.
    emails = set(u.email for o in users for u in o)

    from_email = settings.DEFAULT_NOREPLY_EMAIL
    if emails:
        send_email(template_name='messages/watched_tags.html',
                   extra_context=extra_context,
                   name=post.author.profile.name,
                   recipient_list=emails,
                   from_email=from_email,
                   mass=True)
def notify_watched_tags ( uid , extra_context ) : from biostar . accounts . models import User from biostar . forum . models import Post from django . conf import settings post = Post . objects . filter ( uid = uid ) . first ( ) # Update template context with post extra_context . update ( dict ( post = post ) ) users = [ User . objects . filter ( profile__watched__name__iexact = tag . name ) . distinct ( ) for tag in post . root . tags . all ( ) ] # Flatten nested users queryset and get email. emails = set ( u . email for o in users for u in o ) from_email = settings . DEFAULT_NOREPLY_EMAIL if emails : send_email ( template_name = 'messages/watched_tags.html' , extra_context = extra_context , name = post . author . profile . name , recipient_list = emails , from_email = from_email , mass = True )