Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/lordgrim18/mulearnbackend in…
Browse files Browse the repository at this point in the history
…to dev
  • Loading branch information
lordgrim18 committed Nov 29, 2023
2 parents ff95e0b + 54e3366 commit 73a683d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 43 deletions.
2 changes: 2 additions & 0 deletions api/dashboard/campus/campus_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def get(self, request):
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")
))

paginated_queryset = CommonUtils.get_paginated_queryset(
Expand Down
2 changes: 2 additions & 0 deletions api/dashboard/campus/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class CampusStudentDetailsSerializer(serializers.Serializer):
join_date = serializers.CharField()
email = serializers.CharField()
mobile = serializers.CharField()
graduation_year = serializers.CharField()
department = serializers.CharField()

class Meta:
fields = ("user_id", "email", "mobile", "fullname", "karma", "muid", "rank", "level", "join_date")
Expand Down
39 changes: 38 additions & 1 deletion api/dashboard/lc/dash_lc_serializer.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import uuid

from django.db.models import Sum, Count
from django.db.models import Sum, Count, Value, CharField
from django.db.models.functions import Concat
from rest_framework import serializers

from db.learning_circle import LearningCircle, UserCircleLink, InterestGroup, CircleMeetingLog
from db.task import TaskList, UserIgLink
from db.organization import UserOrganizationLink
from db.task import KarmaActivityLog
from db.user import User
from utils.types import OrganizationType
from utils.utils import DateTimeUtils
from utils.types import Lc
Expand Down Expand Up @@ -505,17 +507,42 @@ def update(self, instance, validated_data):


class MeetRecordsCreateEditDeleteSerializer(serializers.ModelSerializer):
attendees_details = serializers.SerializerMethodField()
meet_created_by = serializers.CharField(source='created_by.fullname', required=False)
meet_created_at = serializers.CharField(source='created_at', required=False)
meet_id = serializers.CharField(source='id', required=False)

class Meta:
model = CircleMeetingLog
fields = [
"meet_id",
"meet_time",
"meet_place",
"day",
"attendees",
"agenda",
"attendees_details",
"meet_created_by",
"meet_created_at"
]

def get_attendees_details(self, obj):
attendees_list = obj.attendees.split(',')

attendees_details_list = User.objects.filter(
id__in=attendees_list
).values(
'profile_pic',
fullname=Concat(
'first_name',
Value(' '),
'last_name',
output_field=CharField()
),
)

return attendees_details_list

def create(self, validated_data):
validated_data['id'] = uuid.uuid4()
validated_data['circle_id'] = self.context.get('circle_id')
Expand Down Expand Up @@ -550,6 +577,16 @@ def validate_attendees(self, attendees):
return attendees


class ListAllMeetRecordsSerializer(serializers.ModelSerializer):
class Meta:
model = CircleMeetingLog
fields = [
"id",
"meet_time",
"day",
]


class IgTaskDetailsSerializer(serializers.ModelSerializer):
task = serializers.CharField(source='title')
is_completed = serializers.SerializerMethodField()
Expand Down
56 changes: 14 additions & 42 deletions api/dashboard/lc/dash_lc_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from .dash_lc_serializer import LearningCircleSerializer, LearningCircleCreateSerializer, LearningCircleHomeSerializer, \
LearningCircleUpdateSerializer, LearningCircleJoinSerializer, \
LearningCircleMainSerializer, LearningCircleNoteSerializer, LearningCircleDataSerializer, \
LearningCircleMemberListSerializer, MeetRecordsCreateEditDeleteSerializer, IgTaskDetailsSerializer, ScheduleMeetingSerializer
LearningCircleMemberListSerializer, MeetRecordsCreateEditDeleteSerializer, IgTaskDetailsSerializer, \
ScheduleMeetingSerializer, ListAllMeetRecordsSerializer

domain = config("FR_DOMAIN_NAME")
from_mail = config("FROM_MAIL")
Expand Down Expand Up @@ -396,53 +397,24 @@ def delete(self, request, circle_id):

class MeetRecordsGetPostPatchDeleteAPI(APIView):

def get(self, request, circle_id=None, meet_id=None):

def get(self, request, meet_id=None, circle_id=None):
if meet_id:
circle_meeting_log = CircleMeetingLog.objects.filter(
id=meet_id
).values(
"id",
"meet_time",
"meet_place",
"day",
"attendees",
"agenda",
meet_created_by=F("created_by__first_name"),
meet_created_at=F("created_at"),
meet_updated_by=F("updated_by__first_name"),
meet_updated_at=F("updated_at"),
)
for meeting in circle_meeting_log:

attendees = meeting.get('attendees', '')
attendees_list = attendees.split(',')

attendees_first_names = User.objects.filter(
id__in=attendees_list
).values(
'profile_pic',
fullname=Concat(
'first_name',
Value(' '),
'last_name',
output_field=CharField()
),
)
circle_meeting_log = CircleMeetingLog.objects.get(id=meet_id)

meeting['attendees'] = list(attendees_first_names)
serializer = MeetRecordsCreateEditDeleteSerializer(
circle_meeting_log,
many=False
).data

if circle_id:
circle_meeting_log = CircleMeetingLog.objects.filter(
circle_id=circle_id
).values(
"id",
"meet_time",
"day"
)
circle_meeting_log = CircleMeetingLog.objects.filter(circle_id=circle_id)
serializer = ListAllMeetRecordsSerializer(
circle_meeting_log,
many=True
).data

return CustomResponse(
response=circle_meeting_log
response=serializer
).get_success_response()

def post(self, request, circle_id):
Expand Down

0 comments on commit 73a683d

Please sign in to comment.