Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	api/dashboard/lc/dash_lc_view.py
  • Loading branch information
aashishvinu committed Nov 16, 2023
2 parents faf62e7 + 7d89a4c commit 4b7681b
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 17 deletions.
2 changes: 1 addition & 1 deletion api/dashboard/lc/dash_lc_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def update(self, instance, validated_data):
return instance


class LearningCircleCreateEditDeleteSerializer(serializers.ModelSerializer):
class ScheduleMeetingSerializer(serializers.ModelSerializer):
class Meta:
model = LearningCircle
fields = [
Expand Down
1 change: 1 addition & 0 deletions api/dashboard/lc/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
path('list-all/', dash_lc_view.TotalLearningCircleListApi.as_view()),
path('create/', dash_lc_view.LearningCircleCreateApi.as_view()),
path('list-members/<str:circle_id>/', dash_lc_view.LearningCircleListMembersApi.as_view()),
path('schedule-meet/<str:circle_id>/', dash_lc_view.ScheduleMeetAPI.as_view()),
# path('invite/', dash_lc_view.LearningCircleInviteLeadAPI.as_view()),
path('list-all/<str:circle_code>/', dash_lc_view.TotalLearningCircleListApi.as_view()),
path('join/<str:circle_id>/', dash_lc_view.LearningCircleJoinApi.as_view()),
Expand Down
6 changes: 3 additions & 3 deletions api/dashboard/location/location_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class StateCreateEditSerializer(serializers.ModelSerializer):
# value = serializers.CharField(source="id")
class Meta:
model = State
fields = ["label", "created_by", "updated_by"]
fields = ["label", "country", "created_by", "updated_by"]


class ZoneRetrievalSerializer(serializers.ModelSerializer):
Expand Down Expand Up @@ -92,7 +92,7 @@ class ZoneCreateEditSerializer(serializers.ModelSerializer):

class Meta:
model = Zone
fields = ["label", "created_by", "updated_by"]
fields = ["label", "state", "created_by", "updated_by"]


class DistrictRetrievalSerializer(serializers.ModelSerializer):
Expand Down Expand Up @@ -129,4 +129,4 @@ class DistrictCreateEditSerializer(serializers.ModelSerializer):

class Meta:
model = District
fields = ["label", "created_by", "updated_by"]
fields = ["label", "zone","created_by", "updated_by"]
14 changes: 6 additions & 8 deletions api/dashboard/location/location_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ class StateDataAPI(APIView):
@role_required([RoleType.ADMIN.value])
def get(self, request, state_id=None):
if state_id:
states = State.objects.filter(pk=state_id).select_related("country", "created_by", "updated_by")
states = State.objects.filter(pk=state_id).select_related(
"country", "created_by", "updated_by"
)
else:
states = State.objects.all().select_related(
"country", "created_by", "updated_by"
Expand Down Expand Up @@ -129,9 +131,7 @@ def patch(self, request, state_id):

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

return CustomResponse(
general_message="State edited successfully"
).get_failure_response()
return CustomResponse(general_message=serializer.errors).get_failure_response()

@role_required([RoleType.ADMIN.value])
def delete(self, request, state_id):
Expand Down Expand Up @@ -217,7 +217,7 @@ class DistrictDataAPI(APIView):
def get(self, request, district_id=None):
if district_id:
districts = District.objects.filter(pk=district_id)

else:
districts = District.objects.all().select_related(
"zone",
Expand Down Expand Up @@ -254,9 +254,7 @@ def post(self, request):

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

return CustomResponse(
general_message="Zone created successfully"
).get_failure_response()
return CustomResponse(general_message=serializer.errors).get_failure_response()

@role_required([RoleType.ADMIN.value])
def patch(self, request, district_id):
Expand Down
42 changes: 41 additions & 1 deletion api/dashboard/task/dash_task_serializer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import uuid
from rest_framework import serializers

from db.task import TaskList, KarmaActivityLog
from db.task import TaskList, KarmaActivityLog, TaskType
from utils.permission import JWTUtils
from utils.utils import DateTimeUtils


class TaskListSerializer(serializers.ModelSerializer):
Expand Down Expand Up @@ -100,3 +103,40 @@ class Meta:
"created_at",
"updated_at",
]

class TasktypeSerializer(serializers.ModelSerializer):
updated_by=serializers.CharField(source='updated_by.fullname')
created_by=serializers.CharField(source='created_by.fullname')

class Meta:
model = TaskType
fields = ["id", "title","updated_by","updated_at","created_by","created_at"]

class TaskTypeCreateUpdateSerializer(serializers.ModelSerializer):

class Meta:
model=TaskType
fields=["title"]

def create(self, validated_data):
user_id = self.context.get("user_id")
return TaskType.objects.create(
id=uuid.uuid4(),
title=validated_data.get("title"),
updated_by_id=user_id,
updated_at=DateTimeUtils.get_current_utc_time(),
created_by_id=user_id,
created_at=DateTimeUtils.get_current_utc_time(),
)
def update(self, instance, validated_data):
updated_title = validated_data.get("title")
instance.title = updated_title
user_id = JWTUtils.fetch_user_id(self.context.get("request"))
instance.updated_by_id = user_id
instance.updated_at=DateTimeUtils.get_current_utc_time(),
instance.save()
return instance




65 changes: 64 additions & 1 deletion api/dashboard/task/dash_task_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
TaskImportSerializer,
TaskListSerializer,
TaskModifySerializer,
TaskTypeCreateUpdateSerializer,
TasktypeSerializer,
)

from openpyxl import load_workbook
Expand Down Expand Up @@ -535,4 +537,65 @@ def get(self, request):
with open(tmp.name, 'rb') as f:
f.seek(0)
new_file_object = f.read()
return FileResponse(BytesIO(new_file_object), as_attachment=True, filename='task_base_template.xlsx')
return FileResponse(BytesIO(new_file_object), as_attachment=True, filename='task_base_template.xlsx')

class TaskTypeCrudAPI(APIView):
authentication_classes = [CustomizePermission]
@role_required(
[
RoleType.ADMIN.value,
]
)
def get(self,request):
taskType=TaskType.objects.all()
paginated_queryset = CommonUtils.get_paginated_queryset(
taskType, request, [ "title"],{"title":"title","updated_by":"updated_by","created_by":"created_by","updated_at":"updated_at","created_at":"created_at"}
)
serializer = TasktypeSerializer(
paginated_queryset.get("queryset"), many=True
)

return CustomResponse().paginated_response(
data=serializer.data, pagination=paginated_queryset.get("pagination")
)

@role_required([RoleType.ADMIN.value])
def post(self, request):
user_id = JWTUtils.fetch_user_id(request)
serializer = TaskTypeCreateUpdateSerializer(
data=request.data, context={"user_id": user_id}
)
if serializer.is_valid():
serializer.save()
return CustomResponse(
general_message="Task type added successfully"
).get_success_response()

return CustomResponse(general_message=serializer.errors).get_failure_response()

@role_required([RoleType.ADMIN.value])
def delete(self, request, task_type_id):
taskType = TaskType.objects.filter(id=task_type_id).first()
if taskType is None:
return CustomResponse(
general_message="task type doesnt exist"
).get_failure_response()
taskType.delete()
return CustomResponse(
general_message=f"{taskType.title} Deleted Successfully"
).get_success_response()

@role_required([RoleType.ADMIN.value])
def put(self, request, task_type_id):
taskType = TaskType.objects.filter(id=task_type_id).first()
if taskType is None:
return CustomResponse(general_message="task type not found").get_failure_response()
serializer = TaskTypeCreateUpdateSerializer(
taskType, data=request.data, context={"request": request}
)
if serializer.is_valid():
serializer.save()
return CustomResponse(
general_message=f"{taskType.title} updated successfully"
).get_success_response()
return CustomResponse(response=serializer.errors).get_failure_response()
5 changes: 2 additions & 3 deletions api/dashboard/task/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
path('organization/', dash_task_view.OrganizationDropdownAPI.as_view()),
path('level/', dash_task_view.LevelDropdownAPI.as_view()),
path('task-types/', dash_task_view.TaskTypesDropDownAPI.as_view()),

path('', dash_task_view.TaskListAPI.as_view()), # list task, create
path('csv/', dash_task_view.TaskListCSV.as_view()), # CSV
path('import/', dash_task_view.ImportTaskListCSV.as_view()),
path('base-template/', dash_task_view.TaskBaseTemplateAPI.as_view()),

path('events/', dash_task_view.EventDropDownApi.as_view()),

path('<str:task_id>/', dash_task_view.TaskAPI.as_view()), # get task, edit, delete
path('list-task-type/', dash_task_view.TaskTypeCrudAPI.as_view()), # get tasktype,create tasktype
path('list-task-type/<str:task_type_id>', dash_task_view.TaskTypeCrudAPI.as_view()), #delete,edit

]

0 comments on commit 4b7681b

Please sign in to comment.