Skip to content

Commit

Permalink
fix: use year_of_birth instead of date_of_birth
Browse files Browse the repository at this point in the history
  • Loading branch information
shadinaif committed Apr 21, 2024
1 parent e4a504c commit 2a161ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 6 additions & 6 deletions futurex_openedx_extensions/dashboard/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LearnerDetailsSerializer(serializers.ModelSerializer):
username = serializers.CharField()
email = serializers.EmailField()
mobile_no = serializers.SerializerMethodField()
date_of_birth = serializers.SerializerMethodField()
year_of_birth = serializers.SerializerMethodField()
gender = serializers.SerializerMethodField()
date_joined = serializers.DateTimeField()
last_login = serializers.DateTimeField()
Expand All @@ -30,7 +30,7 @@ class Meta:
'username',
'email',
'mobile_no',
'date_of_birth',
'year_of_birth',
'gender',
'date_joined',
'last_login',
Expand All @@ -55,10 +55,6 @@ def get_mobile_no(self, obj):
"""Return mobile number."""
return self._get_profile_field(obj, 'phone_number')

def get_date_of_birth(self, obj): # pylint: disable=unused-argument
"""Return date of birth."""
return None

def get_gender(self, obj):
"""Return gender."""
return self._get_profile_field(obj, 'gender')
Expand All @@ -71,6 +67,10 @@ def get_enrolled_courses_count(self, obj):
"""Return enrolled courses count."""
return obj.courses_count

def get_year_of_birth(self, obj):
"""Return year of birth."""
return self._get_profile_field(obj, 'year_of_birth')


class CourseDetailsSerializer(serializers.ModelSerializer):
"""Serializer for course details."""
Expand Down
5 changes: 3 additions & 2 deletions tests/test_dashboard/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_learner_details_serializer_no_profile():
assert data[0]['user_id'] == 10
assert data[0]['full_name'] is None
assert data[0]['mobile_no'] is None
assert data[0]['date_of_birth'] is None
assert data[0]['year_of_birth'] is None
assert data[0]['gender'] is None


Expand All @@ -36,12 +36,13 @@ def test_learner_details_serializer_with_profile():
name='Test User',
phone_number='1234567890',
gender='m',
year_of_birth=1988,
)
queryset = get_dummy_queryset()
data = LearnerDetailsSerializer(queryset, many=True).data
assert len(data) == 1
assert data[0]['user_id'] == 10
assert data[0]['full_name'] == 'Test User'
assert data[0]['mobile_no'] == '1234567890'
assert data[0]['date_of_birth'] is None
assert data[0]['year_of_birth'] == 1988
assert data[0]['gender'] == 'm'

0 comments on commit 2a161ca

Please sign in to comment.