Ticket #3185: 3185_3.diff
File 3185_3.diff, 6.6 KB (added by , 18 years ago) |
---|
-
django/contrib/comments/templatetags/comments.py
5 5 from django.template import loader 6 6 from django.core.exceptions import ObjectDoesNotExist 7 7 from django.contrib.contenttypes.models import ContentType 8 from django.contrib.auth import LOGOUT_URL 8 9 import re 9 10 10 11 register = template.Library() … … 64 65 if self.rating_options: 65 66 context['rating_range'], context['rating_choices'] = Comment.objects.get_rating_options(self.rating_options) 66 67 context['hash'] = Comment.objects.get_security_hash(context['options'], context['photo_options'], context['rating_options'], context['target']) 68 context['logout_url'] = LOGOUT_URL 67 69 default_form = loader.get_template(COMMENT_FORM) 68 70 output = default_form.render(context) 69 71 context.pop() -
django/contrib/comments/templates/comments/form.html
3 3 <form {% if photos_optional or photos_required %}enctype="multipart/form-data" {% endif %}action="/comments/post/" method="post"> 4 4 5 5 {% if user.is_authenticated %} 6 <p>{% trans "Username:" %} <strong>{{ user.username }}</strong> (<a href=" /accounts/logout/">{% trans "Log out" %}</a>)</p>6 <p>{% trans "Username:" %} <strong>{{ user.username }}</strong> (<a href="{{ logout_url }}">{% trans "Log out" %}</a>)</p> 7 7 {% else %} 8 8 <p><label for="id_username">{% trans "Username:" %}</label> <input type="text" name="username" id="id_username" /><br />{% trans "Password:" %} <input type="password" name="password" id="id_password" /> (<a href="/accounts/password_reset/">{% trans "Forgotten your password?" %}</a>)</p> 9 9 {% endif %} -
django/contrib/auth/views.py
6 6 from django.contrib.sites.models import Site 7 7 from django.http import HttpResponseRedirect 8 8 from django.contrib.auth.decorators import login_required 9 from django.contrib.auth import LOGIN_URL, REDIRECT_FIELD_NAME9 from django.contrib.auth import LOGIN_URL, ACCOUNT_URL, REDIRECT_FIELD_NAME 10 10 11 11 def login(request, template_name='registration/login.html'): 12 12 "Displays the login form and handles the login action." … … 17 17 if not errors: 18 18 # Light security check -- make sure redirect_to isn't garbage. 19 19 if not redirect_to or '://' in redirect_to or ' ' in redirect_to: 20 redirect_to = '/accounts/profile/'20 redirect_to = ACCOUNT_URL 21 21 from django.contrib.auth import login 22 22 login(request, manipulator.get_user()) 23 23 request.session.delete_test_cookie() -
django/contrib/auth/__init__.py
1 from django.conf import settings 1 2 from django.core.exceptions import ImproperlyConfigured 2 3 3 4 SESSION_KEY = '_auth_user_id' … … 2 3 BACKEND_SESSION_KEY = '_auth_user_backend' 3 LOGIN_URL = '/accounts/login/' 4 LOGIN_URL = getattr(settings, 'LOGIN_URL', '/accounts/login/') 5 LOGOUT_URL = getattr(settings, 'LOGOUT_URL', '/accounts/logout/') 6 ACCOUNT_URL = getattr(settings, 'ACCOUNT_URL', '/accounts/profile/') 4 7 REDIRECT_FIELD_NAME = 'next' -
docs/settings.txt
166 166 'news.Story': lambda o: "/stories/%s/%s/" % (o.pub_year, o.slug), 167 167 } 168 168 169 ACCOUNT_URL 170 ------------- 171 172 Default: ``'/accounts/profile/'`` 173 174 The URL where requests are redirected after login when the ``"contrib.auth.login"`` view 175 gets no ``next`` parameter. 176 i.e.: When the `@login_required`_ decorator is called 177 169 178 ADMIN_FOR 170 179 --------- 171 180 … … 533 542 you'll have to remember to wrap the languages in the *real* ``gettext()`` in 534 543 any code that uses ``LANGUAGES`` at runtime. 535 544 545 LOGIN_URL 546 ------------- 547 548 Default: ``'/accounts/login/'`` 549 550 The URL where requests are redirected for login, specially when using the 551 `@login_required`_ decorator. 552 553 LOGOUT_URL 554 ------------- 555 556 Default: ``'/accounts/logout/'`` 557 558 LOGIN_URL counterpart. 559 536 560 MANAGERS 537 561 -------- 538 562 … … 972 996 973 997 It boils down to this: Use exactly one of either ``configure()`` or 974 998 ``DJANGO_SETTINGS_MODULE``. Not both, and not neither. 999 1000 .. _@login_required: ../authentication/#the-login-required-decorator -
docs/authentication.txt
377 377 378 378 ``login_required`` does the following: 379 379 380 * If the user isn't logged in, redirect to ``/accounts/login/``, passing 381 the current absolute URL in the query string as ``next``. For example: 380 * If the user isn't logged in, redirect to ``"settings.LOGIN_URL"`` 381 (``"/accounts/login/"`` by default), passing the current absolute URL 382 in the query string as ``next``. For example: 382 383 ``/accounts/login/?next=/polls/3/``. 383 384 * If the user is logged in, execute the view normally. The view code is 384 385 free to assume the user is logged in. 385 386 386 Note that you'll need to map the appropriate Django view to `` /accounts/login/``.387 To do this, add the following line to your URLconf::387 Note that you'll need to map the appropriate Django view to ``"settings.LOGIN_URL"``. 388 For example, using the defaults, add the following line to your URLconf:: 388 389 389 390 (r'^accounts/login/$', 'django.contrib.auth.views.login'), 390 391 … … 395 396 396 397 * If called via ``POST``, it tries to log the user in. If login is 397 398 successful, the view redirects to the URL specified in ``next``. If 398 ``next`` isn't provided, it redirects to `` /accounts/profile/`` (which is399 currently hard-coded). If login isn't successful, it redisplays the login399 ``next`` isn't provided, it redirects to ``"settings.ACCOUNT_URL"`` which 400 defaults to ``/accounts/profile/``. If login isn't successful, it redisplays the login 400 401 form. 401 402 402 403 It's your responsibility to provide the login form in a template called