本文整理匯總了Python中django.conf.settings.LOGOUT_URL屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.LOGOUT_URL屬性的具體用法?Python settings.LOGOUT_URL怎麽用?Python settings.LOGOUT_URL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類django.conf.settings
的用法示例。
在下文中一共展示了settings.LOGOUT_URL屬性的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: media
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_URL [as 別名]
def media(request):
"""
Add context things that we need
"""
# A/B testing: half of instructors and TAs see a different search box
instr_ta = is_instr_ta(request.user.username)
instr_ta_ab = instr_ta and request.user.is_authenticated and request.user.id % 2 == 0
# GRAD_DATE(TIME?)_FORMAT for the grad/ra/ta apps
return {'GRAD_DATE_FORMAT': settings.GRAD_DATE_FORMAT,
'GRAD_DATETIME_FORMAT': settings.GRAD_DATETIME_FORMAT,
'LOGOUT_URL': settings.LOGOUT_URL,
'LOGIN_URL': settings.LOGIN_URL,
'STATIC_URL': settings.STATIC_URL,
'is_instr_ta': instr_ta,
'instr_ta_ab': instr_ta_ab,
'request_path': request.path,
'CourSys': product_name(request),
'help_email': help_email(request),
}
示例2: test_change_password_sets_logout_reason
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_URL [as 別名]
def test_change_password_sets_logout_reason(self):
api.keystone.user_update_own_password(IsA(http.HttpRequest),
'oldpwd',
'normalpwd').AndReturn(None)
self.mox.ReplayAll()
formData = {'method': 'PasswordForm',
'current_password': 'oldpwd',
'new_password': 'normalpwd',
'confirm_password': 'normalpwd'}
res = self.client.post(INDEX_URL, formData, follow=False)
self.assertRedirectsNoFollow(res, settings.LOGOUT_URL)
self.assertIn('logout_reason', res.cookies)
self.assertEqual(res.cookies['logout_reason'].value,
"Password changed. Please log in again to continue.")
scheme, netloc, path, query, fragment = urlsplit(res.url)
redirect_response = res.client.get(path, http.QueryDict(query))
self.assertRedirectsNoFollow(redirect_response, settings.LOGIN_URL)
示例3: handle
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_URL [as 別名]
def handle(self, request, data):
user_is_editable = api.keystone.keystone_can_edit_user()
if user_is_editable:
try:
api.keystone.user_update_own_password(request,
data['current_password'],
data['new_password'])
response = http.HttpResponseRedirect(settings.LOGOUT_URL)
msg = _("Password changed. Please log in again to continue.")
utils.add_logout_reason(request, response, msg)
return response
except Exception:
exceptions.handle(request,
_('Unable to change password.'))
return False
else:
messages.error(request, _('Changing password is not supported.'))
return False
示例4: get_redirect_url
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_URL [as 別名]
def get_redirect_url(self):
ret = self.request.GET.get(
self.redirect_field_name, settings.LOGOUT_URL)
return ret
示例5: _configure_settings
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_URL [as 別名]
def _configure_settings(self):
# Setup the configuration as described in the documentation
bossoidc.settings.configure_oidc('https://auth',
'client_id',
'https://localhost')
# Copy the values into the active settings
settings.LOGIN_URL = bossoidc.settings.LOGIN_URL
settings.LOGOUT_URL = bossoidc.settings.LOGOUT_URL
settings.OIDC_PROVIDERS = bossoidc.settings.OIDC_PROVIDERS
settings.OIDC_AUTH = bossoidc.settings.OIDC_AUTH
示例6: get_context_data
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_URL [as 別名]
def get_context_data(self, **kwargs):
context = super(IndexView, self).get_context_data(**kwargs)
context.update({
"logout_url": settings.LOGOUT_URL,
"login_url": settings.LOGIN_URL,
})
if self.request.user.is_authenticated:
context.update({
"user_attrs": sorted([(field.name, getattr(self.request.user, field.name)) for field in self.request.user._meta.get_fields() if field.concrete]),
"known_sp_ids": [sp for sp in ServiceProvider.objects.filter(active=True)],
})
return context
示例7: get_context_data
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_URL [as 別名]
def get_context_data(self, **kwargs):
context = super(IndexView, self).get_context_data(**kwargs)
context.update({
"logout_url": settings.LOGOUT_URL,
"login_url": settings.LOGIN_URL,
})
if self.request.user.is_authenticated:
context.update({
"user_attrs": sorted([(field.name, getattr(self.request.user, field.name)) for field in self.request.user._meta.get_fields() if field.concrete]),
})
return context
# TODO fix this in IdP side?
示例8: test_logout_message
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_URL [as 別名]
def test_logout_message(self):
login = self.client.login(username=self.user.username, password="123456", request=MockRequest(self.user))
self.assertEqual(login, True)
response = self.client.get(dj_settings.LOGOUT_URL, follow=True)
self.assertIn("You are now logged out. Have a nice day!", str(response.content))
示例9: test_anonymous
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_URL [as 別名]
def test_anonymous(self):
response = self.client.get(settings.LOGOUT_URL, follow=True)
url = urls.reverse("download-email-view", kwargs={"email": self.email.eid,
"inbox": self.email.inbox.inbox,
"domain": self.email.inbox.domain.domain})
response = self.client.get(url)
self.assertRedirects(response,
"{}?next={}".format(settings.LOGIN_URL, url),
fetch_redirect_response=False)
示例10: logout_with_message
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_URL [as 別名]
def logout_with_message(request, msg):
"""Send HttpResponseRedirect to LOGOUT_URL.
`msg` is a message displayed on the login page after the logout, to explain
the logout reason.
"""
logout(request)
response = http.HttpResponseRedirect(
'%s?next=%s' % (settings.LOGOUT_URL, request.path))
add_logout_reason(request, response, msg)
return response
示例11: process_response
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_URL [as 別名]
def process_response(self, request, response):
"""Convert HttpResponseRedirect to HttpResponse if request is via ajax
to allow ajax request to redirect url
"""
if request.is_ajax() and hasattr(request, 'horizon'):
queued_msgs = request.horizon['async_messages']
if type(response) == http.HttpResponseRedirect:
# Drop our messages back into the session as per usual so they
# don't disappear during the redirect. Not that we explicitly
# use django's messages methods here.
for tag, message, extra_tags in queued_msgs:
getattr(django_messages, tag)(request, message, extra_tags)
# if response['location'].startswith(settings.LOGOUT_URL):
# redirect_response = http.HttpResponse(status=401)
# # This header is used for handling the logout in JS
# redirect_response['logout'] = True
# if self.logout_reason is not None:
# utils.add_logout_reason(
# request, redirect_response, self.logout_reason)
# else:
redirect_response = http.HttpResponse()
# Use a set while checking if we want a cookie's attributes
# copied
cookie_keys = set(('max_age', 'expires', 'path', 'domain',
'secure', 'httponly', 'logout_reason'))
# Copy cookies from HttpResponseRedirect towards HttpResponse
for cookie_name, cookie in six.iteritems(response.cookies):
cookie_kwargs = dict((
(key, value) for key, value in six.iteritems(cookie)
if key in cookie_keys and value
))
redirect_response.set_cookie(
cookie_name, cookie.value, **cookie_kwargs)
redirect_response['X-Horizon-Location'] = response['location']
upload_url_key = 'X-File-Upload-URL'
if upload_url_key in response:
self.copy_headers(response, redirect_response,
(upload_url_key, 'X-Auth-Token'))
return redirect_response
if queued_msgs:
# TODO(gabriel): When we have an async connection to the
# client (e.g. websockets) this should be pushed to the
# socket queue rather than being sent via a header.
# The header method has notable drawbacks (length limits,
# etc.) and is not meant as a long-term solution.
response['X-Horizon-Messages'] = json.dumps(queued_msgs)
return response
示例12: process_response
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_URL [as 別名]
def process_response(self, request, response):
"""Convert HttpResponseRedirect to HttpResponse if request is via ajax
to allow ajax request to redirect url
"""
if request.is_ajax() and hasattr(request, 'horizon'):
queued_msgs = request.horizon['async_messages']
if type(response) == http.HttpResponseRedirect:
# Drop our messages back into the session as per usual so they
# don't disappear during the redirect. Not that we explicitly
# use django's messages methods here.
for tag, message, extra_tags in queued_msgs:
getattr(django_messages, tag)(request, message, extra_tags)
if response['location'].startswith(settings.LOGOUT_URL):
redirect_response = http.HttpResponse(status=401)
# This header is used for handling the logout in JS
redirect_response['logout'] = True
if self.logout_reason is not None:
utils.add_logout_reason(
request, redirect_response, self.logout_reason)
else:
redirect_response = http.HttpResponse()
# Use a set while checking if we want a cookie's attributes
# copied
cookie_keys = set(('max_age', 'expires', 'path', 'domain',
'secure', 'httponly', 'logout_reason'))
# Copy cookies from HttpResponseRedirect towards HttpResponse
for cookie_name, cookie in six.iteritems(response.cookies):
cookie_kwargs = dict((
(key, value) for key, value in six.iteritems(cookie)
if key in cookie_keys and value
))
redirect_response.set_cookie(
cookie_name, cookie.value, **cookie_kwargs)
redirect_response['X-Horizon-Location'] = response['location']
return redirect_response
if queued_msgs:
# TODO(gabriel): When we have an async connection to the
# client (e.g. websockets) this should be pushed to the
# socket queue rather than being sent via a header.
# The header method has notable drawbacks (length limits,
# etc.) and is not meant as a long-term solution.
response['X-Horizon-Messages'] = json.dumps(queued_msgs)
return response