-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2076 from gtech-mulearn/dev-server
Prod: feat: Launchpad Dashboard
- Loading branch information
Showing
10 changed files
with
482 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,6 @@ RAZORPAY_SECRET= | |
|
||
PROTECTED_API_KEY = | ||
|
||
SYSTEM_ADMIN_ID = | ||
SYSTEM_ADMIN_ID = | ||
|
||
LAUNCHPAD_ADMIN_EMAIL = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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';") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.