def emails_with_users_and_watches(subject, text_template, html_template, context_vars, users_and_watches, from_email=settings.TIDINGS_FROM_ADDRESS, default_locale=settings.WIKI_DEFAULT_LANGUAGE, **extra_kwargs):
 @safe_translation
 def _make_mail(locale, user, watch):
  context_vars['user'] = user
  context_vars['watch'] = watch[0]
  context_vars['watches'] = watch
  msg = EmailMultiAlternatives((subject % context_vars), render_email(text_template, context_vars), from_email, [user.email], **extra_kwargs)
  if html_template:
   msg.attach_alternative(render_email(html_template, context_vars), 'text/html')
  return msg
 for (user, watch) in users_and_watches:
  if hasattr(user, 'locale'):
   locale = user.locale
  else:
   locale = default_locale
  (yield _make_mail(locale, user, watch))

def emails_with_users_and_watches ( subject , text_template , html_template , context_vars , users_and_watches , from_email = settings . TIDINGS_FROM_ADDRESS , default_locale = settings . WIKI_DEFAULT_LANGUAGE , ** extra_kwargs ) : @ safe_translation def _make_mail ( locale , user , watch ) : context_vars [ 'user' ] = user context_vars [ 'watch' ] = watch [ 0 ] context_vars [ 'watches' ] = watch msg = EmailMultiAlternatives ( ( subject % context_vars ) , render_email ( text_template , context_vars ) , from_email , [ user . email ] , ** extra_kwargs ) if html_template : msg . attach_alternative ( render_email ( html_template , context_vars ) , 'text/html' ) return msg for ( user , watch ) in users_and_watches : if hasattr ( user , 'locale' ) : locale = user . locale else : locale = default_locale ( yield _make_mail ( locale , user , watch ) )
return iterable of emailmessages with user and watch values substituted .