当前位置: 首页>>代码示例>>Python>>正文


Python send_remo_mail.delay函数代码示例

本文整理汇总了Python中remo.base.tasks.send_remo_mail.delay函数的典型用法代码示例。如果您正苦于以下问题:Python delay函数的具体用法?Python delay怎么用?Python delay使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了delay函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: extend_voting_period

def extend_voting_period():
    """Extend voting period by EXTEND_VOTING_PERIOD if there is no
    majority decision.

    """

    # avoid circular dependencies
    from remo.voting.models import Poll

    tomorrow = get_date(days=1)
    review_count = User.objects.filter(groups__name='Review').count()

    query_start = make_aware(datetime.combine(tomorrow, datetime.min.time()), pytz.UTC)
    query_end = make_aware(datetime.combine(tomorrow, datetime.max.time()), pytz.UTC)
    polls = Poll.objects.filter(end__range=[query_start, query_end])

    for poll in polls:
        if not poll.is_extended:
            budget_poll = poll.radio_polls.get(question='Budget Approval')
            majority = reduce(or_, map(lambda x: x.votes > review_count / 2,
                                       budget_poll.answers.all()))
            if not majority:
                poll.end += timedelta(seconds=EXTEND_VOTING_PERIOD)
                poll.save()
                subject = '[Urgent] Voting extended for {0}'.format(poll.name)
                recipients = (User.objects.filter(groups=poll.valid_groups)
                              .exclude(pk__in=poll.users_voted.all())
                              .values_list('id', flat=True))
                ctx_data = {'poll': poll}
                template = 'emails/voting_vote_reminder.jinja'
                send_remo_mail.delay(subject=subject,
                                     recipients_list=recipients,
                                     email_template=template,
                                     data=ctx_data)
开发者ID:MichaelKohler,项目名称:remo,代码行数:34,代码来源:tasks.py

示例2: extend_voting_period

def extend_voting_period():
    """Extend voting period by EXTEND_VOTING_PERIOD if there is no
    majority decision.

    """

    # avoid circular dependencies
    from remo.voting.models import Poll

    tomorrow = get_date(days=1)
    council_count = User.objects.filter(groups__name='Council').count()

    polls = Poll.objects.filter(end__year=tomorrow.year,
                                end__month=tomorrow.month,
                                end__day=tomorrow.day,
                                automated_poll=True)

    for poll in polls:
        if not poll.is_extended:
            budget_poll = poll.radio_polls.get(question='Budget Approval')
            majority = reduce(or_, map(lambda x: x.votes > council_count/2,
                                       budget_poll.answers.all()))
            if not majority:
                poll.end += timedelta(seconds=EXTEND_VOTING_PERIOD)
                poll.save()
                subject = '[Urgent] Voting extended for {0}'.format(poll.name)
                recipients = (User.objects.filter(groups=poll.valid_groups)
                              .exclude(pk__in=poll.users_voted.all())
                              .values_list('id', flat=True))
                ctx_data = {'poll': poll}
                template = 'emails/voting_vote_reminder.txt'
                send_remo_mail.delay(subject=subject,
                                     recipients_list=recipients,
                                     email_template=template,
                                     data=ctx_data)
开发者ID:bobsilverberg,项目名称:remo,代码行数:35,代码来源:tasks.py

示例3: email_commenters_on_add_ng_report_comment

def email_commenters_on_add_ng_report_comment(sender, instance, **kwargs):
    """Email a user when a comment is added to a continuous report instance."""
    subject = '[Report] User {0} commented on {1}'
    email_template = 'emails/user_notification_on_add_ng_report_comment.jinja'
    report = instance.report

    # Send an email to all users commented so far on the report except fom
    # the user who made the comment. Dedup the list with unique IDs.
    commenters = set(NGReportComment.objects.filter(report=report)
                     .exclude(user=instance.user)
                     .values_list('user', flat=True))

    # Add the owner of the report in the list
    if report.user.id not in commenters:
        commenters.add(report.user.id)

    for user_id in commenters:
        user = User.objects.get(pk=user_id)
        if user.userprofile.receive_email_on_add_comment and user != instance.user:
            ctx_data = {'report': report, 'user': user,
                        'commenter': instance.user,
                        'comment': instance.comment,
                        'created_on': instance.created_on}
            subject = subject.format(instance.user.get_full_name(), report)
            send_remo_mail.delay(subject=subject, recipients_list=[user_id],
                                 email_template=email_template, data=ctx_data)
开发者ID:Josespaul,项目名称:remo,代码行数:26,代码来源:models.py

示例4: email_commenters_on_add_poll_comment

def email_commenters_on_add_poll_comment(sender, instance, **kwargs):
    """Email a user when a comment is added to a poll."""
    poll = instance.poll
    if poll.comments_allowed:
        subject = '[Voting] User {0} commented on {1}'
        email_template = 'emails/user_notification_on_add_poll_comment.txt'

        # Send an email to all users commented so far on the poll except from
        # the user who made the comment. Dedup the list with unique IDs.
        commenters = set(PollComment.objects.filter(poll=poll)
                         .exclude(user=instance.user)
                         .values_list('user', flat=True))

        # Add the creator of the poll in the list
        if poll.created_by.id not in commenters:
            commenters.add(poll.created_by.id)

        for user_id in commenters:
            user = User.objects.get(pk=user_id)
            if (user.userprofile.receive_email_on_add_voting_comment and
                    user != instance.user):
                ctx_data = {'poll': poll, 'user': user,
                            'commenter': instance.user,
                            'comment': instance.comment,
                            'created_on': instance.created_on}
                subject = subject.format(instance.user.get_full_name(), poll)
                send_remo_mail.delay(subject=subject,
                                     recipients_list=[user_id],
                                     email_template=email_template,
                                     data=ctx_data)
开发者ID:v1ka5,项目名称:remo,代码行数:30,代码来源:models.py

示例5: email_mentor_notification

def email_mentor_notification(sender, instance, raw, **kwargs):
    """Notify mentor when his/her mentee changes mentor on his/her profile."""
    if not instance.mentor:
        return

    user_profile = get_object_or_none(UserProfile, user=instance.user)

    if not user_profile or not user_profile.mentor or raw:
        return

    if user_profile.mentor != instance.mentor:
        subject = '[Reps] Mentor reassignment.'
        email_template = 'emails/mentor_change_notification.txt'
        mentors_recipients = [user_profile.mentor.id, instance.mentor.id]
        rep_recipient = [instance.user.id]
        ctx_data = {'rep_user': instance.user,
                    'new_mentor': instance.mentor}
        send_remo_mail.delay(recipients_list=mentors_recipients,
                             subject=subject,
                             email_template=email_template,
                             data=ctx_data,
                             headers={'Reply-To': instance.user.email})
        send_remo_mail.delay(recipients_list=rep_recipient,
                             subject=subject,
                             email_template=email_template,
                             data=ctx_data,
                             headers={'Reply-To': instance.mentor.email})
        statsd.incr('profiles.change_mentor')
开发者ID:pemmasanikrishna,项目名称:remo,代码行数:28,代码来源:models.py

示例6: notify_event_owners_to_input_metrics

def notify_event_owners_to_input_metrics():
    """Send an email to event creators.

    After an event has finished event creators are notified
    that they should input the actual metrics for the event.
    """
    start = datetime.combine(get_date(days=-1), datetime.min.time())
    end = datetime.combine(get_date(days=-1), datetime.max.time())
    events = Event.objects.filter(end__range=[start, end],
                                  has_new_metrics=True,
                                  eventmetricoutcome__outcome__isnull=True)
    events = events.distinct()

    event_model = ContentType.objects.get_for_model(Event)
    for event in events:
        # Before sending an email check that an action item already exists.
        # If it does, then we have already sent this email.

        action_item = ActionItem.objects.filter(content_type=event_model, object_id=event.id)
        if not action_item.exists():
            subject = '[Reminder] Please add the actual metrics for event {0}'.format(event.name)
            template = 'email/event_creator_notification_to_input_metrics.jinja'
            data = {'event': event}
            send_remo_mail.delay(subject=subject, email_template=template,
                                 recipients_list=[event.owner.id], data=data)
            ActionItem.create(instance=event)
开发者ID:kn17,项目名称:remo,代码行数:26,代码来源:tasks.py

示例7: poll_vote_reminder

def poll_vote_reminder():
    """Send an email reminder every 8 hours to
    remind valid users to cast their vote.

    """
    polls = Poll.objects.filter(start__lte=now(), end__gt=now())

    for poll in polls:
        last_notification = (poll.last_nofication if poll.last_notification
                             else poll.created_on)

        time_diff = (time.mktime(now().timetuple()) -
                     time.mktime(last_notification.timetuple()))
        if time_diff > NOTIFICATION_INTERVAL:
            valid_users = User.objects.filter(groups=poll.valid_groups)
            recipients = (valid_users.exclude(pk__in=poll.users_voted.all())
                                     .values_list('id', flat=True))
            subject = ('[Reminder][Voting] Please cast your vote '
                       'for "%s" now!' % poll.name)
            template_reminder = 'emails/voting_vote_reminder.txt'
            ctx_data = {'poll': poll}
            send_remo_mail.delay(subject=subject, recipients_list=recipients,
                                 email_template=template_reminder,
                                 data=ctx_data)
            Poll.objects.filter(pk=poll.pk).update(last_notification=now())
开发者ID:Binzzzz,项目名称:remo,代码行数:25,代码来源:cron.py

示例8: send_email

 def send_email(self, request, subject=''):
     """Send an email to user's mentor"""
     mentor = request.user.userprofile.mentor
     from_email = '%s <%s>' % (request.user.get_full_name(),
                               request.user.email)
     send_remo_mail.delay(sender=from_email,
                          recipients_list=[mentor.id],
                          subject=subject,
                          message=self.cleaned_data['body'])
开发者ID:seocam,项目名称:remo,代码行数:9,代码来源:forms.py

示例9: send_email

 def send_email(self, request, subject='', message=None,
                template=None, data=None):
     """Send an email to user's mentor"""
     mentor = request.user.userprofile.mentor
     from_email = '%s <%s>' % (request.user.get_full_name(),
                               request.user.email)
     send_remo_mail.delay(sender=from_email,
                          recipients_list=[mentor.id],
                          subject=subject,
                          message=message,
                          email_template=template,
                          data=data)
开发者ID:TheTeraByte,项目名称:remo,代码行数:12,代码来源:forms.py

示例10: automated_poll_discussion_email

def automated_poll_discussion_email(sender, instance, created, raw, **kwargs):
    """Send email reminders when a vote starts/ends."""
    if instance.automated_poll and created:
        template = 'emails/review_budget_notify_council.txt'
        subject = ('[Bug %d] Budget request discussion' %
                   instance.bug.bug_id)
        data = {'bug': instance.bug,
                'BUGZILLA_URL': BUGZILLA_URL}
        send_remo_mail.delay(
            subject=subject, email_template=template,
            recipients_list=[settings.REPS_COUNCIL_ALIAS],
            data=data,
            headers={'Reply-To': settings.REPS_COUNCIL_ALIAS})
开发者ID:Binzzzz,项目名称:remo,代码行数:13,代码来源:models.py

示例11: automated_poll_discussion_email

def automated_poll_discussion_email(sender, instance, created, raw, **kwargs):
    """Send email reminders when a vote starts/ends."""
    if instance.automated_poll and created:
        template = 'emails/review_budget_notify_review_team.jinja'
        subject = u'Discuss [Bug {id}] - {summary}'.format(id=instance.bug.bug_id,
                                                           summary=unicode(instance.bug.summary))
        data = {'bug': instance.bug,
                'BUGZILLA_URL': get_bugzilla_url(instance.bug),
                'poll': instance}
        send_remo_mail.delay(
            subject=subject, email_template=template,
            recipients_list=[settings.REPS_REVIEW_ALIAS],
            data=data)
开发者ID:MichaelKohler,项目名称:remo,代码行数:13,代码来源:models.py

示例12: email_event_owner_on_add_comment

def email_event_owner_on_add_comment(sender, instance, **kwargs):
    """Email event owner when a comment is added to event."""
    subject = '[Event] User %s commented on event "%s"'
    email_template = 'email/owner_notification_on_add_comment.jinja'
    event = instance.event
    owner = instance.event.owner
    event_url = reverse('events_view_event', kwargs={'slug': event.slug})
    ctx_data = {'event': event, 'owner': owner, 'commenter': instance.user,
                'comment': instance.comment, 'event_url': event_url}
    if owner.userprofile.receive_email_on_add_event_comment:
        subject = subject % (instance.user.get_full_name(), instance.event.name)
        send_remo_mail.delay(subject=subject, recipients_list=[owner.id],
                             email_template=email_template, data=ctx_data)
开发者ID:MichaelKohler,项目名称:remo,代码行数:13,代码来源:models.py

示例13: email_mentor_notification

def email_mentor_notification(sender, instance, raw, **kwargs):
    """Notify mentor when his/her mentee changes mentor on his/her profile."""
    if UserProfile.objects.filter(user=instance.user).exists() and not raw:
        user_profile = UserProfile.objects.get(user=instance.user)
        if user_profile.mentor and user_profile.mentor != instance.mentor:
            subject = '[Reps] Change of mentor.'
            email_template = 'emails/mentor_change_notification.txt'
            recipients = [user_profile.mentor.id, user_profile.user.id,
                          instance.mentor.id]
            ctx_data = {'rep_user': instance.user,
                        'new_mentor': instance.mentor}
            send_remo_mail.delay(recipients_list=recipients, subject=subject,
                                 email_template=email_template, data=ctx_data)
            statsd.incr('profiles.change_mentor')
开发者ID:bobsilverberg,项目名称:remo,代码行数:14,代码来源:models.py

示例14: send_mail

    def send_mail(self, request):
        """Send mail to recipients list."""
        recipients_list = []
        for field in self.fields:
            if (isinstance(self.fields[field], forms.BooleanField) and
                    self.cleaned_data[field]):
                recipients_list.append(long(field))

        if recipients_list:
            from_email = '%s <%s>' % (request.user.get_full_name(),
                                      request.user.email)
            send_remo_mail.delay(sender=from_email,
                                 recipients_list=recipients_list,
                                 subject=self.cleaned_data['subject'],
                                 message=self.cleaned_data['body'])
            messages.success(request, 'Email sent successfully.')
        else:
            messages.error(request, ('Email not sent. Please select at '
                                     'least one recipient.'))
开发者ID:MichaelKohler,项目名称:remo,代码行数:19,代码来源:forms.py

示例15: send_report_notification

def send_report_notification(reps, weeks):
    """Send notification to inactive reps."""
    rep_subject = '[Reminder] Please share your recent activities'
    rep_mail_body = 'emails/reps_ng_report_notification.txt'
    mentor_subject = ('[Report] Mentee without report for the last %d weeks'
                      % weeks)
    mentor_mail_body = 'emails/mentor_ng_report_notification.txt'

    for rep in reps:
        ctx_data = {'mentor': rep.userprofile.mentor,
                    'user': rep,
                    'SITE_URL': settings.SITE_URL,
                    'weeks': weeks}

        rep_message = render_to_string(rep_mail_body, ctx_data)
        mentor_message = render_to_string(mentor_mail_body, ctx_data)
        send_remo_mail.delay(rep_subject, [rep.email], message=rep_message)
        send_remo_mail.delay(mentor_subject, [rep.userprofile.mentor.email],
                             message=mentor_message)
开发者ID:seocam,项目名称:remo,代码行数:19,代码来源:utils.py


注:本文中的remo.base.tasks.send_remo_mail.delay函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。