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


Python settings.MANAGERS属性代码示例

本文整理汇总了Python中django.conf.settings.MANAGERS属性的典型用法代码示例。如果您正苦于以下问题:Python settings.MANAGERS属性的具体用法?Python settings.MANAGERS怎么用?Python settings.MANAGERS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在django.conf.settings的用法示例。


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

示例1: mail_managers

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import MANAGERS [as 别名]
def mail_managers(subject, message, fail_silently=False, connection=None,
                  html_message=None):
    """Sends a message to the managers, as defined by the MANAGERS setting."""
    if not settings.MANAGERS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.MANAGERS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:13,代码来源:__init__.py

示例2: on_comment_posted

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import MANAGERS [as 别名]
def on_comment_posted(sender, comment, request, **kwargs):
    """
    Send email notification of a new comment to site staff when email notifications have been requested.
    """
    # This code is copied from django_comments.moderation.
    # That code doesn't offer a RequestContext, which makes it really
    # hard to generate proper URL's with FQDN in the email
    #
    # Instead of implementing this feature in the moderator class, the signal is used instead
    # so the notification feature works regardless of a manual moderator.register() call in the project.
    if not appsettings.FLUENT_COMMENTS_USE_EMAIL_NOTIFICATION:
        return

    recipient_list = [manager_tuple[1] for manager_tuple in settings.MANAGERS]
    site = get_current_site(request)
    content_object = comment.content_object

    if comment.is_removed:
        subject = u'[{0}] Spam comment on "{1}"'.format(site.name, content_object)
    elif not comment.is_public:
        subject = u'[{0}] Moderated comment on "{1}"'.format(site.name, content_object)
    else:
        subject = u'[{0}] New comment posted on "{1}"'.format(site.name, content_object)

    context = {
        'site': site,
        'comment': comment,
        'content_object': content_object
    }

    if django.VERSION >= (1, 8):
        message = render_to_string("comments/comment_notification_email.txt", context, request=request)
    else:
        message = render_to_string("comments/comment_notification_email.txt", context, context_instance=RequestContext(request))
    send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=True) 
开发者ID:82Flex,项目名称:DCRM,代码行数:37,代码来源:models.py

示例3: sponsor_apply

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import MANAGERS [as 别名]
def sponsor_apply(request):
    if request.method == "POST":
        form = SponsorApplicationForm(request.POST, user=request.user)
        if form.is_valid():
            sponsor = form.save()
            # Send email notification of successful application.
            for manager in settings.MANAGERS:
                send_email(
                    [manager[1]],
                    "sponsor_signup",
                    context={"sponsor": sponsor},
                )
            if sponsor.sponsor_benefits.all():
                # Redirect user to sponsor_detail to give extra information.
                messages.success(
                    request,
                    _(
                        "Thank you for your sponsorship "
                        "application. Please update your "
                        "benefit details below."
                    ),
                )
                return redirect("sponsor_detail", pk=sponsor.pk)
            else:
                messages.success(
                    request,
                    _("Thank you for your sponsorship " "application."),
                )
                return redirect("dashboard")
    else:
        form = SponsorApplicationForm(user=request.user)

    return render(
        request=request,
        template_name="symposion/sponsorship/apply.html",
        context={"form": form},
    ) 
开发者ID:pydata,项目名称:conf_site,代码行数:39,代码来源:views.py

示例4: post

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import MANAGERS [as 别名]
def post(self, request, *args, **kwargs):
        form = FeedbackForm(request.POST)

        if not form.is_valid():
            respdata = {
                'status': 'fail',
                'errors': form.errors
            }
            responsecls = HttpResponseBadRequest

        else:
            respdata = {
                'status': 'ok',
                'errors': {}
            }
            responsecls = HttpResponse
            recipients = [self.format_email(name, email)
                          for name, email in settings.MANAGERS]

            message = '{0}\n-- \nSent from: {1}\n'.format(
                form.cleaned_data['message'],
                request.META['HTTP_REFERER'])

            send_mail(subject='[OSP feedback] ' + form.cleaned_data['subject'],
                      message=message,
                      from_email=self.format_email(
                          form.cleaned_data['name'],
                          form.cleaned_data['email']),
                      recipient_list=recipients)

        return responsecls(json.dumps(respdata),
                           content_type='application/json') 
开发者ID:chaoss,项目名称:prospector,代码行数:34,代码来源:feedback.py


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