Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prod: feat: Launchpad Dashboard #2076

Merged
merged 24 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cda3600
feat: Add Donor model and DonorSerializer for creating donor objects
jelanmathewjames Jun 12, 2024
432d2b4
Merge branch 'dev' of https://github.com/jelanmathewjames/mulearnback…
jelanmathewjames Jun 12, 2024
5950fa9
Update donor.py
jelanmathewjames Jun 12, 2024
210e49a
Update donate_serializer.py
jelanmathewjames Jun 12, 2024
ed5bf83
Merge branch 'gtech-mulearn:dev' into dev
jelanmathewjames Jun 12, 2024
349e0fe
Update donor.py
jelanmathewjames Jun 12, 2024
91f7a23
refactor: Update Donor model fields to allow null values
jelanmathewjames Jun 12, 2024
cbfbbaa
Merge branch 'gtech-mulearn:dev' into dev
jelanmathewjames Jun 15, 2024
b006f9f
commenting donor tables
jelanmathewjames Jun 16, 2024
cef6fcd
Merge branch 'dev' of https://github.com/jelanmathewjames/mulearnback…
jelanmathewjames Jun 16, 2024
563b95a
Merge branch 'gtech-mulearn:dev' into dev
jelanmathewjames Jun 16, 2024
fcccc0d
Merge pull request #2053 from jelanmathewjames/dev
jelanmathewjames Jun 16, 2024
e7ec797
feat: Launchpad Dashboard
jelanmathewjames Jun 16, 2024
77c6aa3
Refactor serializers.py and donor.py
jelanmathewjames Jun 16, 2024
af84269
Merge branch 'gtech-mulearn:dev' into dev
jelanmathewjames Jun 16, 2024
0be9f58
alter script for creating first launchpad admin user
jelanmathewjames Jun 16, 2024
1a155bf
Merge branch 'dev' of https://github.com/jelanmathewjames/mulearnback…
jelanmathewjames Jun 16, 2024
42b834e
feat: Add API endpoint for user-college-link with user_id parameter
jelanmathewjames Jun 17, 2024
e9ce8ce
Refactor LaunchPadUser and BulkLaunchpadUser views and serializers
jelanmathewjames Jun 17, 2024
e9d104e
chore: Remove unused variables in LaunchPadUser and BulkLaunchpadUser…
jelanmathewjames Jun 17, 2024
5f229a8
feat: Update BulkLaunchpadUser view to use POST method for creating u…
jelanmathewjames Jun 17, 2024
0a2516b
refactor: Remove print statement in BulkLaunchpadUser view
jelanmathewjames Jun 17, 2024
0de9aa7
Merge pull request #2074 from jelanmathewjames/dev
Kochouseph26John Jun 17, 2024
ad0664f
Merge pull request #2075 from gtech-mulearn/dev
Kochouseph26John Jun 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ RAZORPAY_SECRET=

PROTECTED_API_KEY =

SYSTEM_ADMIN_ID =
SYSTEM_ADMIN_ID =

LAUNCHPAD_ADMIN_EMAIL =
35 changes: 35 additions & 0 deletions alter-scripts/alter-1.50.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import os
import sys
import uuid
from decouple import config
import django

from connection import execute

os.chdir('..')
sys.path.append(os.getcwd())
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mulearnbackend.settings')
django.setup()

from db.launchpad import LaunchPadUsers
from utils.types import LaunchPadRoles

def create_launchpad_admin():
query = f"SELECT id FROM launchpad_user WHERE email = '{config('LAUNCHPAD_ADMIN_EMAIL')}'"
if execute(query):
return
query = f"""
INSERT INTO launchpad_user (id, email, role, created_at, updated_at)
VALUES (
'{uuid.uuid4()}',
'{config('LAUNCHPAD_ADMIN_EMAIL')}',
'{LaunchPadRoles.ADMIN.value}',
UTC_TIMESTAMP,
UTC_TIMESTAMP
)
"""
execute(query)

if __name__ == '__main__':
create_launchpad_admin()
execute("UPDATE system_setting SET value = '1.50', updated_at = now() WHERE `key` = 'db.version';")
19 changes: 19 additions & 0 deletions api/donate/donate_serializer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import uuid

from rest_framework import serializers
from django.conf import settings

from db.donor import Donor
from utils.utils import DateTimeUtils


class DonorSerializer(serializers.ModelSerializer):

class Meta:
model = Donor
exclude = ['created_by', 'created_at', 'id']

def create(self, validated_data):
validated_data["created_by_id"] = settings.SYSTEM_ADMIN_ID
validated_data["id"] = uuid.uuid4()
return Donor.objects.create(**validated_data)
36 changes: 27 additions & 9 deletions api/donate/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import razorpay
from io import BytesIO
from reportlab.pdfgen import canvas

from django.http import HttpResponse
from rest_framework.views import APIView

from utils.response import CustomResponse
from .donate_serializer import DonorSerializer
from mulearnbackend.settings import RAZORPAY_ID, RAZORPAY_SECRET

from reportlab.lib.pagesizes import letter
Expand Down Expand Up @@ -65,20 +65,28 @@ def create_receipt(transaction_details):
class RazorPayOrderAPI(APIView):
def post(self, request):
try:
serializer = DonorSerializer(data=request.data)
if not serializer.is_valid():
return CustomResponse(general_message=serializer.errors).get_failure_response()
validated_data = serializer.validated_data

data = {
"amount": int(float(request.data.get("amount")) * 100),
"currency": request.data.get("currency", "INR"),
"amount": int(float(validated_data.get("amount")) * 100),
"currency": validated_data.get("currency"),
"payment_capture": 1,
"notes": {
"email": request.data.get("email"),
"name": request.data.get("name"),
"company": request.data.get("company", None),
"email": validated_data.get("email"),
"name": validated_data.get("name"),
"phone_number": validated_data.get("phone_number", None),
"company": validated_data.get("company", None),
"pan_number": validated_data.get("pan_number", None),
"validated_data": validated_data
},
}
order = razorpay_client.order.create(data)
return CustomResponse(response=order).get_success_response()
except razorpay.errors.BadRequestError as e:
return CustomResponse(message=str(e)).get_error_response()
return CustomResponse(message=str(e)).get_failure_response()


class RazorPayVerification(APIView):
Expand All @@ -101,8 +109,18 @@ def post(self, request):
"Currency": data['currency'],
"Name": data['notes']['name'],
"Email": data['notes']['email'],
"Company": data['notes']['company']
}
if extra_data := data['notes'].get('company', None):
transaction_details["Company"] = extra_data
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

serializer = DonorSerializer(data=data['notes']['validated_data'])
# if serializer.is_valid():
# serializer.save()

return create_receipt(transaction_details)
except razorpay.errors.SignatureVerificationError as e:
return CustomResponse(message=str(e)).get_error_response()
return CustomResponse(message=str(e)).get_failure_response()
Loading
Loading