def setUp(self): self.app = create_app('config/test.ini').test_client() init_db() # TODO move this to the proper place in the code dbfixture = SQLAlchemyFixture( env={'UserData': User}, engine=dailylog.db.engine) self.data = dbfixture.data(UserData) self.data.setup()
def main(config_filename): app = create_app(config_filename) subject = format_subject() # want to paginate this later for user in User.query.all(): body = format_body(user.questions) email = DeliverableEmail(app, user.email, subject, body, app.config['MAIL_USER']) email.send()
def main(config_filename): app = create_app(config_filename) mailbox = DailyLogResponseMailbox(app.config['MAIL_SERVER'], app.config['MAIL_USER'], app.config['MAIL_PASSWORD']) uids = mailbox.uids()[:app.config['MAILS_PER_PROCESS']] for uid in uids: email = mailbox.get_email(uid) user = User.query.filter_by(email=email.sender).first() # todo error checking that the user does not exist # todo error checking that the email is not a valid dailylogemail answers = email.get_answers([q.text for q in user.questions]) date = email.get_date() for i in xrange(len(answers)): answer = Answer(answers[i], date, user, user.questions[i]) db_session.add(answer) db_session.commit() # todo get rid of the uids that errored out mailbox.delete(uids)
from dailylog import create_app if __name__ == '__main__': app = create_app('config/development.ini') app.run(debug=True, host='0.0.0.0')
from werkzeug.contrib.fixers import ProxyFix from dailylog import create_app app = create_app('config/production.ini') app.wsgi_app = ProxyFix(app.wsgi_app)