全部
常见问题
产品动态
精选推荐

Python settings.SITE_NAME属性代码示例

管理 管理 编辑 删除

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

在下文中一共展示了settings.SITE_NAME属性的15个代码示例。

示例1: notify_chat_on_group_creation

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import SITE_NAME [as 别名]
def notify_chat_on_group_creation(sender, instance, created, **kwargs):
    """Send notifications to admin chat"""
    if not created:
        return
    group = instance
    webhook_url = getattr(settings, 'ADMIN_CHAT_WEBHOOK', None)

    if webhook_url is None:
        return

    group_url = frontend_urls.group_preview_url(group)

    message_data = {
        'text': f':tada: A new group has been created on **{settings.SITE_NAME}**! [Visit {group.name}]({group_url})',
    }

    response = requests.post(webhook_url, data=json.dumps(message_data), headers={'Content-Type': 'application/json'})
    response.raise_for_status() 

示例2: get

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import SITE_NAME [as 别名]
def get(self, request, *args, **kwargs):
        challenge = os.urandom(32)
        request.session['webauthn_attest'] = webauthn_encode(challenge)
        data = webauthn.WebAuthnMakeCredentialOptions(
            challenge=challenge,
            rp_id=settings.WEBAUTHN_RP_ID,
            rp_name=settings.SITE_NAME,
            user_id=request.profile.webauthn_id,
            username=request.user.username,
            display_name=request.user.username,
            user_verification='discouraged',
            icon_url=gravatar(request.user.email),
            attestation='none',
        ).registration_dict
        data['excludeCredentials'] = [{
            'type': 'public-key',
            'id': {'_bytes': credential.cred_id},
        } for credential in request.profile.webauthn_credentials.all()]
        return JsonResponse(data, encoder=WebAuthnJSONEncoder) 

示例3: test_it_adds_team_member

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import SITE_NAME [as 别名]
def test_it_adds_team_member(self):
        self.client.login(username="alice@example.org", password="password")

        form = {"invite_team_member": "1", "email": "frank@example.org"}
        r = self.client.post(self.url, form)
        self.assertEqual(r.status_code, 200)

        members = self.project.member_set.all()
        self.assertEqual(members.count(), 2)

        member = Member.objects.get(
            project=self.project, user__email="frank@example.org"
        )

        # The new user should not have their own project
        self.assertFalse(member.user.project_set.exists())

        # And an email should have been sent
        subj = (
            "You have been invited to join"
            " Alice's Project on %s" % settings.SITE_NAME
        )
        self.assertHTMLEqual(mail.outbox[0].subject, subj) 

示例4: test_it_sends_set_password_link

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import SITE_NAME [as 别名]
def test_it_sends_set_password_link(self):
        self.client.login(username="alice@example.org", password="password")

        form = {"set_password": "1"}
        r = self.client.post("/accounts/profile/", form)
        assert r.status_code == 302

        # profile.token should be set now
        self.profile.refresh_from_db()
        token = self.profile.token
        self.assertTrue(len(token) > 10)

        # And an email should have been sent
        self.assertEqual(len(mail.outbox), 1)
        expected_subject = "Set password on %s" % settings.SITE_NAME
        self.assertEqual(mail.outbox[0].subject, expected_subject) 

示例5: test_it_sends_change_email_link

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import SITE_NAME [as 别名]
def test_it_sends_change_email_link(self):
        self.client.login(username="alice@example.org", password="password")

        form = {"change_email": "1"}
        r = self.client.post("/accounts/profile/", form)
        assert r.status_code == 302

        # profile.token should be set now
        self.profile.refresh_from_db()
        token = self.profile.token
        self.assertTrue(len(token) > 10)

        # And an email should have been sent
        self.assertEqual(len(mail.outbox), 1)
        expected_subject = "Change email address on %s" % settings.SITE_NAME
        self.assertEqual(mail.outbox[0].subject, expected_subject) 

示例6: notify

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import SITE_NAME [as 别名]
def notify(self, check):
        profile = Profile.objects.for_user(self.channel.project.owner)
        if not profile.authorize_sms():
            profile.send_sms_limit_notice("SMS")
            return "Monthly SMS limit exceeded"

        url = self.URL % settings.TWILIO_ACCOUNT
        auth = (settings.TWILIO_ACCOUNT, settings.TWILIO_AUTH)
        text = tmpl("sms_message.html", check=check, site_name=settings.SITE_NAME)

        data = {
            "From": settings.TWILIO_FROM,
            "To": self.channel.sms_number,
            "Body": text,
        }

        return self.post(url, data=data, auth=auth) 

示例7: manifest

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import SITE_NAME [as 别名]
def manifest(request):
    data = {
        "name": settings.SITE_NAME,
        "short_name": settings.SITE_NAME,
        "icons": [
            {
                "src": static("imgs/megmelon-icon-white.png"),
                "sizes": "128x128",
                "type": "image/png"
            }
        ],
        "theme_color": "#ffffff",
        "background_color": "#ffffff",
        "display": "browser",
        "start_url": reverse("user-home"),
    }

    return JsonResponse(data) 

示例8: setup_event_webhook

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import SITE_NAME [as 别名]
def setup_event_webhook(self, s):
        response = s.get('https://api.sparkpost.com/api/v1/webhooks')
        self.log_response(response)
        if not status.is_success(response.status_code):
            self.errors.append(
                'Failed to get existing event webhooks.' +
                'Check if your subaccount API key has permission to Read/Write Event Webhooks.'
            )

        webhooks = response.json()
        event_webhook_data = {
            "name": settings.SITE_NAME[:23],  # obey sparkpost name length limit
            "target": settings.HOSTNAME + "/api/webhooks/email_event/",
            "auth_type": "basic",
            "auth_credentials": {
                "username": "xxx",
                "password": settings.SPARKPOST_WEBHOOK_SECRET
            },
            "events": settings.SPARKPOST_EMAIL_EVENTS,
        }
        existing_event_webhook = None
        for w in webhooks['results']:
            if w['target'] == event_webhook_data['target']:
                existing_event_webhook = w

        if existing_event_webhook is None:
            print(
                'WARNING: creating a new event webhook for {}. '
                'Please check on sparkpost.com if there are unused ones.'.format(event_webhook_data['target'])
            )
            response = s.post('https://api.sparkpost.com/api/v1/webhooks', json=event_webhook_data)
            self.log_response(response)
            if not status.is_success(response.status_code):
                self.errors.append('Failed to create new event webhook')
        else:
            response = s.put(
                'https://api.sparkpost.com/api/v1/webhooks/' + existing_event_webhook['id'], json=event_webhook_data
            )
            self.log_response(response)
            if not status.is_success(response.status_code):
                self.errors.append('Failed to update existing event webhook') 

示例9: test_invite_with_different_invited_by_language

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import SITE_NAME [as 别名]
def test_invite_with_different_invited_by_language(self):
        self.member.language = 'fr'
        self.member.save()
        self.client.force_login(self.member)
        response = self.client.post(base_url, {'email': 'please@join.com', 'group': self.group.id})
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        expected = f'[{settings.SITE_NAME}] Invitation de joinde {self.group.name}'
        self.assertEqual(mail.outbox[-1].subject, expected) 

示例10: get_serializer_context

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import SITE_NAME [as 别名]
def get_serializer_context(self, *args, **kwargs):
        context = super(OrganizationRoles, self).get_serializer_context(
            *args, **kwargs)
        context['organization'] = self.get_organization()
        context['domain'] = get_current_site(self.request).domain
        context['sitename'] = settings.SITE_NAME
        return context 

示例11: site_name

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import SITE_NAME [as 别名]
def site_name(request):
    return {'SITE_NAME': settings.SITE_NAME,
            'SITE_LONG_NAME': settings.SITE_LONG_NAME,
            'SITE_ADMIN_EMAIL': settings.SITE_ADMIN_EMAIL} 

示例12: render_qr_code

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import SITE_NAME [as 别名]
def render_qr_code(cls, username, key):
        totp = pyotp.TOTP(key)
        uri = totp.provisioning_uri(username, settings.SITE_NAME)

        qr = qrcode.QRCode(box_size=1)
        qr.add_data(uri)
        qr.make(fit=True)

        image = qr.make_image(fill_color='black', back_color='white')
        buf = BytesIO()
        image.save(buf, format='PNG')
        return 'data:image/png;base64,' + base64.b64encode(buf.getvalue()).decode('ascii') 

示例13: handle

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import SITE_NAME [as 别名]
def handle(self, *args, **options):
        Site.objects.update_or_create(
            id=settings.SITE_ID,
            defaults={
                'domain': settings.HOST_NAME,
                'name': settings.SITE_NAME
            }
        ) 

示例14: test_it_sends_link

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import SITE_NAME [as 别名]
def test_it_sends_link(self):
        form = {"identity": "alice@example.org"}

        r = self.client.post("/accounts/login/", form)
        self.assertRedirects(r, "/accounts/login_link_sent/")

        # And email should have been sent
        self.assertEqual(len(mail.outbox), 1)
        subject = "Log in to %s" % settings.SITE_NAME
        self.assertEqual(mail.outbox[0].subject, subject) 

示例15: test_it_sends_link

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import SITE_NAME [as 别名]
def test_it_sends_link(self):
        form = {"identity": "alice@example.org"}

        r = self.client.post("/accounts/signup/", form)
        self.assertContains(r, "Account created")
        self.assertIn("auto-login", r.cookies)

        # An user should have been created
        user = User.objects.get()

        # And email sent
        self.assertEqual(len(mail.outbox), 1)
        subject = "Log in to %s" % settings.SITE_NAME
        self.assertEqual(mail.outbox[0].subject, subject)

        # A project should have been created
        project = Project.objects.get()
        self.assertEqual(project.owner, user)
        self.assertEqual(project.badge_key, user.username)

        # And check should be associated with the new user
        check = Check.objects.get()
        self.assertEqual(check.name, "My First Check")
        self.assertEqual(check.project, project)

        # A channel should have been created
        channel = Channel.objects.get()
        self.assertEqual(channel.project, project) 


请登录后查看

CRMEB-慕白寒窗雪 最后编辑于2023-03-24 09:51:45

快捷回复
回复
回复
回复({{post_count}}) {{!is_user ? '我的回复' :'全部回复'}}
排序 默认正序 回复倒序 点赞倒序

{{item.user_info.nickname ? item.user_info.nickname : item.user_name}} LV.{{ item.user_info.bbs_level }}

作者 管理员 企业

{{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest == 1? '取消推荐': '推荐'}}
{{item.is_suggest == 1? '取消推荐': '推荐'}}
沙发 板凳 地板 {{item.floor}}#
{{item.user_info.title || '暂无简介'}}
附件

{{itemf.name}}

{{item.created_at}}  {{item.ip_address}}
{{item.like_count}}
{{item.showReply ? '取消回复' : '回复'}}
删除
回复
回复

{{itemc.user_info.nickname}}

{{itemc.user_name}}

回复 {{itemc.comment_user_info.nickname}}

附件

{{itemf.name}}

{{itemc.created_at}}
{{itemc.like_count}}
{{itemc.showReply ? '取消回复' : '回复'}}
删除
回复
回复
查看更多
1220
{{like_count}}
{{collect_count}}
添加回复 ({{post_count}})

相关推荐

快速安全登录

使用微信扫码登录
{{item.label}} 加精
{{item.label}} {{item.label}} 板块推荐 常见问题 产品动态 精选推荐 首页头条 首页动态 首页推荐
取 消 确 定
回复
回复
问题:
问题自动获取的帖子内容,不准确时需要手动修改. [获取答案]
答案:
提交
bug 需求 取 消 确 定

微信登录/注册

切换手机号登录

{{ bind_phone ? '绑定手机' : '手机登录'}}

{{codeText}}
切换微信登录/注册
暂不绑定
CRMEB客服

CRMEB咨询热线 咨询热线

400-8888-794

微信扫码咨询

CRMEB开源商城下载 源码下载 CRMEB帮助文档 帮助文档
返回顶部 返回顶部
CRMEB客服