Skip to content

Commit

Permalink
Merge pull request #1636 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
[FEAT] Delete user profile from account
  • Loading branch information
adnankattekaden authored Nov 29, 2023
2 parents 9362ca0 + a4e1ef5 commit bb49beb
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 174 deletions.
97 changes: 65 additions & 32 deletions api/dashboard/campus/campus_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,47 +84,80 @@ class CampusStudentDetailsAPI(APIView):
def get(self, request):
user_id = JWTUtils.fetch_user_id(request)
user_org_link = get_user_college_link(user_id)
is_alumni = request.query_params.get("is_alumni", "").lower() in ["1", "true"]
is_alumni = request.query_params.get("is_alumni")

if user_org_link.org is None:
return CustomResponse(
general_message="Campus lead has no college"
).get_failure_response()

rank = (
Wallet.objects.filter(
user__user_organization_link_user__org=user_org_link.org,
user__user_organization_link_user__org__org_type=OrganizationType.COLLEGE.value,
user__user_organization_link_user__is_alumni=is_alumni,
)
.distinct()
.order_by("-karma", "-created_at")
.values(
"user_id",
"karma",
if is_alumni:
rank = (
Wallet.objects.filter(
user__user_organization_link_user__org=user_org_link.org,
user__user_organization_link_user__org__org_type=OrganizationType.COLLEGE.value,
user__user_organization_link_user__is_alumni=is_alumni,
)
.distinct()
.order_by("-karma", "-created_at")
.values(
"user_id",
"karma",
)
)
)

ranks = {user["user_id"]: i + 1 for i, user in enumerate(rank)}
ranks = {user["user_id"]: i + 1 for i, user in enumerate(rank)}

user_org_links = (
User.objects.filter(
user_organization_link_user__org=user_org_link.org,
user_organization_link_user__org__org_type=OrganizationType.COLLEGE.value,
user_organization_link_user__is_alumni=is_alumni,
user_org_links = (
User.objects.filter(
user_organization_link_user__org=user_org_link.org,
user_organization_link_user__org__org_type=OrganizationType.COLLEGE.value,
user_organization_link_user__is_alumni=is_alumni,
)
.distinct()
.annotate(
user_id=F("id"),
email_=F("email"),
mobile_=F("mobile"),
karma=F("wallet_user__karma"),
level=F("user_lvl_link_user__level__name"),
join_date=F("created_at"),
department=F('user_organization_link_user__department__title'),
graduation_year=F("user_organization_link_user__graduation_year"),
is_alumni=F('user_organization_link_user__is_alumni'),
))
else:
rank = (
Wallet.objects.filter(
user__user_organization_link_user__org=user_org_link.org,
user__user_organization_link_user__org__org_type=OrganizationType.COLLEGE.value,
)
.distinct()
.order_by("-karma", "-created_at")
.values(
"user_id",
"karma",
)
)
.distinct()
.annotate(
user_id=F("id"),
email_=F("email"),
mobile_=F("mobile"),
karma=F("wallet_user__karma"),
level=F("user_lvl_link_user__level__name"),
join_date=F("created_at"),
department=F('user_organization_link_user__department__title'),
graduation_year=F("user_organization_link_user__graduation_year"),
is_alumni=F('user_organization_link_user__is_alumni'),
))

ranks = {user["user_id"]: i + 1 for i, user in enumerate(rank)}

user_org_links = (
User.objects.filter(
user_organization_link_user__org=user_org_link.org,
user_organization_link_user__org__org_type=OrganizationType.COLLEGE.value,
)
.distinct()
.annotate(
user_id=F("id"),
email_=F("email"),
mobile_=F("mobile"),
karma=F("wallet_user__karma"),
level=F("user_lvl_link_user__level__name"),
join_date=F("created_at"),
department=F('user_organization_link_user__department__title'),
graduation_year=F("user_organization_link_user__graduation_year"),
is_alumni=F('user_organization_link_user__is_alumni'),
))

paginated_queryset = CommonUtils.get_paginated_queryset(
user_org_links,
Expand Down
3 changes: 3 additions & 0 deletions api/dashboard/lc/dash_lc_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ def update(self, instance, validated_data):


class ScheduleMeetingSerializer(serializers.ModelSerializer):
meet_time = serializers.CharField(required=True)
day = serializers.CharField(required=True)

class Meta:
model = LearningCircle
fields = [
Expand Down
3 changes: 1 addition & 2 deletions api/dashboard/lc/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
path('data/', dash_lc_view.LearningCircleDataAPI.as_view()),
path('list-all/', dash_lc_view.TotalLearningCircleListApi.as_view()),
path('create/', dash_lc_view.LearningCircleCreateApi.as_view()),
path('schedule-meet/<str:circle_id>/', dash_lc_view.ScheduleMeetAPI.as_view()),
path('ig-task/<str:ig_id>/', dash_lc_view.IgTaskDetailsAPI.as_view()),
path('list-members/<str:circle_id>/', dash_lc_view.LearningCircleListMembersApi.as_view()),
# path('invite/', dash_lc_view.LearningCircleInviteLeadAPI.as_view()),
Expand All @@ -21,8 +22,6 @@
path('meet-record/edit/<str:circle_id>/', dash_lc_view.MeetRecordsGetPostPatchDeleteAPI.as_view()), # optim
path('meet-record/create/<str:circle_id>/', dash_lc_view.MeetRecordsGetPostPatchDeleteAPI.as_view()), # optim

path('schedule-meet/<str:circle_id>/', dash_lc_view.ScheduleMeetAPI.as_view()),

path('member/invite/<str:circle_id>/<str:muid>/', dash_lc_view.LearningCircleInviteMemberAPI.as_view()),
path('member/invite/status/<str:circle_id>/<str:muid>/<str:status>/', dash_lc_view.LearningCircleInvitationStatus.as_view()),
path('lead/<str:circle_id>/<str:lead_id>/', dash_lc_view.LearningCircleLeadTransfer.as_view()),
Expand Down
Loading

0 comments on commit bb49beb

Please sign in to comment.