M src/wiki/core/permissions.py => src/wiki/core/permissions.py +9 -9
@@ 23,11 23,11 @@ def can_read(article, user):
return False
# Check access for other users...
- if user.is_anonymous() and not settings.ANONYMOUS:
+ if user.is_anonymous and not settings.ANONYMOUS:
return False
elif article.other_read:
return True
- elif user.is_anonymous():
+ elif user.is_anonymous:
return False
if user == article.owner:
return True
@@ 44,11 44,11 @@ def can_write(article, user):
if callable(settings.CAN_WRITE):
return settings.CAN_WRITE(article, user)
# Check access for other users...
- if user.is_anonymous() and not settings.ANONYMOUS_WRITE:
+ if user.is_anonymous and not settings.ANONYMOUS_WRITE:
return False
elif article.other_write:
return True
- elif user.is_anonymous():
+ elif user.is_anonymous:
return False
if user == article.owner:
return True
@@ 64,7 64,7 @@ def can_write(article, user):
def can_assign(article, user):
if callable(settings.CAN_ASSIGN):
return settings.CAN_ASSIGN(article, user)
- return not user.is_anonymous() and user.has_perm('wiki.assign')
+ return not user.is_anonymous and user.has_perm('wiki.assign')
def can_assign_owner(article, user):
@@ 77,7 77,7 @@ def can_change_permissions(article, user):
if callable(settings.CAN_CHANGE_PERMISSIONS):
return settings.CAN_CHANGE_PERMISSIONS(article, user)
return (
- not user.is_anonymous() and (
+ not user.is_anonymous and (
article.owner == user or
user.has_perm('wiki.assign')
)
@@ 87,16 87,16 @@ def can_change_permissions(article, user):
def can_delete(article, user):
if callable(settings.CAN_DELETE):
return settings.CAN_DELETE(article, user)
- return not user.is_anonymous() and article.can_write(user)
+ return not user.is_anonymous and article.can_write(user)
def can_moderate(article, user):
if callable(settings.CAN_MODERATE):
return settings.CAN_MODERATE(article, user)
- return not user.is_anonymous() and user.has_perm('wiki.moderate')
+ return not user.is_anonymous and user.has_perm('wiki.moderate')
def can_admin(article, user):
if callable(settings.CAN_ADMIN):
return settings.CAN_ADMIN(article, user)
- return not user.is_anonymous() and user.has_perm('wiki.admin')
+ return not user.is_anonymous and user.has_perm('wiki.admin')
M src/wiki/decorators.py => src/wiki/decorators.py +2 -2
@@ 12,7 12,7 @@ from wiki.core.exceptions import NoRootURL
def response_forbidden(request, article, urlpath):
- if request.user.is_anonymous():
+ if request.user.is_anonymous:
qs = request.META.get('QUERY_STRING', '')
if qs:
qs = urlquote('?' + qs)
@@ 143,7 143,7 @@ def get_article(func=None, can_read=True, can_write=False, # noqa
return response_forbidden(request, article, urlpath)
if can_create and not (
- request.user.is_authenticated() or settings.ANONYMOUS_CREATE):
+ request.user.is_authenticated or settings.ANONYMOUS_CREATE):
return response_forbidden(request, article, urlpath)
if can_delete and not article.can_delete(request.user):
M src/wiki/forms.py => src/wiki/forms.py +3 -3
@@ 117,7 117,7 @@ class SpamProtectionMixin(object):
request = self.request
user = None
ip_address = None
- if request.user.is_authenticated():
+ if request.user.is_authenticated:
user = request.user
else:
ip_address = request.META.get('REMOTE_ADDR', None)
@@ 151,7 151,7 @@ class SpamProtectionMixin(object):
return
from_time = timezone.now() - timedelta(minutes=settings.REVISIONS_MINUTES_LOOKBACK)
- if request.user.is_authenticated():
+ if request.user.is_authenticated:
per_minute = settings.REVISIONS_PER_MINUTES
else:
per_minute = settings.REVISIONS_PER_MINUTES_ANONYMOUS
@@ 164,7 164,7 @@ class SpamProtectionMixin(object):
)
from_time = timezone.now() - timedelta(minutes=60)
- if request.user.is_authenticated():
+ if request.user.is_authenticated:
per_hour = settings.REVISIONS_PER_MINUTES
else:
per_hour = settings.REVISIONS_PER_MINUTES_ANONYMOUS
M src/wiki/managers.py => src/wiki/managers.py +4 -4
@@ 11,7 11,7 @@ class ArticleQuerySet(QuerySet):
are included"""
if user.has_perm('wiki.moderator'):
return self
- if user.is_anonymous():
+ if user.is_anonymous:
q = self.filter(other_read=True)
else:
q = self.filter(Q(other_read=True) |
@@ 25,7 25,7 @@ class ArticleQuerySet(QuerySet):
are included"""
if user.has_perm('wiki.moderator'):
return self
- if user.is_anonymous():
+ if user.is_anonymous:
q = self.filter(other_write=True)
else:
q = self.filter(Q(other_write=True) |
@@ 57,7 57,7 @@ class ArticleFkQuerySetMixin(object):
are included"""
if user.has_perm('wiki.moderate'):
return self
- if user.is_anonymous():
+ if user.is_anonymous:
q = self.filter(article__other_read=True)
else:
# https://github.com/django-wiki/django-wiki/issues/67
@@ 72,7 72,7 @@ class ArticleFkQuerySetMixin(object):
are included"""
if user.has_perm('wiki.moderate'):
return self
- if user.is_anonymous():
+ if user.is_anonymous:
q = self.filter(article__other_write=True)
else:
# https://github.com/django-wiki/django-wiki/issues/67
M src/wiki/models/article.py => src/wiki/models/article.py +1 -1
@@ 316,7 316,7 @@ class BaseRevisionMixin(models.Model):
)
def set_from_request(self, request):
- if request.user.is_authenticated():
+ if request.user.is_authenticated:
self.user = request.user
if settings.LOG_IPS_USERS:
self.ip_address = request.META.get('REMOTE_ADDR', None)
M src/wiki/models/urlpath.py => src/wiki/models/urlpath.py +1 -1
@@ 314,7 314,7 @@ class URLPath(MPTTModel):
"""
user = None
ip_address = None
- if not request.user.is_anonymous():
+ if not request.user.is_anonymous:
user = request.user
if settings.LOG_IPS_USERS:
ip_address = request.META.get('REMOTE_ADDR', None)
M src/wiki/plugins/attachments/models.py => src/wiki/plugins/attachments/models.py +1 -1
@@ 40,7 40,7 @@ class Attachment(ReusablePlugin):
null=True)
def can_write(self, user):
- if not settings.ANONYMOUS and (not user or user.is_anonymous()):
+ if not settings.ANONYMOUS and (not user or user.is_anonymous):
return False
return ReusablePlugin.can_write(self, user)
M src/wiki/plugins/attachments/views.py => src/wiki/plugins/attachments/views.py +3 -3
@@ 41,7 41,7 @@ class AttachmentView(ArticleMixin, FormView):
def form_valid(self, form):
- if (self.request.user.is_anonymous() and not settings.ANONYMOUS or
+ if (self.request.user.is_anonymous and not settings.ANONYMOUS or
not self.article.can_write(self.request.user) or
self.article.current_revision.locked):
return response_forbidden(self.request, self.article, self.urlpath)
@@ 81,7 81,7 @@ class AttachmentView(ArticleMixin, FormView):
current_revision__deleted=True)
kwargs['search_form'] = forms.SearchForm()
kwargs['selected_tab'] = 'attachments'
- kwargs['anonymous_disallowed'] = self.request.user.is_anonymous() and not settings.ANONYMOUS
+ kwargs['anonymous_disallowed'] = self.request.user.is_anonymous and not settings.ANONYMOUS
return super().get_context_data(**kwargs)
@@ 118,7 118,7 @@ class AttachmentReplaceView(ArticleMixin, FormView):
@method_decorator(get_article(can_write=True, not_locked=True))
def dispatch(self, request, article, attachment_id, *args, **kwargs):
- if request.user.is_anonymous() and not settings.ANONYMOUS:
+ if request.user.is_anonymous and not settings.ANONYMOUS:
return response_forbidden(request, article, kwargs.get('urlpath', None))
if article.can_moderate(request.user):
self.attachment = get_object_or_404(
M src/wiki/plugins/haystack/__init__.py => src/wiki/plugins/haystack/__init__.py +2 -2
@@ 21,7 21,7 @@ class SearchViewHaystack(haystack_views.SearchView):
def dispatch(self, request, *args, **kwargs):
# Do not allow anonymous users to search if they cannot read content
- if request.user.is_anonymous() and not settings.ANONYMOUS:
+ if request.user.is_anonymous and not settings.ANONYMOUS:
return redirect(settings.LOGIN_URL)
return super().dispatch(request, *args, **kwargs)
@@ 30,7 30,7 @@ class SearchViewHaystack(haystack_views.SearchView):
are included"""
if user.has_perm('wiki.moderator'):
return self.results
- if user.is_anonymous():
+ if user.is_anonymous:
q = self.results.filter(other_read='True')
return q
else:
M src/wiki/plugins/haystack/views.py => src/wiki/plugins/haystack/views.py +1 -1
@@ 12,7 12,7 @@ class HaystackSearchView(SearchView):
def get_queryset(self):
qs = SearchQuerySet().all()
- if self.request.user.is_authenticated():
+ if self.request.user.is_authenticated:
if not permissions.can_moderate(
models.URLPath.root().article,
self.request.user):
M src/wiki/plugins/images/models.py => src/wiki/plugins/images/models.py +1 -1
@@ 36,7 36,7 @@ class Image(RevisionPlugin):
# anything! :D
def can_write(self, user):
- if not settings.ANONYMOUS and (not user or user.is_anonymous()):
+ if not settings.ANONYMOUS and (not user or user.is_anonymous):
return False
return RevisionPlugin.can_write(self, user)
M src/wiki/plugins/images/templatetags/wiki_images_tags.py => src/wiki/plugins/images/templatetags/wiki_images_tags.py +1 -1
@@ 13,6 13,6 @@ def images_for_article(article):
@register.filter
def images_can_add(article, user):
- if not settings.ANONYMOUS and (not user or user.is_anonymous()):
+ if not settings.ANONYMOUS and (not user or user.is_anonymous):
return False
return article.can_write(user)
M src/wiki/views/accounts.py => src/wiki/views/accounts.py +2 -2
@@ 33,7 33,7 @@ class Signup(CreateView):
def dispatch(self, request, *args, **kwargs):
# Let logged in super users continue
- if not request.user.is_anonymous() and not request.user.is_superuser:
+ if not request.user.is_anonymous and not request.user.is_superuser:
return redirect('wiki:root')
# If account handling is disabled, don't go here
if not settings.ACCOUNT_HANDLING:
@@ 77,7 77,7 @@ class Login(FormView):
template_name = "wiki/accounts/login.html"
def dispatch(self, request, *args, **kwargs):
- if not request.user.is_anonymous():
+ if not request.user.is_anonymous:
return redirect('wiki:root')
if not settings.ACCOUNT_HANDLING:
return redirect(settings.LOGIN_URL)
M src/wiki/views/article.py => src/wiki/views/article.py +1 -1
@@ 664,7 664,7 @@ class SearchView(ListView):
def dispatch(self, request, *args, **kwargs):
self.urlpath = None
# Do not allow anonymous users to search if they cannot read content
- if request.user.is_anonymous() and not settings.ANONYMOUS:
+ if request.user.is_anonymous and not settings.ANONYMOUS:
return redirect(settings.LOGIN_URL)
self.search_form = forms.SearchForm(request.GET)
if self.search_form.is_valid():