user is_anonymous and is_authenticated as properties (#49189)
This commit is contained in:
parent
9aa59cef6c
commit
24ee0ceb68
|
@ -313,7 +313,7 @@ admin.site.register(models.Notification, NotificationAdmin)
|
|||
|
||||
|
||||
def login(request, *args, **kwargs):
|
||||
if request.user.is_authenticated() and not (request.user.is_active and request.user.is_staff):
|
||||
if request.user.is_authenticated and not (request.user.is_active and request.user.is_staff):
|
||||
raise PermissionDenied()
|
||||
return auth_views.login(request, *args, **kwargs)
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ def modified_data(sender, instance, created, raw, using, **kwargs):
|
|||
extra = middleware.get_extra()
|
||||
if not do_log:
|
||||
return
|
||||
if hasattr(extra['user'], 'is_anonymous') and extra['user'].is_anonymous():
|
||||
if hasattr(extra['user'], 'is_anonymous') and extra['user'].is_anonymous:
|
||||
extra['user'] = '-'
|
||||
if extra['user'] == middleware.NO_USER:
|
||||
return
|
||||
|
@ -62,7 +62,7 @@ def list_m2m_changed_handler(sender, instance, action, reverse, model, pk_set, u
|
|||
return
|
||||
action.replace('_', '-')
|
||||
extra = middleware.get_extra()
|
||||
if hasattr(extra['user'], 'is_anonymous') and extra['user'].is_anonymous():
|
||||
if hasattr(extra['user'], 'is_anonymous') and extra['user'].is_anonymous:
|
||||
extra['user'] = '-'
|
||||
if extra['user'] == middleware.NO_USER:
|
||||
return
|
||||
|
|
|
@ -408,7 +408,7 @@ def help(request, pagename='index.html'):
|
|||
def contact(request, template='docbow/contact.html',
|
||||
form_class=AnonymousContactForm):
|
||||
user = request.user
|
||||
if user.is_authenticated():
|
||||
if user.is_authenticated:
|
||||
template = 'docbow/contact_user.html'
|
||||
form_class = ContactForm
|
||||
contacts = User.objects.filter(groups__name__in=settings.CONTACT_GROUPS)
|
||||
|
@ -425,7 +425,7 @@ def contact(request, template='docbow/contact.html',
|
|||
to = [ contact.email for contact in contacts ]
|
||||
subject = settings.CONTACT_SUBJECT_PREFIX + cleaned_data['subject']
|
||||
message = cleaned_data['message']
|
||||
if user.is_authenticated():
|
||||
if user.is_authenticated:
|
||||
reply_to = user.email
|
||||
body = _('Message from %(name)s <%(email)s>') % { 'name':
|
||||
user.get_full_name(), 'email': reply_to } + '\n\n%s' % message
|
||||
|
|
Loading…
Reference in New Issue