Пример #1
0
def queue_no_addon_email(user):
    """Queue an email for user who has not connected an addon after
    `settings.NO_ADDON_WAIT_TIME` months of signing up for the OSF.
    """
    mails.queue_mail(to_addr=user.username,
                     mail=mails.NO_ADDON,
                     send_at=timezone.now() + settings.NO_ADDON_WAIT_TIME,
                     user=user,
                     fullname=user.fullname)
Пример #2
0
def queue_osf4m_welcome_email(user, conference, node):
    """Queue an email once a new user is created for OSF for Meetings"""
    root = (node.get_addon('osfstorage')).get_root()
    root_children = [child for child in root.children if child.is_file]
    mails.queue_mail(to_addr=user.username,
                     mail=mails.WELCOME_OSF4M,
                     send_at=timezone.now() + settings.WELCOME_OSF4M_WAIT_TIME,
                     user=user,
                     conference=conference.name,
                     fullname=user.fullname,
                     fid=root_children[0]._id if len(root_children) else None)
Пример #3
0
def queue_no_addon_email(user):
    """Queue an email for user who has not connected an addon after
    `settings.NO_ADDON_WAIT_TIME` months of signing up for the OSF.
    """
    mails.queue_mail(
        to_addr=user.username,
        mail=mails.NO_ADDON,
        send_at=datetime.utcnow() + settings.NO_ADDON_WAIT_TIME,
        user=user,
        fullname=user.fullname
    )
Пример #4
0
def queue_osf4m_welcome_email(user, conference, node):
    """Queue an email once a new user is created for OSF for Meetings"""
    root = (node.get_addon('osfstorage')).get_root()
    fid = root.children[0]._id if root.children else None
    mails.queue_mail(to_addr=user.username,
                     mail=mails.WELCOME_OSF4M,
                     send_at=datetime.utcnow() +
                     settings.WELCOME_OSF4M_WAIT_TIME,
                     user=user,
                     conference=conference.name,
                     fullname=user.fullname,
                     fid=fid)
Пример #5
0
def queue_osf4m_welcome_email(user, conference, node):
    """Queue an email once a new user is created for OSF for Meetings"""
    root = (node.get_addon('osfstorage')).get_root()
    fid = root.children[0]._id if root.children else None
    mails.queue_mail(
        to_addr=user.username,
        mail=mails.WELCOME_OSF4M,
        send_at=datetime.utcnow() + settings.WELCOME_OSF4M_WAIT_TIME,
        user=user,
        conference=conference.name,
        fullname=user.fullname,
        fid=fid
    )
Пример #6
0
def main(dry_run=True):
    for user in find_inactive_users_with_no_inactivity_email_sent_or_queued():
        if dry_run:
            logger.warn('Dry run mode')
        logger.warn('Email of type no_login queued to {0}'.format(user.username))
        if not dry_run:
            with TokuTransaction():
                mails.queue_mail(
                    to_addr=user.username,
                    mail=mails.NO_LOGIN,
                    send_at=datetime.utcnow(),
                    user=user,
                    fullname=user.fullname,
                )
Пример #7
0
def main(dry_run=True):
    for user in find_inactive_users_with_no_inactivity_email_sent_or_queued():
        if dry_run:
            logger.warn('Dry run mode')
        logger.warn('Email of type no_login queued to {0}'.format(user.username))
        if not dry_run:
            with transaction.atomic():
                mails.queue_mail(
                    to_addr=user.username,
                    mail=mails.NO_LOGIN,
                    send_at=timezone.now(),
                    user=user,
                    fullname=user.fullname,
                )
 def test_find_inactive_users_with_no_inactivity_email_sent_or_queued(self, mock_mail):
     user_active = UserFactory(fullname='Spot')
     user_inactive = UserFactory(fullname='Nucha')
     user_already_received_mail = UserFactory(fullname='Pep')
     user_active.date_last_login = timezone.now() - timedelta(seconds=6)
     user_inactive.date_last_login = timezone.now() - timedelta(weeks=6)
     user_already_received_mail.date_last_login = timezone.now() - timedelta(weeks=6)
     user_active.save()
     user_inactive.save()
     user_already_received_mail.save()
     mails.queue_mail(to_addr=user_already_received_mail.username,
                      send_at=timezone.now(),
                      user=user_already_received_mail,
                      mail=mails.NO_LOGIN)
     users = find_inactive_users_with_no_inactivity_email_sent_or_queued()
     assert_equal(len(users), 1)
Пример #9
0
def queue_first_public_project_email(user, node, meeting_creation):
    """Queue and email after user has made their first
    non-OSF4M project public.
    """
    if not meeting_creation:
        sent_mail = mails.QueuedMail.find(
            Q('user', 'eq', user) & Q('sent_at', 'ne', None)
            & Q('email_type', 'eq', mails.NEW_PUBLIC_PROJECT_TYPE))
        if not sent_mail.count():
            mails.queue_mail(to_addr=user.username,
                             mail=mails.NEW_PUBLIC_PROJECT,
                             send_at=timezone.now() +
                             settings.NEW_PUBLIC_PROJECT_WAIT_TIME,
                             user=user,
                             nid=node._id,
                             fullname=user.fullname,
                             project_title=node.title)
Пример #10
0
 def queue_mail(self, mail_type=mails.NO_ADDON, user=None, send_at=None):
     return mails.queue_mail(
         to_addr=user.username if user else self.user.username,
         mail=mail_type,
         send_at=send_at or datetime.utcnow(),
         user=user if user else self.user,
         fullname=user.fullname if user else self.user.fullname,
     )
Пример #11
0
 def queue_mail(self, mail_type=mails.NO_ADDON, user=None, send_at=None):
     return mails.queue_mail(
         to_addr=user.username if user else self.user.username,
         mail=mail_type,
         send_at=send_at or datetime.utcnow(),
         user=user if user else self.user,
         fullname=user.fullname if user else self.user.fullname,
     )
Пример #12
0
def queue_first_public_project_email(user, node, meeting_creation):
    """Queue and email after user has made their first
    non-OSF4M project public.
    """
    if not meeting_creation:
        sent_mail = mails.QueuedMail.find(Q('user', 'eq', user) & Q('sent_at', 'ne', None) &
                                          Q('email_type', 'eq', mails.NEW_PUBLIC_PROJECT_TYPE))
        if not sent_mail.count():
            mails.queue_mail(
                to_addr=user.username,
                mail=mails.NEW_PUBLIC_PROJECT,
                send_at=datetime.utcnow() + settings.NEW_PUBLIC_PROJECT_WAIT_TIME,
                user=user,
                nid=node._id,
                fullname=user.fullname,
                project_title=node.title
            )
Пример #13
0
 def test_find_inactive_users_with_no_inactivity_email_sent_or_queued(
         self, mock_mail):
     user_active = UserFactory(fullname='Spot')
     user_inactive = UserFactory(fullname='Nucha')
     user_already_received_mail = UserFactory(fullname='Pep')
     user_active.date_last_login = timezone.now() - timedelta(seconds=6)
     user_inactive.date_last_login = timezone.now() - timedelta(weeks=6)
     user_already_received_mail.date_last_login = timezone.now(
     ) - timedelta(weeks=6)
     user_active.save()
     user_inactive.save()
     user_already_received_mail.save()
     mails.queue_mail(to_addr=user_already_received_mail.username,
                      send_at=timezone.now(),
                      user=user_already_received_mail,
                      mail=mails.NO_LOGIN)
     users = find_inactive_users_with_no_inactivity_email_sent_or_queued()
     assert_equal(len(users), 1)
Пример #14
0
 def queue_mail(self, mail, user=None, send_at=None, **kwargs):
     mail = mails.queue_mail(
         to_addr=user.username if user else self.user.username,
         send_at=send_at or timezone.now(),
         user=user or self.user,
         mail=mail,
         fullname=user.fullname if user else self.user.username,
         **kwargs)
     return mail
Пример #15
0
 def queue_mail(self, mail, user=None, send_at=None, **kwargs):
     mail = mails.queue_mail(
         to_addr=user.username if user else self.user.username,
         send_at=send_at or datetime.utcnow(),
         user=user or self.user,
         mail=mail,
         fullname=user.fullname if user else self.user.username,
         **kwargs
     )
     return mail