Skip to content

Commit

Permalink
Merge pull request #1835 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
fullname issue fixed
  • Loading branch information
adnankattekaden authored Dec 18, 2023
2 parents 5f3b9ae + 3152336 commit 74c6161
Show file tree
Hide file tree
Showing 22 changed files with 115 additions and 121 deletions.
36 changes: 14 additions & 22 deletions api/common/common_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ def get(self, request):
total_no_enrollment = (UserCircleLink.objects.filter(accepted=True,
user__user_organization_link_user__org__org_type=OrganizationType.COLLEGE.value,
created_at__gt=date).values(
first_name=F("user__first_name"),
last_name=F("user__last_name"),
full_name=F("user__full_name"),
email=F("user__email"),
muid=F("user__muid"),
circle_name=F("circle__name"),
Expand Down Expand Up @@ -88,8 +87,7 @@ def get(self, request):
# user__user_organization_link_user__org__org_type=OrganizationType.COLLEGE.value).count()
total_no_enrollment = (UserCircleLink.objects.filter(accepted=True,
user__user_organization_link_user__org__org_type=OrganizationType.COLLEGE.value).values(
first_name=F("user__first_name"),
last_name=F("user__last_name"),
full_name=F("user__full_name"),
email=F("user__email"),
muid=F("user__muid"),
circle_name=F("circle__name"),
Expand Down Expand Up @@ -158,8 +156,7 @@ def get(self, request):
student_info = (UserCircleLink.objects.filter(accepted=True,
user__user_organization_link_user__org__org_type=OrganizationType.COLLEGE.value,
created_at__date=date).values(
first_name=F("user__first_name"),
last_name=F("user__last_name"),
full_name=F("user__full_name"),
muid=F("user__muid"),
circle_name=F("circle__name"),
circle_ig=F("circle__ig__name"),
Expand Down Expand Up @@ -190,8 +187,7 @@ def get(self, request):
user__user_organization_link_user__org__org_type=OrganizationType.COLLEGE.value,
)
.values(
first_name=F("user__first_name"),
last_name=F("user__last_name"),
full_name=F("user__full_name"),
muid=F("user__muid"),
circle_name=F("circle__name"),
circle_ig=F("circle__ig__name"),
Expand Down Expand Up @@ -220,9 +216,9 @@ def get(self, request):
paginated_queryset = CommonUtils.get_paginated_queryset(
student_info,
request,
search_fields=["first_name", "last_name", "muid", "circle_name", 'circle_ig', "organisation",
search_fields=["full_name", "muid", "circle_name", 'circle_ig', "organisation",
"karma_earned"],
sort_fields={"first_name": "first_name", "last_name": "last_name", "muid": "muid",
sort_fields={"full_name": "full_name", "muid": "muid",
"circle_name": "circle_name",
"circle_ig": "circle_ig", "organisation": "organisation", "dwms_id": "dwms_id",
"karma_earned": "karma_earned"},
Expand All @@ -246,8 +242,7 @@ def get(self, request):
user__user_organization_link_user__org__org_type=OrganizationType.COLLEGE.value,
)
.values(
first_name=F("user__first_name"),
last_name=F("user__last_name"),
full_name=F("user__full_name"),
muid=F("user__muid"),
circle_name=F("circle__name"),
circle_ig=F("circle__ig__name"),
Expand Down Expand Up @@ -366,8 +361,7 @@ class LearningCircleEnrollment(APIView):
def get(self, request):
total_no_enrollment = (UserCircleLink.objects.filter(accepted=True,
user__user_organization_link_user__org__org_type=OrganizationType.COLLEGE.value).values(
first_name=F("user__first_name"),
last_name=F("user__last_name"),
full_name=F("user__full_name"),
email=F("user__email"),
muid=F("user__muid"),
circle_name=F("circle__name"),
Expand Down Expand Up @@ -397,9 +391,9 @@ def get(self, request):
paginated_queryset = CommonUtils.get_paginated_queryset(
total_no_enrollment,
request,
search_fields=["first_name", "last_name", "email", "muid", "circle_name", "district", "circle_ig",
search_fields=["full_name", "email", "muid", "circle_name", "district", "circle_ig",
"organisation", "karma_earned"],
sort_fields={"first_name": "first_name", "last_name": "last_name", "email": "email", "muid": "muid",
sort_fields={"full_name": "full_name", "email": "email", "muid": "muid",
"circle_name": "circle_name", "district": "district", "circle_ig": "circle_ig",
"organisation": "organisation", "dwms_id": "dwms_id", "karma_earned": "karma_earned"},
is_pagination=True)
Expand All @@ -414,8 +408,7 @@ class LearningCircleEnrollmentCSV(APIView):
def get(self, request):
total_no_enrollment = (UserCircleLink.objects.filter(accepted=True,
user__user_organization_link_user__org__org_type=OrganizationType.COLLEGE.value).values(
first_name=F("user__first_name"),
last_name=F("user__last_name"),
full_name=F("user__full_name"),
email=F("user__email"),
muid=F("user__muid"),
circle_name=F("circle__name"),
Expand Down Expand Up @@ -446,9 +439,9 @@ def get(self, request):
paginated_queryset = CommonUtils.get_paginated_queryset(
total_no_enrollment,
request,
search_fields=["first_name", "last_name", "email", "muid", "circle_name", "district", "circle_ig",
search_fields=["full_name", "email", "muid", "circle_name", "district", "circle_ig",
"organisation", "karma_earned"],
sort_fields={"first_name": "first_name", "last_name": "last_name", "email": "email", "muid": "muid",
sort_fields={"full_name": "full_name", "email": "email", "muid": "muid",
"circle_name": "circle_name", "district": "district", "circle_ig": "circle_ig",
"organisation": "organisation", "dwms_id": "dwms_id", "karma_earned": "karma_earned"},
is_pagination=False)
Expand Down Expand Up @@ -546,8 +539,7 @@ def get(self, request):
).values(
userid=F('user__id'),
muid=F('user__muid'),
first_name=F('user__first_name'),
last_name=F('user__last_name'),
full_name=F('user__full_name'),
).annotate(
ig_karma=Sum('karma')
).order_by('-ig_karma')[:100]
Expand Down
6 changes: 2 additions & 4 deletions api/common/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@


class StudentInfoSerializer(serializers.Serializer):
first_name = serializers.CharField()
last_name = serializers.CharField()
full_name = serializers.CharField()
muid = serializers.CharField()
circle_name = serializers.CharField()
circle_ig = serializers.CharField()
Expand All @@ -21,8 +20,7 @@ class CollegeInfoSerializer(serializers.Serializer):


class LearningCircleEnrollmentSerializer(serializers.Serializer):
first_name = serializers.CharField()
last_name = serializers.CharField()
full_name = serializers.CharField()
muid = serializers.CharField()
email = serializers.CharField()
dwms_id = serializers.CharField(allow_null=True)
Expand Down
10 changes: 4 additions & 6 deletions api/dashboard/campus/campus_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,9 @@ def get(self, request):
paginated_queryset = CommonUtils.get_paginated_queryset(
user_org_links,
request,
["first_name", "last_name", "level"],
["full_name", "level"],
{
"first_name": "first_name",
"last_name": "last_name",
"full_name": "full_name",
"muid": "muid",
"karma": "wallet_user__karma",
"level": "user_lvl_link_user__level__level_order",
Expand Down Expand Up @@ -277,10 +276,9 @@ def get(self, request):
paginated_queryset = CommonUtils.get_paginated_queryset(
user_org_links,
request,
["first_name", "last_name", "level"],
["full_name", "level"],
{
"first_name": "first_name",
"last_name": "last_name",
"full_name": "full_name",
"muid": "muid",
"karma": "wallet_user__karma",
"level": "user_lvl_link_user__level__level_order",
Expand Down
5 changes: 2 additions & 3 deletions api/dashboard/district/dash_district_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ def get(self, request):
paginated_queryset = CommonUtils.get_paginated_queryset(
user_org_links,
request,
["first_name", "last_name", "level"],
["full_name", "level"],
{
"first_name": "first_name",
"last_name": "last_name",
"full_name": "full_name",
"muid": "muid",
"karma": "wallet_user__karma",
"level": "user_lvl_link_user__level__level_order",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def get_users(self, obj):
user_data = [{
'dynamic_user_id': dynamic_user.id,
'user_id': dynamic_user.user.id,
'name': f"{dynamic_user.user.first_name} {dynamic_user.user.last_name if dynamic_user.user.last_name else ''}",
'name': dynamic_user.user.full_name,
'muid': dynamic_user.user.muid,
'email': dynamic_user.user.email} for dynamic_user in dynamic_users]
return user_data
Expand Down
4 changes: 2 additions & 2 deletions api/dashboard/dynamic_management/dynamic_management_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def get(self, request): # list

paginated_queryset = CommonUtils.get_paginated_queryset(
data, request,
search_fields=["type", "user__first_name", "user__last_name"],
search_fields=["type", "user__full_name"],
sort_fields={'type': 'type',
'user': 'user__first_name'}
'user': 'user__full_name'}
)
dynamic_user_serializer = DynamicUserListSerializer(paginated_queryset.get('queryset'), many=True).data
return CustomResponse().paginated_response(data=dynamic_user_serializer,
Expand Down
10 changes: 4 additions & 6 deletions api/dashboard/ig/dash_ig_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,16 @@ def get(self, request):
request,
[
"name",
"created_by__first_name",
"created_by__last_name",
"updated_by__first_name",
"updated_by__last_name",
"created_by__full_name",
"updated_by__full_name",
],
{
"name": "name",
"members": "members",
"updated_on": "updated_at",
"updated_by": "updated_by__first_name",
"updated_by": "updated_by__full_name",
"created_on": "created_at",
"created_by": "created_by__first_name",
"created_by": "created_by__full_name",
},
)

Expand Down
20 changes: 9 additions & 11 deletions api/dashboard/karma_voucher/karma_voucher_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ def post(self, request):
users_to_fetch.add(muid)
tasks_to_fetch.add(task_hashtag)
# Fetching users and tasks in bulk
users = User.objects.filter(muid__in=users_to_fetch).values('id', 'email', 'first_name', 'last_name', 'muid')
users = User.objects.filter(muid__in=users_to_fetch).values('id', 'email', 'full_name', 'muid')
tasks = TaskList.objects.filter(hashtag__in=tasks_to_fetch).values('id', 'hashtag')
user_dict = {
user['muid']: (
user['id'], user['email'],
user['first_name'] if user['last_name'] is None else f"{user['first_name']} {user['last_name']}"
user['full_name']
) for user in users
}

Expand Down Expand Up @@ -219,20 +219,20 @@ def get(self, request):
voucher_queryset = VoucherLog.objects.all()
paginated_queryset = CommonUtils.get_paginated_queryset(
voucher_queryset, request,
search_fields=["user__first_name", "user__last_name",
search_fields=["user__full_name",
"task__title", "karma", "month", "week", "claimed",
"updated_by__first_name", "updated_by__last_name",
"created_by__first_name", "created_by__last_name",
"updated_by__full_name",
"created_by__full_name",
"description", "event", "code"],

sort_fields={'user': 'user__first_name',
sort_fields={'user': 'user__full_name',
'code': 'code',
'karma': 'karma',
'claimed': 'claimed',
'task': 'task__title',
'week': 'week',
'month': 'month',
'updated_by': 'updated_by__first_name',
'updated_by': 'updated_by__full_name',
'updated_at': 'updated_at',
'created_at': 'created_at',
'event': 'event',
Expand All @@ -251,8 +251,7 @@ def post(self, request):
id = serializer.save().id
voucher = VoucherLog.objects.filter(id=id).values(
'code',
'user__first_name',
'user__last_name',
'user__full_name',
'user__email',
'task__hashtag',
'month',
Expand All @@ -268,8 +267,7 @@ def post(self, request):
week = voucher['week']
karma = voucher['karma']
task_hashtag = voucher['task__hashtag']
full_name = voucher['user__first_name'] if voucher[
'user__last_name'] is None else f"{voucher['user__first_name']} {voucher['user__last_name']}"
full_name = voucher['user__full_name']
email = voucher['user__email']

# Preparing email context and attachment
Expand Down
3 changes: 1 addition & 2 deletions api/dashboard/lc/dash_lc_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,8 @@ def create(self, validated_data):
# accepted=True
# ).values(
# full_name=Concat(
# 'user__first_name',
# 'user__full_name',
# Value(' '),
# 'user__last_name',
# output_field=CharField()
# ),
# discord_id=F('user__discord_id'),
Expand Down
11 changes: 4 additions & 7 deletions api/dashboard/profile/profile_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ class Meta:
fields = (
"id",
"joined",
"first_name",
"last_name",
"full_name",
"gender",
"muid",
"roles",
Expand Down Expand Up @@ -201,16 +200,15 @@ def get_tasks(self, obj):


class UserRankSerializer(ModelSerializer):
first_name = serializers.CharField()
last_name = serializers.CharField()
full_name = serializers.CharField()
role = serializers.SerializerMethodField()
rank = serializers.SerializerMethodField()
karma = serializers.SerializerMethodField()
interest_groups = serializers.SerializerMethodField()

class Meta:
model = User
fields = ("first_name", "last_name", "role",
fields = ("full_name", "role",
"rank", "karma", "interest_groups")

def get_role(self, obj):
Expand Down Expand Up @@ -322,8 +320,7 @@ def update(self, instance, validated_data):
class Meta:
model = User
fields = [
"first_name",
"last_name",
"full_name",
"email",
"mobile",
"communities",
Expand Down
14 changes: 6 additions & 8 deletions api/dashboard/roles/dash_roles_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@ def get(self, request):
"id",
"title",
"description",
"updated_by__first_name",
"updated_by__last_name",
"created_by__first_name",
"created_by__last_name",
"updated_by__full_name",
"created_by__full_name",
],
{
"title": "title",
"description": "description",
"members": "userrolelink",
"updated_by": "updated_by__first_name",
"created_by": "created_by__first_name",
"updated_by": "updated_by__full_name",
"created_by": "created_by__full_name",
"updated_at": "updated_at",
"created_at": "created_at",
},
Expand Down Expand Up @@ -142,8 +140,8 @@ def get(self, request, role_id):
paginated_queryset = CommonUtils.get_paginated_queryset(
user,
request,
["muid", "first_name", "last_name"],
{"muid": "muid", "first_name": "first_name", "last_name": "last_name"},
["muid", "full_name"],
{"muid": "muid", "full_name": "full_name"},
)

serializer = dash_roles_serializer.UserRoleSearchSerializer(
Expand Down
8 changes: 4 additions & 4 deletions api/dashboard/task/dash_task_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def get(self, request):
"ig__name",
"event",
"updated_at",
"updated_by__first_name",
"created_by__first_name",
"updated_by__full_name",
"created_by__full_name",
"created_at",
],
sort_fields={
Expand All @@ -80,8 +80,8 @@ def get(self, request):
"ig": "ig__name",
"event": "event",
"updated_at": "updated_at",
"updated_by": "updated_by__first_name",
"created_by": "created_by__first_name",
"updated_by": "updated_by__full_name",
"created_by": "created_by__full_name",
"created_at": "created_at",
},
)
Expand Down
Loading

0 comments on commit 74c6161

Please sign in to comment.