From 38487809f3d830e1e092897e878121c7ea614eef Mon Sep 17 00:00:00 2001 From: jelanmathewjames Date: Thu, 20 Jun 2024 22:03:10 +0530 Subject: [PATCH 1/3] refactor: Update ListParticipantsAPI and LaunchpadParticipantsSerializer to allow null and blank values for certain fields --- api/launchpad/launchpad_views.py | 4 +--- api/launchpad/serializers.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/api/launchpad/launchpad_views.py b/api/launchpad/launchpad_views.py index 8a9527ca..d36740a2 100644 --- a/api/launchpad/launchpad_views.py +++ b/api/launchpad/launchpad_views.py @@ -101,9 +101,7 @@ def get(self, request): district_name=F("user_organization_link_user__org__district__name"), state=F("user_organization_link_user__org__district__zone__state__name"), level=F("user_role_link_user__role__title"), - time_=Max("karma_activity_log_user__created_at"), - ).filter( - level__in=allowed_levels + time_=Max("karma_activity_log_user__created_at") ).distinct() paginated_queryset = CommonUtils.get_paginated_queryset( diff --git a/api/launchpad/serializers.py b/api/launchpad/serializers.py index 92386593..0fe5bdf5 100644 --- a/api/launchpad/serializers.py +++ b/api/launchpad/serializers.py @@ -72,7 +72,7 @@ class LaunchpadParticipantsSerializer(serializers.ModelSerializer): org = serializers.CharField(allow_null=True, allow_blank=True) district_name = serializers.CharField(allow_null=True, allow_blank=True) state = serializers.CharField(allow_null=True, allow_blank=True) - level = serializers.CharField() + level = serializers.CharField(allow_null=True, allow_blank=True) class Meta: model = User From a4dae2e43a5c4aff9f875e45f6d760684bc7d888 Mon Sep 17 00:00:00 2001 From: ParthipPR Date: Sat, 22 Jun 2024 14:08:12 +0530 Subject: [PATCH 2/3] "fix: Donation Bug Fix " --- api/donate/donate_serializer.py | 3 ++- api/donate/views.py | 12 +++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/api/donate/donate_serializer.py b/api/donate/donate_serializer.py index 3ce7e743..c9d9d5fb 100644 --- a/api/donate/donate_serializer.py +++ b/api/donate/donate_serializer.py @@ -8,10 +8,11 @@ class DonorSerializer(serializers.ModelSerializer): + currency = serializers.CharField(allow_null=True, allow_blank=True, default='INR') class Meta: model = Donor - exclude = ['created_by', 'created_at', 'id'] + exclude = ['created_by', 'created_at', 'id', 'payment_id', 'payment_method'] def create(self, validated_data): validated_data["created_by_id"] = settings.SYSTEM_ADMIN_ID diff --git a/api/donate/views.py b/api/donate/views.py index e5705727..ef32bd7c 100644 --- a/api/donate/views.py +++ b/api/donate/views.py @@ -103,10 +103,8 @@ def post(self, request): request.data.get("razorpay_payment_id") ) transaction_details = { - "Payment ID": data['id'], - "Payment Method": data['method'], "Amount": float(data['amount']) / 100, - "Currency": data['currency'], + "Currency": data['currency', None], "Name": data['notes']['name'], "Email": data['notes']['email'], } @@ -115,12 +113,12 @@ def post(self, request): if extra_data := data['notes'].get('phone_number', None): transaction_details["Phone Number"] = extra_data if extra_data := data['notes'].get('pan_number', None): - transaction_details["PAN number"] = extra_data + transaction_details["PAN number"] = extra_data serializer = DonorSerializer(data=data['notes']['validated_data']) - # if serializer.is_valid(): - # serializer.save() + if serializer.is_valid(): + serializer.save() return create_receipt(transaction_details) except razorpay.errors.SignatureVerificationError as e: - return CustomResponse(message=str(e)).get_failure_response() + return CustomResponse(general_message = "Payment Verification Failed").get_failure_response() From f593bb164736e678158b7ac0bd89ef6e4f5a5d08 Mon Sep 17 00:00:00 2001 From: jelanmathewjames <72068016+jelanmathewjames@users.noreply.github.com> Date: Sat, 22 Jun 2024 14:37:40 +0530 Subject: [PATCH 3/3] Update launchpad_views.py --- api/launchpad/launchpad_views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/launchpad/launchpad_views.py b/api/launchpad/launchpad_views.py index d36740a2..d757732b 100644 --- a/api/launchpad/launchpad_views.py +++ b/api/launchpad/launchpad_views.py @@ -102,6 +102,8 @@ def get(self, request): state=F("user_organization_link_user__org__district__zone__state__name"), level=F("user_role_link_user__role__title"), time_=Max("karma_activity_log_user__created_at") + ).filter( + Q(level__in=allowed_levels) | Q(level__isnull=True) ).distinct() paginated_queryset = CommonUtils.get_paginated_queryset( @@ -429,4 +431,4 @@ def post(self, request): errors[data.get('email')]["not_found_colleges"] = not_found_colleges if error: return CustomResponse(message=errors).get_failure_response() - return CustomResponse(general_message="Successfully added users").get_success_response() \ No newline at end of file + return CustomResponse(general_message="Successfully added users").get_success_response()