Silence deprecation warnings
https://docs.djangoproject.com/en/1.11/releases/1.10/#using-user-is-authenticated-and-user-is-anonymous-as-methods
This commit is contained in:
@@ -137,7 +137,7 @@ def permission_blacked_out(course, role_names, permission_name):
|
||||
|
||||
def all_permissions_for_user_in_course(user, course_id): # pylint: disable=invalid-name
|
||||
"""Returns all the permissions the user has in the given course."""
|
||||
if not user.is_authenticated():
|
||||
if not user.is_authenticated:
|
||||
return {}
|
||||
|
||||
course = modulestore().get_course(course_id)
|
||||
|
||||
@@ -106,7 +106,7 @@ class EnrollmentUserThrottle(UserRateThrottle, ApiKeyPermissionMixIn):
|
||||
def allow_request(self, request, view):
|
||||
# Use a special scope for staff to allow for a separate throttle rate
|
||||
user = request.user
|
||||
if user.is_authenticated() and (user.is_staff or user.is_superuser):
|
||||
if user.is_authenticated and (user.is_staff or user.is_superuser):
|
||||
self.scope = 'staff'
|
||||
self.rate = self.get_rate()
|
||||
self.num_requests, self.duration = self.parse_rate(self.rate)
|
||||
|
||||
@@ -164,7 +164,7 @@ def _check_caller_authority(caller, role):
|
||||
:param caller: a user
|
||||
:param role: an AccessRole
|
||||
"""
|
||||
if not (caller.is_authenticated() and caller.is_active):
|
||||
if not (caller.is_authenticated and caller.is_active):
|
||||
raise PermissionDenied
|
||||
# superuser
|
||||
if GlobalStaff().has_user(caller):
|
||||
|
||||
@@ -124,7 +124,7 @@ class GlobalStaff(AccessRole):
|
||||
|
||||
def add_users(self, *users):
|
||||
for user in users:
|
||||
if user.is_authenticated() and user.is_active:
|
||||
if user.is_authenticated and user.is_active:
|
||||
user.is_staff = True
|
||||
user.save()
|
||||
|
||||
@@ -167,7 +167,7 @@ class RoleBase(AccessRole):
|
||||
Return:
|
||||
bool identifying if user has that particular role or not
|
||||
"""
|
||||
if check_user_activation and not (user.is_authenticated() and user.is_active):
|
||||
if check_user_activation and not (user.is_authenticated and user.is_active):
|
||||
return False
|
||||
|
||||
# pylint: disable=protected-access
|
||||
@@ -186,7 +186,7 @@ class RoleBase(AccessRole):
|
||||
# legit get updated.
|
||||
from student.models import CourseAccessRole
|
||||
for user in users:
|
||||
if user.is_authenticated() and user.is_active and not self.has_user(user):
|
||||
if user.is_authenticated and user.is_active and not self.has_user(user):
|
||||
entry = CourseAccessRole(user=user, role=self._role_name, course_id=self.course_key, org=self.org)
|
||||
entry.save()
|
||||
if hasattr(user, '_roles'):
|
||||
@@ -372,7 +372,7 @@ class UserBasedRole(object):
|
||||
"""
|
||||
Return whether the role's user has the configured role access to the passed course
|
||||
"""
|
||||
if not (self.user.is_authenticated() and self.user.is_active):
|
||||
if not (self.user.is_authenticated and self.user.is_active):
|
||||
return False
|
||||
|
||||
# pylint: disable=protected-access
|
||||
@@ -385,7 +385,7 @@ class UserBasedRole(object):
|
||||
"""
|
||||
Grant this object's user the object's role for the supplied courses
|
||||
"""
|
||||
if self.user.is_authenticated() and self.user.is_active:
|
||||
if self.user.is_authenticated and self.user.is_active:
|
||||
for course_key in course_keys:
|
||||
entry = CourseAccessRole(user=self.user, role=self.role, course_id=course_key, org=course_key.org)
|
||||
entry.save()
|
||||
|
||||
@@ -514,7 +514,7 @@ def signin_user(request):
|
||||
return external_auth_response
|
||||
# Determine the URL to redirect to following login:
|
||||
redirect_to = get_next_url_for_login_page(request)
|
||||
if request.user.is_authenticated():
|
||||
if request.user.is_authenticated:
|
||||
return redirect(redirect_to)
|
||||
|
||||
third_party_auth_error = None
|
||||
|
||||
@@ -203,7 +203,7 @@ def register_user(request, extra_context=None):
|
||||
"""
|
||||
# Determine the URL to redirect to following login:
|
||||
redirect_to = get_next_url_for_login_page(request)
|
||||
if request.user.is_authenticated():
|
||||
if request.user.is_authenticated:
|
||||
return redirect(redirect_to)
|
||||
|
||||
external_auth_response = external_auth_register(request)
|
||||
@@ -352,7 +352,7 @@ def change_enrollment(request, check_access=True):
|
||||
user = request.user
|
||||
|
||||
# Ensure the user is authenticated
|
||||
if not user.is_authenticated():
|
||||
if not user.is_authenticated:
|
||||
return HttpResponseForbidden()
|
||||
|
||||
# Ensure we received a course_id
|
||||
@@ -1020,7 +1020,7 @@ def activate_account(request, key):
|
||||
# Success message for logged in users.
|
||||
message = _('{html_start}Success{html_end} You have activated your account.')
|
||||
|
||||
if not request.user.is_authenticated():
|
||||
if not request.user.is_authenticated:
|
||||
# Success message for logged out users
|
||||
message = _(
|
||||
'{html_start}Success! You have activated your account.{html_end}'
|
||||
@@ -1054,7 +1054,7 @@ def activate_account_studio(request, key):
|
||||
{'csrf': csrf(request)['csrf_token']}
|
||||
)
|
||||
else:
|
||||
user_logged_in = request.user.is_authenticated()
|
||||
user_logged_in = request.user.is_authenticated
|
||||
already_active = True
|
||||
if not registration.user.is_active:
|
||||
if waffle().is_enabled(PREVENT_AUTH_USER_WRITES):
|
||||
|
||||
@@ -626,7 +626,7 @@ def set_logged_in_cookies(backend=None, user=None, strategy=None, auth_entry=Non
|
||||
to the next pipeline step.
|
||||
|
||||
"""
|
||||
if not is_api(auth_entry) and user is not None and user.is_authenticated():
|
||||
if not is_api(auth_entry) and user is not None and user.is_authenticated:
|
||||
request = strategy.request if strategy else None
|
||||
# n.b. for new users, user.is_active may be False at this point; set the cookie anyways.
|
||||
if request is not None:
|
||||
|
||||
@@ -53,7 +53,7 @@ def cache_if_anonymous(*get_parameters):
|
||||
# If that page is cached the authentication doesn't
|
||||
# happen, so we disable the cache when that feature is enabled.
|
||||
if (
|
||||
not request.user.is_authenticated() and
|
||||
not request.user.is_authenticated and
|
||||
not settings.FEATURES['AUTH_USE_CERTIFICATES']
|
||||
):
|
||||
# Use the cache. The same view accessed through different domain names may
|
||||
|
||||
@@ -215,7 +215,7 @@ def get_required_content(course_key, user):
|
||||
if settings.FEATURES.get('MILESTONES_APP'):
|
||||
course_run_id = unicode(course_key)
|
||||
|
||||
if user.is_authenticated():
|
||||
if user.is_authenticated:
|
||||
# Get all of the outstanding milestones for this course, for this user
|
||||
try:
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ def _get_zendesk_custom_field_context(request, **kwargs):
|
||||
return context
|
||||
|
||||
context["course_id"] = course_id
|
||||
if not request.user.is_authenticated():
|
||||
if not request.user.is_authenticated:
|
||||
return context
|
||||
|
||||
enrollment = CourseEnrollment.get_enrollment(request.user, CourseKey.from_string(course_id))
|
||||
@@ -388,7 +388,7 @@ def get_feedback_form_context(request):
|
||||
|
||||
context["additional_info"] = {}
|
||||
|
||||
if request.user.is_authenticated():
|
||||
if request.user.is_authenticated:
|
||||
context["realname"] = request.user.profile.name
|
||||
context["email"] = request.user.email
|
||||
context["additional_info"]["username"] = request.user.username
|
||||
@@ -432,7 +432,7 @@ def submit_feedback(request):
|
||||
|
||||
required_fields = ["subject", "details"]
|
||||
|
||||
if not request.user.is_authenticated():
|
||||
if not request.user.is_authenticated:
|
||||
required_fields += ["name", "email"]
|
||||
|
||||
required_field_errs = {
|
||||
@@ -445,7 +445,7 @@ def submit_feedback(request):
|
||||
if field not in request.POST or not request.POST[field]:
|
||||
return build_error_response(400, field, required_field_errs[field])
|
||||
|
||||
if not request.user.is_authenticated():
|
||||
if not request.user.is_authenticated:
|
||||
try:
|
||||
validate_email(request.POST["email"])
|
||||
except ValidationError:
|
||||
|
||||
@@ -61,7 +61,7 @@ class DjangoXBlockUserService(UserService):
|
||||
"""
|
||||
xblock_user = XBlockUser(is_current_user=True)
|
||||
|
||||
if django_user is not None and django_user.is_authenticated():
|
||||
if django_user is not None and django_user.is_authenticated:
|
||||
# This full_name is dependent on edx-platform's profile implementation
|
||||
if hasattr(django_user, 'profile'):
|
||||
full_name = django_user.profile.name
|
||||
|
||||
@@ -136,6 +136,6 @@ from django.core.urlresolvers import reverse
|
||||
</section>
|
||||
</section>
|
||||
|
||||
%if user.is_authenticated():
|
||||
%if user.is_authenticated:
|
||||
<%include file="../signup_modal.html" />
|
||||
%endif
|
||||
|
||||
Reference in New Issue
Block a user