def post(self): if not self.current_user_can('send_daily_email'): raise tornado.web.HTTPError(401) action = self.get_argument('action', None) if not action: return self.write("Select an action") if action == "setup_email": posts = postsdb.get_hot_posts_by_day(datetime.today()) slugs = [] for i, post in enumerate(posts): if i < 5: slugs.append(post['slug']) response1 = emailsdb.construct_daily_email(slugs) print response1 response2 = emailsdb.setup_email_list() print response2 if action == "add_list_to_email": response3 = emailsdb.add_list_to_email() print response3 if action == "send_email": response4 = emailsdb.send_email() print response4
def post(self): if not self.current_user_can('send_daily_email'): raise tornado.web.HTTPError(401) slugs = self.request.arguments['slugs'] if not slugs: return self.write("No posts selected") email = emailsdb.construct_daily_email(slugs) recipients = userdb.get_newsletter_recipients() if self.get_argument('preview', '') == "true": self.render('admin/daily_email.html', slugs=slugs, posts=None, email=email, has_previewed=True, has_sent=False, recipients=recipients) else: emailsdb.send_daily_email(email) self.redirect('/admin/daily_email/history')