Updating User.is_authenticated and User.is_anonymous as properties
This commit is contained in:
Awais Qureshi
2019-12-23 17:51:27 +05:00
parent 91bb648d11
commit 5f6b2db31b
5 changed files with 6 additions and 6 deletions

View File

@@ -20,7 +20,7 @@ def get_student_module_as_dict(user, course_key, block_key):
Returns:
StudentModule as a (possibly empty) dict.
"""
if not user.is_authenticated():
if not user.is_authenticated:
return {}
try:

View File

@@ -168,7 +168,7 @@ class StudentModule(models.Model):
@classmethod
def save_state(cls, student, course_id, module_state_key, defaults):
if not student.is_authenticated():
if not student.is_authenticated:
return
else:
cls.objects.update_or_create(

View File

@@ -579,7 +579,7 @@ def get_module_system_for_user(
"""
Submit a grade for the block.
"""
if not user.is_anonymous():
if not user.is_anonymous:
grades_signals.SCORE_PUBLISHED.send(
sender=None,
block=block,

View File

@@ -274,7 +274,7 @@ def get_experiment_user_metadata_context(course, user):
pass # Not enrolled, use the default values
has_entitlements = False
if user.is_authenticated():
if user.is_authenticated:
has_entitlements = CourseEntitlement.objects.filter(user=user).exists()
context = get_base_experiment_metadata_context(course, user, enrollment, user_enrollments)
@@ -284,7 +284,7 @@ def get_experiment_user_metadata_context(course, user):
forum_roles = list(Role.objects.filter(users=user, course_id=course.id).values_list('name').distinct())
# get user partition data
if user.is_authenticated():
if user.is_authenticated:
partition_groups = get_all_partitions_for_course(course)
user_partitions = get_user_partition_groups(course.id, partition_groups, user, 'name')
else:

View File

@@ -165,7 +165,7 @@ class XBlockRuntime(RuntimeShim, Runtime):
"""
Submit a grade for the block.
"""
if not self.user.is_anonymous():
if not self.user.is_anonymous:
grades_signals.SCORE_PUBLISHED.send(
sender=None,
block=block,