Python django.conf.settings 模块,WAGTAIL_SITE_NAME 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用django.conf.settings.WAGTAIL_SITE_NAME

项目:moore    作者:UTNkar    | 项目源码 | 文件源码
def send_confirmation_email(sender, email, user=None, **kwargs):
    user = user or sender  # TODO: use user.send_email
    if user is not None:
        context = {
            'email': email,
            'domain': settings.BASE_URL,
            'site_name': settings.WAGTAIL_SITE_NAME,
            'token': user.get_confirmation_key(email),
            'new_user': user.get_confirmed_emails() == []
        }

        subject = loader.render_to_string(
            'members/email_change_subject.txt', context)
        # Email subject *must not* contain newlines
        subject = ''.join(subject.splitlines())
        body = loader.render_to_string('members/email_change_email.html',
                                       context)

        email_message = EmailMultiAlternatives(subject, body, None, [email])
        email_message.send()
项目:a4-meinberlin    作者:liqd    | 项目源码 | 文件源码
def get_form_kwargs(self):
        kwargs = super().get_form_kwargs()
        kwargs['user'] = self.request.user

        if hasattr(self, 'organisation'):
            sender_name = self.organisation.name
        else:
            sender_name = settings.WAGTAIL_SITE_NAME

        kwargs['initial'] = {
            'sender_name': sender_name,
            'sender': settings.CONTACT_EMAIL
        }
        return kwargs
项目:wagtail-linkchecker    作者:takeflight    | 项目源码 | 文件源码
def handle(self, *args, **kwargs):
        site = Site.objects.filter(is_default_site=True).first()
        pages = site.root_page.get_descendants(inclusive=True).live().public()
        broken_links = broken_link_scan(site)

        messages = []
        for page in pages:
            revision = PageRevision.objects.filter(page=page).latest('created_at')
            page_broken_links = []
            for link in broken_links:
                if link.page == page:
                    page_broken_links.append(link)
            email_message = render_to_string(
                'wagtaillinkchecker/emails/broken_links.html', {
                    'page_broken_links': page_broken_links,
                    'user': revision.user,
                    'page': page,
                    'base_url': site.root_url,
                    'site_name': settings.WAGTAIL_SITE_NAME,
                    })
            email = EmailMessage(
                'Broken links on page "%s"' % (page.title),
                email_message,
                settings.DEFAULT_FROM_EMAIL,
                [revision.user.email])
            email.content_subtype = 'html'
            messages.append(email)

        connection = mail.get_connection()
        connection.open()
        connection.send_messages(messages)
        connection.close()
项目:wagtail-relevancy    作者:takeflight    | 项目源码 | 文件源码
def handle(self, *args, **kwargs):
        reminders = Reminder.objects.filter(sent=False, due_to_be_sent_at__lt=timezone.now(), page__live=True)
        try:
            sent_from = settings.REMINDER_FROM_EMAIL
        except AttributeError:
            sent_from = settings.DEFAULT_FROM_EMAIL

        try:
            reminder_template = settings.REMINDER_TEMPLATE
        except AttributeError:
            reminder_template = 'wagtailrelevancy/reminder.html'

        for reminder in reminders:
            subject = _('Reminder: Check to see if the content on the page, {0}, is up to date!'.format(reminder.page.title))
            message = render_to_string(
                reminder_template, {
                    'user': reminder.user,
                    'page': reminder.page,
                    'site_name': settings.WAGTAIL_SITE_NAME,
                }
            )
            email = EmailMessage(
                subject,
                message,
                sent_from,
                [reminder.user.email])
            email.content_subtype = 'html'
            email.send()

            reminder.sent = True
            reminder.page_reviewed = False
            reminder.save()

        # Purge old sent reminders after 14 days, unless set to false in settings
        try:
            purge = settings.PURGE_REMINDERS
        except AttributeError:
            purge = True
            default_purge_days = 14

        if purge:
            fourteen_days_after_now = timezone.now() + timedelta(days=default_purge_days)
            stale_reminders = Reminder.objects.filter(sent=True, due_to_be_sent_at__gt=fourteen_days_after_now)
            if stale_reminders.exists():
                print(_('Purging {0} stale reminders'.format(stale_reminders.count())))
                stale_reminders.delete()
            else:
                print(_('There were no stale reminders to purge.'))