def send_hipchat_reply(user, reply): """ Send a hipchat message representing the supplied reply. """ review = reply.base_reply_to review_request = review.review_request if not review_request.public: return extra_context = { 'user': user, 'review': review, 'reply': reply, } has_error, extra_context['comment_entries'] = \ build_diff_comment_fragments( reply.comments.order_by('filediff', 'first_line'), extra_context, "notifications/email_diff_comment_fragment.html") format_and_send_hipchat_message(user, reply.user, review_request, 'notifications/reply_hipchat.txt', "purple", extra_context)
def mail_reply(reply): """ Sends an e-mail representing the supplied reply to a review. """ review = reply.base_reply_to review_request = review.review_request if not review_request.public: return extra_context = { 'user': reply.user, 'review': review, 'reply': reply, } has_error, extra_context['comment_entries'] = \ build_diff_comment_fragments( reply.comments.order_by('filediff', 'first_line'), extra_context, "notifications/email_diff_comment_fragment.html") reply.email_message_id = \ send_review_mail(reply.user, review_request, "Re: Review Request %d: %s" % ( review_request.display_id, review_request.summary), review.email_message_id, review.participants, 'notifications/reply_email.txt', 'notifications/reply_email.html', extra_context) reply.time_emailed = timezone.now() reply.save()
def mail_review(user, review): """Sends an e-mail representing the supplied review.""" review_request = review.review_request if not review_request.public: return review.ordered_comments = review.comments.order_by("filediff", "first_line") extra_context = {"user": user, "review": review} has_error, extra_context["comment_entries"] = build_diff_comment_fragments( review.ordered_comments, extra_context, "notifications/email_diff_comment_fragment.html" ) review.email_message_id = send_review_mail( user, review_request, u"Re: Review Request: %s" % review_request.summary, review_request.email_message_id, None, "notifications/review_email.txt", "notifications/review_email.html", extra_context, ) review.time_emailed = datetime.now() review.save()
def send_hipchat_review(user, review): """ Send a hipchat message representing the supplied review. """ review_request = review.review_request if not review_request.public: return review.ordered_comments = \ review.comments.order_by('filediff', 'first_line') extra_context = { 'user': user, 'review': review, } has_error, extra_context['comment_entries'] = \ build_diff_comment_fragments( review.ordered_comments, extra_context, "notifications/email_diff_comment_fragment.html") if review.ship_it: color = "green" else: color = "purple" format_and_send_hipchat_message(user, review.user, review_request, 'notifications/review_hipchat.txt', color, extra_context)
def mail_reply(user, reply): """ Sends an e-mail representing the supplied reply to a review. """ review = reply.base_reply_to review_request = review.review_request if not review_request.public: return extra_context = {"user": user, "review": review, "reply": reply} has_error, extra_context["comment_entries"] = build_diff_comment_fragments( reply.comments.order_by("filediff", "first_line"), extra_context, "notifications/email_diff_comment_fragment.html", ) reply.email_message_id = send_review_mail( user, review_request, u"Re: Review Request: %s" % review_request.summary, review.email_message_id, review.participants, "notifications/reply_email.txt", "notifications/reply_email.html", extra_context, ) reply.time_emailed = datetime.now() reply.save()
def mail_review(user, review): """Sends an e-mail representing the supplied review.""" review_request = review.review_request if not review_request.public: return review.ordered_comments = \ review.comments.order_by('filediff', 'first_line') extra_context = { 'user': user, 'review': review, } has_error, extra_context['comment_entries'] = \ build_diff_comment_fragments( review.ordered_comments, extra_context, "notifications/email_diff_comment_fragment.html") review.email_message_id = \ send_review_mail(user, review_request, u"Re: Review Request %d: %s" % (review_request.id, review_request.summary), review_request.email_message_id, None, 'notifications/review_email.txt', 'notifications/review_email.html', extra_context) review.time_emailed = timezone.now() review.save()
def mail_reply(user, reply): """ Sends an e-mail representing the supplied reply to a review. """ review = reply.base_reply_to review_request = review.review_request if not review_request.public: return extra_context = { 'user': user, 'review': review, 'reply': reply, } has_error, extra_context['comment_entries'] = \ build_diff_comment_fragments( reply.comments.order_by('filediff', 'first_line'), extra_context, "notifications/email_diff_comment_fragment.html") reply.email_message_id = \ send_review_mail(user, review_request, u"Re: Review Request: %s" % review_request.summary, review.email_message_id, harvest_people_from_review(review), 'notifications/reply_email.txt', 'notifications/reply_email.html', extra_context) reply.time_emailed = datetime.now() reply.save()
def mail_review(user, review): """Sends an e-mail representing the supplied review.""" review_request = review.review_request if not review_request.public: return review.ordered_comments = \ review.comments.order_by('filediff', 'first_line') extra_context = { 'user': user, 'review': review, } has_error, extra_context['comment_entries'] = \ build_diff_comment_fragments( review.ordered_comments, extra_context, "notifications/email_diff_comment_fragment.html") review.email_message_id = \ send_review_mail(user, review_request, u"Re: Review Request %d: %s" % ( review_request.display_id, review_request.summary), review_request.email_message_id, None, 'notifications/review_email.txt', 'notifications/review_email.html', extra_context) review.time_emailed = timezone.now() review.save()
def mail_review(review, user, to_submitter_only): """Send an e-mail representing the supplied review. Args: review (reviewboard.reviews.model.Review): The review to send an e-mail about. to_submitter_only (bool): Determines if the review is to the submitter only or not. """ review_request = review.review_request if not review_request.public: return review.ordered_comments = review.comments.order_by("filediff", "first_line") extra_context = {"user": review.user, "review": review} extra_headers = {} if review.ship_it: extra_headers["X-ReviewBoard-ShipIt"] = "1" if review.ship_it_only: extra_headers["X-ReviewBoard-ShipIt-Only"] = "1" has_error, extra_context["comment_entries"] = build_diff_comment_fragments( review.ordered_comments, extra_context, "notifications/email_diff_comment_fragment.html" ) reviewer = review.user limit_to = None if to_submitter_only: limit_to = set([review_request.submitter, review.user]) to_field, cc_field = build_recipients(reviewer, review_request, limit_recipients_to=limit_to) to_field, cc_field = filter_email_recipients_from_hooks( to_field, cc_field, review_published, review=review, user=user, review_request=review_request ) review.email_message_id = send_review_mail( reviewer, review_request, ("Re: Review Request %d: %s" % (review_request.display_id, review_request.summary)), review_request.email_message_id, to_field, cc_field, "notifications/review_email.txt", "notifications/review_email.html", extra_context, extra_headers=extra_headers, ) review.time_emailed = timezone.now() review.save()
def prepare_reply_published_mail(user, reply, review, review_request): """Return an e-mail representing the supplied reply to a review. Args: user (django.contrib.auth.models.User): The user who published the reply. reply (reviewboard.reviews.models.review.Review): The review reply to send an e-mail about. review (reviewboard.reviews.models.review.Review): The review that was replied to. review_request (reviewboard.reviews.models.review_request.ReviewRequest): The review request. Returns: EmailMessage: The generated e-mail message. """ from reviewboard.reviews.views import build_diff_comment_fragments extra_context = { 'user': reply.user, 'review': review, 'reply': reply, 'site_url': _get_server_base_url(), } extra_context['comment_entries'] = build_diff_comment_fragments( reply.comments.order_by('filediff', 'first_line'), extra_context, 'notifications/email_diff_comment_fragment.html')[1] to_field, cc_field = build_recipients( user=reply.user, review_request=review_request, extra_recipients=review_request.review_participants) to_field, cc_field = filter_email_recipients_from_hooks( to_field, cc_field, reply_published, reply=reply, user=user, review=review, review_request=review_request) summary = _ensure_unicode(review_request.summary) return prepare_base_review_request_mail( user, review_request, 'Re: Review Request %d: %s' % (review_request.display_id, summary), review.email_message_id, to_field, cc_field, 'notifications/reply_email', extra_context)
def mail_reply(reply, user): """Send an e-mail representing the supplied reply to a review. Args: reply (reviewboard.reviews.models.Review): The review reply to send an e-mail about. """ review = reply.base_reply_to review_request = review.review_request if not review_request.public: return extra_context = { 'user': reply.user, 'review': review, 'reply': reply, } has_error, extra_context['comment_entries'] = \ build_diff_comment_fragments( reply.comments.order_by('filediff', 'first_line'), extra_context, "notifications/email_diff_comment_fragment.html") reviewer = reply.user to_field, cc_field = build_recipients(reviewer, review_request, review_request.participants) to_field, cc_field = filter_email_recipients_from_hooks( to_field, cc_field, reply_published, reply=reply, user=user, review=review, review_request=review_request) summary = _ensure_unicode(review_request.summary) reply.email_message_id = send_review_mail( user, review_request, ('Re: Review Request %d: %s' % (review_request.display_id, summary)), review.email_message_id, to_field, cc_field, 'notifications/reply_email.txt', 'notifications/reply_email.html', extra_context) reply.time_emailed = timezone.now() reply.save()
def mail_reply(reply, user): """Send an e-mail representing the supplied reply to a review. Args: reply (reviewboard.reviews.models.Review): The review reply to send an e-mail about. """ review = reply.base_reply_to review_request = review.review_request if not review_request.public: return extra_context = {"user": reply.user, "review": review, "reply": reply} has_error, extra_context["comment_entries"] = build_diff_comment_fragments( reply.comments.order_by("filediff", "first_line"), extra_context, "notifications/email_diff_comment_fragment.html", ) reviewer = reply.user to_field, cc_field = build_recipients(reviewer, review_request, review_request.participants) to_field, cc_field = filter_email_recipients_from_hooks( to_field, cc_field, reply_published, reply=reply, user=user, review=review, review_request=review_request ) reply.email_message_id = send_review_mail( user, review_request, ("Re: Review Request %d: %s" % (review_request.display_id, review_request.summary)), review.email_message_id, to_field, cc_field, "notifications/reply_email.txt", "notifications/reply_email.html", extra_context, ) reply.time_emailed = timezone.now() reply.save()
def mail_review(review, user, to_submitter_only): """Send an e-mail representing the supplied review. Args: review (reviewboard.reviews.models.Review): The review to send an e-mail about. to_submitter_only (bool): Determines if the review is to the submitter only or not. """ review_request = review.review_request if not review_request.public: return review.ordered_comments = \ review.comments.order_by('filediff', 'first_line') has_issues = (review.ship_it and review.has_comments(only_issues=True)) extra_context = { 'user': review.user, 'review': review, 'has_issues': has_issues, } extra_headers = {} if review.ship_it: extra_headers['X-ReviewBoard-ShipIt'] = '1' if review.ship_it_only: extra_headers['X-ReviewBoard-ShipIt-Only'] = '1' has_error, extra_context['comment_entries'] = \ build_diff_comment_fragments( review.ordered_comments, extra_context, "notifications/email_diff_comment_fragment.html") reviewer = review.user limit_to = None if to_submitter_only: limit_to = set([review_request.submitter, review.user]) to_field, cc_field = build_recipients(reviewer, review_request, limit_recipients_to=limit_to) to_field, cc_field = filter_email_recipients_from_hooks( to_field, cc_field, review_published, review=review, user=user, review_request=review_request) summary = _ensure_unicode(review_request.summary) review.email_message_id = send_review_mail( reviewer, review_request, ('Re: Review Request %d: %s' % (review_request.display_id, summary)), review_request.email_message_id, to_field, cc_field, 'notifications/review_email.txt', 'notifications/review_email.html', extra_context, extra_headers=extra_headers) review.time_emailed = timezone.now() review.save()
def prepare_review_published_mail(user, review, review_request, request, to_submitter_only=False): """Return an e-mail representing the supplied review. Args: user (django.contrib.auth.models.User): The user who published the review. review (reviewboard.reviews.models.review.Review): The review to send an e-mail about. review_request (reviewboard.reviews.models.review_request.ReviewRequest): The review request that was reviewed. to_submitter_only (bool): Whether or not the review should be sent to the submitter only. Returns: EmailMessage: The generated e-mail message. """ from reviewboard.reviews.views import build_diff_comment_fragments review.ordered_comments = review.comments.order_by('filediff', 'first_line') has_issues = (review.ship_it and review.has_comments(only_issues=True)) extra_context = { 'user': review.user, 'review': review, 'has_issues': has_issues, 'request': request, } extra_headers = {} if review.ship_it: extra_headers['X-ReviewBoard-ShipIt'] = '1' if review.ship_it_only: extra_headers['X-ReviewBoard-ShipIt-Only'] = '1' extra_context['comment_entries'] = build_diff_comment_fragments( review.ordered_comments, extra_context, 'notifications/email_diff_comment_fragment.html')[1] limit_to = None if to_submitter_only: limit_to = {review_request.submitter, review.user} to_field, cc_field = build_recipients(review.user, review_request, limit_recipients_to=limit_to) to_field, cc_field = filter_email_recipients_from_hooks( to_field, cc_field, review_published, user=user, review=review, to_submitter_only=to_submitter_only, review_request=review_request) summary = _ensure_unicode(review_request.summary) return prepare_base_review_request_mail( review.user, review_request, 'Re: Review Request %d: %s' % (review_request.display_id, summary), review_request.email_message_id, to_field, cc_field, 'notifications/review_email', extra_context, extra_headers=extra_headers)
def mail_review(review, user, to_submitter_only): """Send an e-mail representing the supplied review. Args: review (reviewboard.reviews.models.Review): The review to send an e-mail about. to_submitter_only (bool): Determines if the review is to the submitter only or not. """ review_request = review.review_request if not review_request.public: return review.ordered_comments = \ review.comments.order_by('filediff', 'first_line') extra_context = { 'user': review.user, 'review': review, } extra_headers = {} if review.ship_it: extra_headers['X-ReviewBoard-ShipIt'] = '1' if review.ship_it_only: extra_headers['X-ReviewBoard-ShipIt-Only'] = '1' has_error, extra_context['comment_entries'] = \ build_diff_comment_fragments( review.ordered_comments, extra_context, "notifications/email_diff_comment_fragment.html") reviewer = review.user limit_to=None if to_submitter_only: limit_to = set([review_request.submitter, review.user]) to_field, cc_field = build_recipients(reviewer, review_request, limit_recipients_to=limit_to) to_field, cc_field = filter_email_recipients_from_hooks( to_field, cc_field, review_published, review=review, user=user, review_request=review_request) summary = _ensure_unicode(review_request.summary) review.email_message_id = send_review_mail( reviewer, review_request, ('Re: Review Request %d: %s' % (review_request.display_id, summary)), review_request.email_message_id, to_field, cc_field, 'notifications/review_email.txt', 'notifications/review_email.html', extra_context, extra_headers=extra_headers) review.time_emailed = timezone.now() review.save()
def prepare_review_published_mail(user, review, review_request, request, to_owner_only=False): """Return an e-mail representing the supplied review. Args: user (django.contrib.auth.models.User): The user who published the review. review (reviewboard.reviews.models.review.Review): The review to send an e-mail about. review_request (reviewboard.reviews.models.review_request.ReviewRequest): The review request that was reviewed. to_owner_only (bool): Whether or not the review should be sent to the submitter only. Returns: EmailMessage: The generated e-mail message. """ from reviewboard.reviews.views import build_diff_comment_fragments review.ordered_comments = review.comments.order_by('filediff', 'first_line') has_issues = (review.ship_it and review.has_comments(only_issues=True)) extra_context = { 'user': review.user, 'review': review, 'has_issues': has_issues, 'request': request, 'site_url': _get_server_base_url(), } extra_headers = {} if review.ship_it: extra_headers['X-ReviewBoard-ShipIt'] = '1' if review.ship_it_only: extra_headers['X-ReviewBoard-ShipIt-Only'] = '1' extra_context['comment_entries'] = build_diff_comment_fragments( review.ordered_comments, extra_context, 'notifications/email_diff_comment_fragment.html')[1] limit_to = None if to_owner_only: limit_to = {review_request.submitter, review.user} to_field, cc_field = build_recipients(review.user, review_request, limit_recipients_to=limit_to) to_field, cc_field = filter_email_recipients_from_hooks( to_field, cc_field, review_published, user=user, review=review, to_owner_only=to_owner_only, review_request=review_request) summary = _ensure_unicode(review_request.summary) return prepare_base_review_request_mail( review.user, review_request, 'Re: Review Request %d: %s' % (review_request.display_id, summary), review_request.email_message_id, to_field, cc_field, 'notifications/review_email', extra_context, extra_headers=extra_headers)