def send_contact_us_email(data): with app.app_context(): html = render_template('contact_us_form_submit_email.html', **data) _send_email(app.config['CONTACT_US_EMAIL_SENDER'], app.config['CONTACT_US_EMAIL_RECEIVERS'], "Someone contacted you for TestRocket", html)
def send_email_forgot_password(email, reset_url): with app.app_context(): html = render_template('forgot_password_reset_email.html', password_reset_url=reset_url) _send_email(app.config['FORGOT_PASSWORD_EMAIL_SENDER'], email, "Password reset link", html)
def send_email_for_mock_test(attempted_mock_test_id): with app.app_context(): amt = AttemptedMockTest.query.get(attempted_mock_test_id) if amt is None: raise InvalidAttemptedMockTestId mock_test = MockTest.query.get(amt.mock_test_id) student = Student.query.get(amt.student_id) params = { 'mock_test_name': mock_test.name, 'pdf_url': amt.pdf_report_url, 'mock_test_exam_name': app.config['TARGET_EXAMS'][str(mock_test.target_exam)], 'student_name': student.name, 'student_mobile': student.mobile_no, 'student_email': student.email, } # html = render_template('mock_test_attempt_complete_email_student.html', **params) # _send_email(app.config['TEST_REPORT_EMAIL_SENDER'], student.email, # "Report for test %s" % mock_test.name, html) html = render_template('mock_test_attempt_complete_email_teacher.html', **params) _send_email( app.config['TEST_REPORT_EMAIL_SENDER'], app.config['PDF_REPORT_EMAIL_RECEIVERS'], "Report for test %s with id %s" % (mock_test.name, str(amt.id)), html)
def authenticate_by_username(cls, username, password): """ Used in institute login :param username: chosen username of the institute :param password: :return: the institute row if authentication successful, none otherwise """ with app.app_context(): ins = cls.query.filter(cls.username == username, cls.password == password).first() return ins
def upload_pdf_report(attempted_mock_test_id): with app.app_context(): amt = AttemptedMockTest.query.get(attempted_mock_test_id) if amt is None: raise InvalidAttemptedMockTestId if amt.pdf_report_url is None: pdf_report_file_name = create_pdf_report(amt.id) f = open(pdf_report_file_name, 'rb').read() s3 = S3() pdf_url = s3.upload(f, 'application/pdf') os.remove(pdf_report_file_name) amt.pdf_report_url = pdf_url db.session.commit() return pdf_url else: return amt.pdf_report_url
def send_welcome_admin_email(data): with app.app_context(): html = render_template('welcome_admin_email.html', **data) _send_email(app.config['WELCOME_EMAIL_SENDER'], data['email'], "Welcome to TestRocket", html)