def send_complete_registration_prompting_emails(self):
     confirmed_users = self.db.session.query(self.user_model).filter(
         self.user_model.password is not None).all()
     recipients = [
         u for u in confirmed_users
         if u.self_registration_complete() is False
     ]
     self.__send_prompts(
         recipients,
         EmailService(self.app).complete_registration_prompt_email,
         'complete_registration_prompt')
 def send_confirm_email(user):
     current_studies = db.session.query(Study).filter_by(
         status='currently_enrolling').all()
     for study in current_studies:
         study.link = app.config['SITE_URL'] + '/#/study/' + str(study.id) + \
                      EmailService.generate_google_analytics_link_content('reset_password_study' + str(study.id),
                                                                          '0days')
     tracking_code = email_service.confirm_email(user, current_studies)
     log = EmailLog(user_id=user.id,
                    type="confirm_email",
                    tracking_code=tracking_code)
     db.session.add(log)
     db.session.commit()
 def send_dependent_profile_prompting_emails(self):
     confirmed_users = self.db.session.query(self.user_model).filter(self.user_model.password is not None).all()
     recipients = []
     for u in confirmed_users:
         if (u.self_participant() is not None) \
                 and (u.self_participant().relationship.name == 'self_guardian') \
                 and (u.self_registration_complete() is True):
             dependents = [p for p in u.participants if p.relationship.name == 'dependent']
             incomplete_dependents = [p for p in dependents if p.get_percent_complete() < 1]
             if (len(dependents) == 0) or (len(incomplete_dependents) > 0):
                 recipients.append(u)
     self.__send_prompts(recipients, EmailService(self.app).complete_dependent_profile_prompt_email,
                         'dependent_profile_prompt')
 def __send_prompting_email(self, user, send_method, log_type, days):
     campaign = 'prompting'
     if log_type == 'confirm_email':
         campaign = 'reset_password'
     elif log_type == 'complete_registration_prompt':
         campaign = 'create_yourprofile'
     elif log_type == 'dependent_profile_prompt':
         campaign = 'create_dependentprofile'
     current_studies = self.db.session.query(self.study_model).filter_by(status='currently_enrolling').all()
     for study in current_studies:
         study.link = self.app.config['SITE_URL'] + '/#/study/' + str(study.id) + \
                      EmailService.generate_google_analytics_link_content(campaign + '_study' + str(study.id), days)
     tracking_code = send_method(user, current_studies, days)
     log = self.email_log_model(user_id=user.id, type=log_type, tracking_code=tracking_code)
     self.db.session.add(log)
     self.db.session.commit()
Example #5
0
#!/Users/nathancheever/miniconda3/envs/barker/bin/python
# -*- coding:utf-8 -*-
"""Run a batch"""

from app.update_bookmarks import CollectUpdateBookmarks
from app.create_newsletter import NewsletterTemplate
from app.email_service import EmailService


if __name__ == '__main__':
    success = CollectUpdateBookmarks().main()
    if success:
        success = NewsletterTemplate().main()
        if success:
            EmailService().main()
Example #6
0
db = SQLAlchemy(app)

# Flask-Marshmallow provides HATEOAS links
ma = Marshmallow(app)

# Database Migrations
migrate = Migrate(app, db)

# Search System
elastic_index = ElasticIndex(app)

# file Server
file_server = FileServer(app)

# email service
email_service = EmailService(app)

# Single Signon
sso = SSO(app=app)

# Token Authentication
auth = HTTPTokenAuth('Bearer')

# Password Encryption
bcrypt = Bcrypt(app)


@app.cli.command()
def stop():
    """Stop the server."""
    pid = os.getpid()
 def send_confirm_prompting_emails(self):
     recipients = self.db.session.query(
         self.user_model).filter_by(password=None).all()
     self.__send_prompts(recipients,
                         EmailService(self.app).async_confirm_email,
                         'confirm_email')