Skip to content

Commit

Permalink
Merge branch 'dev' into dev-server
Browse files Browse the repository at this point in the history
  • Loading branch information
shaheenhyderk committed Nov 30, 2023
2 parents 4ae88a7 + e2b4332 commit 8e83c7b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 59 deletions.
4 changes: 2 additions & 2 deletions api/dashboard/lc/dash_lc_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ def create(self, validated_data):
validated_data['user_id'] = user_id
validated_data['circle_id'] = circle_id
validated_data['lead'] = False
validated_data['accepted'] = None
validated_data['accepted_at'] = None
validated_data['accepted'] = True
validated_data['accepted_at'] = DateTimeUtils.get_current_utc_time()
validated_data['created_at'] = DateTimeUtils.get_current_utc_time()
return UserCircleLink.objects.create(**validated_data)

Expand Down
73 changes: 36 additions & 37 deletions api/dashboard/lc/dash_lc_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from_mail = config("FROM_MAIL")


class LearningCircleListApi(APIView):
class UserLearningCircleListApi(APIView):
"""
API endpoint for listing a user's learning circles.
Expand Down Expand Up @@ -401,11 +401,11 @@ def delete(self, request, circle_id):
return CustomResponse(general_message='Left').get_success_response()


class MeetRecordsGetPostPatchDeleteAPI(APIView):
class SingleReportDetailAPI(APIView):

def get(self, request, meet_id=None, circle_id=None):
if meet_id:
circle_meeting_log = CircleMeetingLog.objects.get(id=meet_id)
def get(self, request, report_id=None, circle_id=None):
if report_id:
circle_meeting_log = CircleMeetingLog.objects.get(id=report_id)

serializer = MeetRecordsCreateEditDeleteSerializer(
circle_meeting_log,
Expand Down Expand Up @@ -444,44 +444,44 @@ def post(self, request, circle_id):
message=serializer.errors
).get_failure_response()

def patch(self, request, circle_id):
user_id = JWTUtils.fetch_user_id(request)

learning_circle = LearningCircle.objects.filter(
id=circle_id
).first()

serializer = MeetRecordsCreateEditDeleteSerializer(
learning_circle,
data=request.data,
context={
'user_id': user_id
}
)
if serializer.is_valid():
serializer.save()

return CustomResponse(
general_message='Meet updated successfully'
).get_success_response()

return CustomResponse(
message=serializer.errors
).get_failure_response()
# def patch(self, request, circle_id):
# user_id = JWTUtils.fetch_user_id(request)
#
# learning_circle = LearningCircle.objects.filter(
# id=circle_id
# ).first()
#
# serializer = MeetRecordsCreateEditDeleteSerializer(
# learning_circle,
# data=request.data,
# context={
# 'user_id': user_id
# }
# )
# if serializer.is_valid():
# serializer.save()
#
# return CustomResponse(
# general_message='Meet updated successfully'
# ).get_success_response()
#
# return CustomResponse(
# message=serializer.errors
# ).get_failure_response()


class LearningCircleLeadTransfer(APIView):
def patch(self, request, circle_id, lead_id):
def patch(self, request, circle_id, new_lead_id):
user_id = JWTUtils.fetch_user_id(request)

user_circle_link = UserCircleLink.objects.filter(
circle__id=circle_id,
user__id=user_id
).first()

lead_circle_link = UserCircleLink.objects.filter(
new_lead_circle_link = UserCircleLink.objects.filter(
circle__id=circle_id,
user__id=lead_id
user__id=new_lead_id
).first()

if not LearningCircle.objects.filter(
Expand All @@ -496,15 +496,15 @@ def patch(self, request, circle_id, lead_id):
general_message='User is not lead'
).get_failure_response()

if lead_circle_link is None:
if new_lead_circle_link is None:
return CustomResponse(
general_message='New lead not found in the circle'
).get_failure_response()

user_circle_link.lead = None
lead_circle_link.lead = 1
new_lead_circle_link.lead = 1
user_circle_link.save()
lead_circle_link.save()
new_lead_circle_link.save()

return CustomResponse(
general_message='Lead transferred successfully'
Expand Down Expand Up @@ -696,9 +696,8 @@ def get(self, request, ig_id):


class AddMemberAPI(APIView):
def post(self, request):
def post(self, request, circle_id):
muid = request.data.get('muid')
circle_id = request.data.get('circle_id')

user = User.objects.filter(muid=muid).first()
if not user:
Expand Down
42 changes: 22 additions & 20 deletions api/dashboard/lc/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,29 @@
from . import dash_lc_view

urlpatterns = [
path('', dash_lc_view.LearningCircleListApi.as_view(), name='main'),
path('add-member/', dash_lc_view.AddMemberAPI.as_view(), name='add-member'),
path('list/', dash_lc_view.LearningCircleMainApi.as_view(), name='list'),
path('data/', dash_lc_view.LearningCircleDataAPI.as_view(), name='data'),
path('list-all/', dash_lc_view.TotalLearningCircleListApi.as_view(), name='list-all'),
path('user-list/', dash_lc_view.UserLearningCircleListApi.as_view(), name='main'), # list all lc's of user
path('<str:circle_id>/details/', dash_lc_view.LearningCircleHomeApi.as_view(), name='lc-detailed'), # individual ls details
path('<str:circle_id>/schedule-meet/', dash_lc_view.ScheduleMeetAPI.as_view(), name='schedule-meet'),
path('<str:circle_id>/report/create/', dash_lc_view.SingleReportDetailAPI.as_view(), name='create-report'),
path('<str:circle_id>/report/<str:report_id>/show/', dash_lc_view.SingleReportDetailAPI.as_view(), name='show-report'),
path('<str:circle_id>/add-member/', dash_lc_view.AddMemberAPI.as_view(), name='add-member'),
path('create/', dash_lc_view.LearningCircleCreateApi.as_view(), name='create'),
path('schedule-meet/<str:circle_id>/', dash_lc_view.ScheduleMeetAPI.as_view(), name='schedule-meet'),
path('ig-task/<str:ig_id>/', dash_lc_view.IgTaskDetailsAPI.as_view(), name='ig-task'),
path('list-members/<str:circle_id>/', dash_lc_view.LearningCircleListMembersApi.as_view(), name='list-members'),
# path('invite/', dash_lc_view.LearningCircleInviteLeadAPI.as_view()),
path('list-all/<str:circle_code>/', dash_lc_view.TotalLearningCircleListApi.as_view(), name='list-all'),
path('join/<str:circle_id>/', dash_lc_view.LearningCircleJoinApi.as_view(), name='join'),
path('<str:circle_id>/<str:member_id>/', dash_lc_view.LearningCircleHomeApi.as_view()),
path('<str:circle_id>/', dash_lc_view.LearningCircleHomeApi.as_view()),
# meet record
path('meet-record/list-all/<str:circle_id>/', dash_lc_view.MeetRecordsGetPostPatchDeleteAPI.as_view(), name='list-all-meet-record'), # optim
path('meet-record/show/<str:meet_id>/', dash_lc_view.MeetRecordsGetPostPatchDeleteAPI.as_view(), name='show-all-meet-record'),
path('meet-record/edit/<str:circle_id>/', dash_lc_view.MeetRecordsGetPostPatchDeleteAPI.as_view(), name='edit-meet-record'), # optim
path('meet-record/create/<str:circle_id>/', dash_lc_view.MeetRecordsGetPostPatchDeleteAPI.as_view(), name='create-meet-record'), # optim
path('<str:circle_id>/ig-progress/', dash_lc_view.IgTaskDetailsAPI.as_view(), name='ig-progress'), # ig progress api
path('<str:circle_id>/lead-transfer/<str:new_lead_id>/', dash_lc_view.LearningCircleLeadTransfer.as_view(), name='lead-transfer'),

# rework user accept, reject api

path('member/invite/<str:circle_id>/<str:muid>/', dash_lc_view.LearningCircleInviteMemberAPI.as_view(), name='invite-member'),
path('member/invite/status/<str:circle_id>/<str:muid>/<str:status>/', dash_lc_view.LearningCircleInvitationStatus.as_view(), name='invite-member-status'),
path('lead/<str:circle_id>/<str:lead_id>/', dash_lc_view.LearningCircleLeadTransfer.as_view(), name='lead'),
path('<str:circle_id>/<str:member_id>/', dash_lc_view.LearningCircleHomeApi.as_view()), # user accept or reject, also for removal
path('list/', dash_lc_view.LearningCircleMainApi.as_view(), name='list'), # public page listing
path('list-all/', dash_lc_view.TotalLearningCircleListApi.as_view(), name='list-all'), # dashboard search listing
path('list-all/<str:circle_code>/', dash_lc_view.TotalLearningCircleListApi.as_view(), name='list-all-search'), # dashboard search listing

# path('data/', dash_lc_view.LearningCircleDataAPI.as_view(), name='data'),
# path('list-members/<str:circle_id>/', dash_lc_view.LearningCircleListMembersApi.as_view(), name='list-members'),
# path('invite/', dash_lc_view.LearningCircleInviteLeadAPI.as_view()),
# path('meet-record/list-all/<str:circle_id>/', dash_lc_view.SingleReportDetailAPI.as_view(), name='list-all-meet-record'), # optim
# path('meet-record/edit/<str:circle_id>/', dash_lc_view.SingleReportDetailAPI.as_view(), name='edit-meet-record'), # optim
# path('member/invite/<str:circle_id>/<str:muid>/', dash_lc_view.LearningCircleInviteMemberAPI.as_view(), name='invite-member'),
# path('member/invite/status/<str:circle_id>/<str:muid>/<str:status>/', dash_lc_view.LearningCircleInvitationStatus.as_view(), name='invite-member-status'),
]

0 comments on commit 8e83c7b

Please sign in to comment.