本文整理匯總了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)
示例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)
示例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},
)
示例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')