Example #1
0
    def send_email(self, limit=5000):
        filename = Feed.xls_query_popularity(self.query, limit=limit)
        xlsx = open(filename, "r")

        params = {'query': self.query}
        text = render_to_string('mail/email_popularity_query.txt', params)
        html = render_to_string('mail/email_popularity_query.xhtml', params)
        subject = "Keyword popularity spreadsheet: \"%s\"" % self.query
        msg = EmailMultiAlternatives(subject,
                                     text,
                                     from_email='NewsBlur <%s>' %
                                     settings.HELLO_EMAIL,
                                     to=['<%s>' % (self.email)])
        msg.attach_alternative(html, "text/html")
        msg.attach(
            filename, xlsx.read(),
            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
        )
        msg.send()

        self.is_emailed = True
        self.save()

        logging.debug(" -> ~BB~FM~SBSent email for popularity query: %s" %
                      self)
Example #2
0
    def handle(self, *args, **options):
        # settings.LOG_TO_STREAM = True

        # Feed.query_popularity(options['query'], limit=options['limit'])
        Feed.xls_query_popularity(options['query'], limit=options['limit'])
Example #3
0
    def handle(self, *args, **options):
        # settings.LOG_TO_STREAM = True

        # Feed.query_popularity(options['query'], limit=options['limit'])
        Feed.xls_query_popularity(options['query'], limit=options['limit'])