(uid, extra_context={})
Generate notification for mailing list users.
Generate notification for mailing list users.
Generate notification for mailing list users .
def mailing_list(uid, extra_context={}):
    """
    Generate notification for mailing list users.
    """
    from django.conf import settings
    from biostar.forum.models import Post
    from biostar.accounts.models import User, Profile

    # Get the post and users that have this enabled.
    post = Post.objects.filter(uid=uid).first()
    users = User.objects.filter(profile__digest_prefs=Profile.ALL_MESSAGES)

    emails = [user.email for user in users]

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

    # Prepare the templates and emails
    email_template = "messages/mailing_list.html"
    author = post.author.profile.name
    from_email = settings.DEFAULT_NOREPLY_EMAIL
    if emails:
        send_email(template_name=email_template,
                   extra_context=extra_context,
                   name=author,
                   from_email=from_email,
                   recipient_list=emails,
                   mass=True)
def mailing_list ( uid , extra_context = { } ) : from django . conf import settings from biostar . forum . models import Post from biostar . accounts . models import User , Profile # Get the post and users that have this enabled. post = Post . objects . filter ( uid = uid ) . first ( ) users = User . objects . filter ( profile__digest_prefs = Profile . ALL_MESSAGES ) emails = [ user . email for user in users ] # Update template context with post extra_context . update ( dict ( post = post ) ) # Prepare the templates and emails email_template = "messages/mailing_list.html" author = post . author . profile . name from_email = settings . DEFAULT_NOREPLY_EMAIL if emails : send_email ( template_name = email_template , extra_context = extra_context , name = author , from_email = from_email , recipient_list = emails , mass = True )