Ticket #2332: is_loggedin.patch
File is_loggedin.patch, 8.8 KB (added by , 18 years ago) |
---|
-
django/contrib/admin/templates/admin/base.html
20 20 <div id="branding"> 21 21 {% block branding %}{% endblock %} 22 22 </div> 23 {% if not user.is_anonymous%}{% if user.is_staff %}23 {% if user.is_loggedin %}{% if user.is_staff %} 24 24 <div id="user-tools">{% trans 'Welcome,' %} <strong>{% if user.first_name %}{{ user.first_name|escape }}{% else %}{{ user.username }}{% endif %}</strong>. {% block userlinks %}<a href="doc/">{% trans 'Documentation' %}</a> / <a href="password_change/">{% trans 'Change password' %}</a> / <a href="logout/">{% trans 'Log out' %}</a>{% endblock %}</div> 25 25 {% endif %}{% endif %} 26 26 {% block nav-global %}{% endblock %} -
django/contrib/admin/views/decorators.py
46 46 member, displaying the login page if necessary. 47 47 """ 48 48 def _checklogin(request, *args, **kwargs): 49 if not request.user.is_anonymous() and request.user.is_staff:49 if request.user.is_loggedin() and request.user.is_staff: 50 50 # The user is valid. Continue to the admin page. 51 51 if request.POST.has_key('post_data'): 52 52 # User must have re-authenticated through a different window -
django/contrib/auth/decorators.py
17 17 return _checklogin 18 18 return _dec 19 19 20 login_required = user_passes_test(lambda u: not u.is_anonymous())20 login_required = user_passes_test(lambda u: u.is_loggedin()) 21 21 login_required.__doc__ = ( 22 22 """ 23 23 Decorator for views that checks that the user is logged in, redirecting -
django/contrib/auth/models.py
123 123 return "/users/%s/" % self.username 124 124 125 125 def is_anonymous(self): 126 "Always returns False. This is a way of comparing User objects to anonymous users." 127 return False 126 " Depreciated: use .is_loggedin() instead. " 127 return not self.is_loggedin() 128 129 def is_loggedin(self): 130 """ 131 Always return True. This is a way of comparing User objects to 132 anonymous users. 133 """ 134 return True 128 135 129 136 def get_full_name(self): 130 137 "Returns the first_name plus the last_name, with a space in between." … … 291 298 def get_and_delete_messages(self): 292 299 return [] 293 300 294 def is_ anonymous(self):295 return True301 def is_loggedin(self): 302 return False -
django/contrib/comments/templates/comments/form.html
2 2 {% if display_form %} 3 3 <form {% if photos_optional or photos_required %}enctype="multipart/form-data" {% endif %}action="/comments/post/" method="post"> 4 4 5 {% if user.is_anonymous%}5 {% if not user.is_loggedin %} 6 6 <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> 7 7 {% else %} 8 8 <p>{% trans "Username:" %} <strong>{{ user.username }}</strong> (<a href="/accounts/logout/">{% trans "Log out" %}</a>)</p> -
django/contrib/comments/templatetags/comments.py
114 114 comment_list = get_list_function(**kwargs).order_by(self.ordering + 'submit_date').select_related() 115 115 116 116 if not self.free: 117 if context.has_key('user') and not context['user'].is_anonymous():117 if context.has_key('user') and context['user'].is_loggedin(): 118 118 user_id = context['user'].id 119 119 context['user_can_moderate_comments'] = Comment.objects.user_is_moderator(context['user']) 120 120 else: -
django/contrib/comments/views/comments.py
63 63 validator_list=get_validator_list(8), 64 64 ), 65 65 ]) 66 if not user.is_anonymous():66 if user.is_loggedin(): 67 67 self["username"].is_required = False 68 68 self["username"].validator_list = [] 69 69 self["password"].is_required = False -
django/contrib/comments/views/karma.py
15 15 rating = {'up': 1, 'down': -1}.get(vote, False) 16 16 if not rating: 17 17 raise Http404, "Invalid vote" 18 if request.user.is_anonymous():18 if not request.user.is_loggedin(): 19 19 raise Http404, _("Anonymous users cannot vote") 20 20 try: 21 21 comment = Comment.objects.get(pk=comment_id) -
django/contrib/flatpages/views.py
22 22 f = get_object_or_404(FlatPage, url__exact=url, sites__id__exact=settings.SITE_ID) 23 23 # If registration is required for accessing this page, and the user isn't 24 24 # logged in, redirect to the login page. 25 if f.registration_required and request.user.is_anonymous():25 if f.registration_required and not request.user.is_loggedin(): 26 26 from django.contrib.auth.views import redirect_to_login 27 27 return redirect_to_login(request.path) 28 28 if f.template_name: -
django/views/generic/create_update.py
20 20 the form wrapper for the object 21 21 """ 22 22 if extra_context is None: extra_context = {} 23 if login_required and request.user.is_anonymous():23 if login_required and not request.user.is_loggedin(): 24 24 return redirect_to_login(request.path) 25 25 26 26 manipulator = model.AddManipulator(follow=follow) … … 39 39 # No errors -- this means we can save the data! 40 40 new_object = manipulator.save(new_data) 41 41 42 if not request.user.is_anonymous():42 if request.user.is_loggedin(): 43 43 request.user.message_set.create(message="The %s was created successfully." % model._meta.verbose_name) 44 44 45 45 # Redirect to the new object: first by trying post_save_redirect, … … 86 86 the original object being edited 87 87 """ 88 88 if extra_context is None: extra_context = {} 89 if login_required and request.user.is_anonymous():89 if login_required and not request.user.is_loggedin(): 90 90 return redirect_to_login(request.path) 91 91 92 92 # Look up the object to be edited … … 113 113 if not errors: 114 114 object = manipulator.save(new_data) 115 115 116 if not request.user.is_anonymous():116 if request.user.is_loggedin(): 117 117 request.user.message_set.create(message="The %s was updated successfully." % model._meta.verbose_name) 118 118 119 119 # Do a post-after-redirect so that reload works, etc. … … 162 162 the original object being deleted 163 163 """ 164 164 if extra_context is None: extra_context = {} 165 if login_required and request.user.is_anonymous():165 if login_required and not request.user.is_loggedin(): 166 166 return redirect_to_login(request.path) 167 167 168 168 # Look up the object to be edited … … 180 180 181 181 if request.method == 'POST': 182 182 object.delete() 183 if not request.user.is_anonymous():183 if request.user.is_loggedin(): 184 184 request.user.message_set.create(message="The %s was deleted." % model._meta.verbose_name) 185 185 return HttpResponseRedirect(post_delete_redirect) 186 186 else: