def callback(): recipient_id = search_bookmark.user.id msg = bookmark_utils.make_search_email(search_bookmark) msg = EmailMessage.objects.create_from_message(msg) msg.send() logger.info("Sent search bookmark alert to %s about %s" % (recipient_id, search_bookmark.id))
def send_search_bookmark_email(self, search_bookmark, now_month): try: recipient_id = search_bookmark.user.id msg = bookmark_utils.make_search_email(search_bookmark, tag=now_month) msg = EmailMessage.objects.create_from_message(msg) msg.send() logger.info( "Sent search bookmark alert to %s about %s" % ( recipient_id, search_bookmark.id)) except bookmark_utils.BadAlertImageError as e: logger.exception(e)
def preview_bookmark(request, practice=None, pct=None, url=None, name=None): user = User(email='*****@*****.**') user.profile = Profile() if pct or practice: context = bookmark_utils.InterestingMeasureFinder( practice=practice, pct=pct).context_for_org_email() bookmark = OrgBookmark(practice=practice, pct=pct, user=user) msg = bookmark_utils.make_org_email(bookmark, context) else: bookmark = SearchBookmark(url=url, user=user, name=name) msg = bookmark_utils.make_search_email(bookmark) html = msg.alternatives[0][0] images = msg.attachments return HttpResponse(_convert_images_to_data_uris(html, images))
def preview_bookmark(request, practice=None, pct=None, url=None, name=None): user = User(email='*****@*****.**') user.profile = Profile() if pct or practice: context = bookmark_utils.InterestingMeasureFinder( practice=practice, pct=pct ).context_for_org_email() bookmark = OrgBookmark(practice=practice, pct=pct, user=user) msg = bookmark_utils.make_org_email( bookmark, context) else: bookmark = SearchBookmark(url=url, user=user, name=name) msg = bookmark_utils.make_search_email(bookmark) html = msg.alternatives[0][0] images = msg.attachments return HttpResponse(_convert_images_to_data_uris(html, images))
def handle(self, *args, **options): self.validate_options(**options) for org_bookmark in self.get_org_bookmarks(**options): stats = bookmark_utils.InterestingMeasureFinder( practice=org_bookmark.practice or options['practice'], pct=org_bookmark.pct or options['ccg']).context_for_org_email() msg = bookmark_utils.make_org_email( org_bookmark, stats) msg.send() logger.info("Sent message to user %s about bookmark %s" % ( msg.recipients(), org_bookmark.id)) for search_bookmark in self.get_search_bookmarks(**options): recipient_id = search_bookmark.user.id msg = bookmark_utils.make_search_email( search_bookmark) msg.send() logger.info("Sent message to user %s about bookmark %s" % ( recipient_id, search_bookmark.id))