177 lines
8.1 KiB
Python
177 lines
8.1 KiB
Python
|
from django.db import models
|
||
|
from django.contrib.auth.models import User
|
||
|
import uuid
|
||
|
from institutional.models import CorporateUser
|
||
|
import json
|
||
|
|
||
|
class ResetOTP(models.Model):
|
||
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||
|
otp = models.CharField(max_length=10, blank=True,null = True,unique=True)
|
||
|
uid = models.CharField(max_length=100, blank=True,null = True,unique=True)
|
||
|
|
||
|
|
||
|
class Meta:
|
||
|
ordering = ['-id']
|
||
|
|
||
|
def __str__(self):
|
||
|
return f"otp for {self.user}"
|
||
|
|
||
|
|
||
|
|
||
|
class ReferUser(models.Model):
|
||
|
id = models.CharField(primary_key=True, default=uuid.uuid4, editable=False,max_length=36)
|
||
|
user = models.OneToOneField(User, on_delete=models.CASCADE, null=True)
|
||
|
non_auth_user_email = models.CharField(max_length=100, blank=True, null=True)
|
||
|
referId = models.CharField(max_length=100, blank=True)
|
||
|
refferedBy = models.CharField(max_length=100, blank=True)
|
||
|
totalRefferals = models.IntegerField(default=0)
|
||
|
reffered_by = models.ForeignKey(
|
||
|
User, on_delete=models.CASCADE, blank=True, null=True, related_name="ref_by"
|
||
|
)
|
||
|
|
||
|
# def __str__(self):
|
||
|
# return str(self.referId)
|
||
|
|
||
|
# class privilegedUser1(models.Model):
|
||
|
# # id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||
|
# id = models.IntegerField(primary_key=True)
|
||
|
# user = models.ForeignKey(User, on_delete=models.CASCADE,null=True)
|
||
|
# rmuser = models.IntegerField(blank=True, null=True)
|
||
|
# is_active = models.CharField(
|
||
|
# max_length=100, blank=True, default="") # yes/no
|
||
|
# dateSubscribed = models.DateTimeField(auto_now=True)
|
||
|
# transactionId = models.CharField(max_length=100, blank=True, default="")
|
||
|
# chargeId = models.CharField(max_length=100, blank=True, default="")
|
||
|
# razorpaySign = models.CharField(max_length=100, blank=True, default="")
|
||
|
# # normal, yearly, Life Member
|
||
|
# memberType = models.CharField(max_length=100, blank=True, default="")
|
||
|
# months = models.IntegerField(default=0)
|
||
|
# amount_captured = models.CharField(max_length=100, blank=True, default="")
|
||
|
# amount_refunded = models.CharField(max_length=100, blank=True, default="")
|
||
|
# application = models.CharField(max_length=100, blank=True, default="")
|
||
|
# application_fee_amount = models.CharField(
|
||
|
# max_length=100, blank=True, default="")
|
||
|
# city = models.CharField(max_length=100, blank=True, default="")
|
||
|
# country = models.CharField(max_length=100, blank=True, default="")
|
||
|
# line1 = models.CharField(max_length=100, blank=True, default="")
|
||
|
# line2 = models.CharField(max_length=100, blank=True, default="")
|
||
|
# postal_code = models.CharField(max_length=100, blank=True, default="")
|
||
|
# state = models.CharField(max_length=100, blank=True, default="")
|
||
|
# email = models.CharField(max_length=100, blank=True, default="")
|
||
|
# name = models.CharField(max_length=100, blank=True, default="")
|
||
|
# phone = models.CharField(max_length=100, blank=True, default="")
|
||
|
# currency = models.CharField(max_length=100, blank=True, default="")
|
||
|
# created = models.CharField(max_length=100, blank=True, default="")
|
||
|
# customer = models.CharField(max_length=100, blank=True, default="")
|
||
|
# invoice = models.CharField(max_length=100, blank=True, default="")
|
||
|
# paid = models.CharField(max_length=100, blank=True, default="")
|
||
|
# card_brand = models.CharField(max_length=100, blank=True, default="")
|
||
|
# card_country = models.CharField(max_length=100, blank=True, default="")
|
||
|
# card_exp = models.CharField(max_length=100, blank=True, default="")
|
||
|
# card_funding = models.CharField(max_length=100, blank=True, default="")
|
||
|
# receipt_email = models.CharField(max_length=100, blank=True, default="")
|
||
|
# receipt_url = models.CharField(max_length=100, blank=True, default="")
|
||
|
# status = models.CharField(max_length=100, blank=True, default="")
|
||
|
|
||
|
class UserCredentialsForBlockchain(models.Model):
|
||
|
blockChain_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||
|
privateKey = models.CharField(max_length=1000, blank=True, null=True)
|
||
|
publicKey = models.CharField(max_length=1000, blank=True, null=True)
|
||
|
transaction_hash = models.CharField(max_length=1000, blank=True, null=True)
|
||
|
|
||
|
|
||
|
|
||
|
class Institutional_user(models.Model):
|
||
|
id = models.IntegerField(primary_key=True)
|
||
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||
|
"""
|
||
|
name , email will be saved in User model which is inherited from Django structure
|
||
|
"""
|
||
|
|
||
|
# normal , admin , student , corporate_admin
|
||
|
user_role = models.CharField(default="normal", max_length=15)
|
||
|
|
||
|
# Institute = models.ForeignKey(Institute, on_delete=models.CASCADE)
|
||
|
|
||
|
is_admin = models.BooleanField(default=True)
|
||
|
|
||
|
plans = models.CharField(max_length=30, blank=True, null=True)
|
||
|
registered_date = models.DateTimeField(auto_now_add=True)
|
||
|
# month and year will be registered, not date
|
||
|
passing_date = models.DateField(null=True, blank=True)
|
||
|
document1 = models.FileField(
|
||
|
upload_to="kycdocument/", blank=True, null=True) # front ID
|
||
|
document2 = models.FileField(
|
||
|
upload_to="kycdocument/", blank=True, null=True) # back ID
|
||
|
# verified/registred/active/banned/fraud
|
||
|
status = models.CharField(max_length=20, null=True, blank=True)
|
||
|
isactive = models.BooleanField(default=False)
|
||
|
credits = models.IntegerField(default=0)
|
||
|
activated_date = models.DateTimeField(auto_now_add=True)
|
||
|
license_required = models.IntegerField(null=True, blank=True)
|
||
|
list_users = models.TextField(default="", null=True, blank=True)
|
||
|
phonenumber = models.CharField(max_length=100, blank=True, null=True)
|
||
|
phonenumber2 = models.CharField(max_length=100, blank=True, null=True)
|
||
|
email = models.CharField(max_length=100, blank=True, null=True)
|
||
|
email2 = models.CharField(max_length=100, blank=True, null=True)
|
||
|
billing_limit = models.IntegerField(null=True, blank=True)
|
||
|
# custom domain set by Admin only after its verification for Student Verification.
|
||
|
custom_domain = models.CharField(max_length=100, blank=True, null=True)
|
||
|
|
||
|
def set_list_user(self, x):
|
||
|
self.list_users = json.dumps(x)
|
||
|
|
||
|
def get_list_user(self):
|
||
|
return json.loads(self.list_users)
|
||
|
|
||
|
|
||
|
|
||
|
class Certificate(models.Model):
|
||
|
user_name = models.CharField(max_length=100)
|
||
|
id = models.IntegerField(primary_key=True)
|
||
|
|
||
|
class BlockchainUserInfo(models.Model):
|
||
|
# user_id = models.IntegerField()
|
||
|
blockchain_user_info_uuid = models.UUIDField(
|
||
|
primary_key=True, default=uuid.uuid4, editable=False
|
||
|
)
|
||
|
coprate_user = models.ForeignKey(CorporateUser, on_delete=models.CASCADE,blank=True, null=True)
|
||
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||
|
user_name = models.CharField(max_length=100,blank=True, null=True)
|
||
|
tx_hash = models.CharField(max_length=100,blank=True, null=True)
|
||
|
service = models.CharField(max_length=100,blank=True, null=True)
|
||
|
gas_fee = models.IntegerField(max_length=100)
|
||
|
script_name = models.CharField(max_length=100,blank=True, null=True)
|
||
|
uploaded_by = models.CharField(max_length=100,blank=True, null=True)
|
||
|
upload_date = models.DateField(auto_now_add=True)
|
||
|
date_at = models.DateTimeField(auto_now_add=True)
|
||
|
|
||
|
|
||
|
class Wallet(models.Model):
|
||
|
id = models.IntegerField(primary_key=True)
|
||
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||
|
balance = models.FloatField(null=True, blank=True, default=0.0)
|
||
|
mm_balance = models.FloatField(null=True, blank=True, default=0.0)
|
||
|
lpp_balance = models.FloatField(null=True, blank=True, default=0.0)
|
||
|
im_balance = models.FloatField(null=True, blank=True, default=0.0)
|
||
|
active_list = models.TextField(default="[]", null=True, blank=True)
|
||
|
|
||
|
available = models.IntegerField(default=0)
|
||
|
mature_date = models.DateField(auto_now=True)
|
||
|
|
||
|
def set_active_list(self, x):
|
||
|
self.active_list = json.dumps(x)
|
||
|
|
||
|
def get_active_list(self):
|
||
|
return json.loads(self.active_list)
|
||
|
|
||
|
def is_active(self):
|
||
|
if(("MM" in self.active_list) or ("LPP" in self.active_list)):
|
||
|
return True
|
||
|
else:
|
||
|
return False
|
||
|
|
||
|
def __str__(self):
|
||
|
return str(self.user)
|