本文整理汇总了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)