Python django.conf.settings.MANAGERS Examples

The following are 5 code examples of django.conf.settings.MANAGERS(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.conf.settings , or try the search function .
Example #1
Source File: __init__.py    From GTDWeb with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #2
Source File: models.py    From DCRM with GNU Affero General Public License v3.0 5 votes vote down vote up
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) 
Example #3
Source File: views.py    From conf_site with MIT License 5 votes vote down vote up
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},
    ) 
Example #4
Source File: feedback.py    From prospector with GNU General Public License v3.0 5 votes vote down vote up
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') 
Example #5
Source File: __init__.py    From luscan-devel with GNU General Public License v2.0 5 votes vote down vote up
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)