Skip to content

Commit

Permalink
Merge pull request #1837 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
discord id added
  • Loading branch information
adnankattekaden authored Dec 18, 2023
2 parents 74c6161 + 8f15a99 commit 71f05be
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 83 deletions.
8 changes: 4 additions & 4 deletions api/dashboard/channels/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ def create(self, validated_data):
validated_data["created_by_id"] = user_id
validated_data["updated_by_id"] = user_id
validated_data["id"] = uuid.uuid4()

return Channel.objects.create(**validated_data)

def update(self, instance, validated_data):
user_id = self.context.get("user_id")

instance.name = validated_data.get("name", instance.name)
instance.discord_id = validated_data.get("discord_id", instance.discord_id)
instance.updated_by_id = user_id
instance.updated_at = DateTimeUtils.get_current_utc_time()
instance.save()
return instance

return instance
2 changes: 1 addition & 1 deletion db/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Meta:
class College(models.Model):
id = models.CharField(primary_key=True, max_length=36, default=uuid.uuid4())
level = models.IntegerField(default=0)
org = models.OneToOneField(Organization, on_delete=models.CASCADE, related_name='college_org', unique=True)
org = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name='college_org', unique=True)
updated_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='updated_by',
related_name='college_updated_by')
updated_at = models.DateTimeField(auto_now=True)
Expand Down
173 changes: 95 additions & 78 deletions db/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,29 @@
from .managers import user_manager
from decouple import config as decouple_config


# fmt: off
# noinspection PyPep8

class User(models.Model):
id = models.CharField(primary_key=True, max_length=36, default=uuid.uuid4)
muid = models.CharField(unique=True, max_length=100)
full_name = models.CharField(max_length=150)
email = models.EmailField(unique=True, max_length=200)
password = models.CharField(max_length=200, blank=True, null=True)
mobile = models.CharField(unique=True, max_length=15, blank=True, null=True)
gender = models.CharField(max_length=10, blank=True, null=True, choices=[("Male", "Male"), ("Female", "Female")])
dob = models.DateField(blank=True, null=True)
admin = models.BooleanField(default=False)
id = models.CharField(primary_key=True, max_length=36, default=uuid.uuid4)
discord_id = models.CharField(unique=True, max_length=36, blank=True, null=True)
muid = models.CharField(unique=True, max_length=100)
full_name = models.CharField(max_length=150)
email = models.EmailField(unique=True, max_length=200)
password = models.CharField(max_length=200, blank=True, null=True)
mobile = models.CharField(unique=True, max_length=15, blank=True, null=True)
gender = models.CharField(max_length=10, blank=True, null=True, choices=[("Male", "Male"), ("Female", "Female")])
dob = models.DateField(blank=True, null=True)
admin = models.BooleanField(default=False)
exist_in_guild = models.BooleanField(default=False)
district = models.ForeignKey("District", on_delete=models.CASCADE, blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True)
suspended_at = models.DateTimeField(blank=True, null=True)
suspended_by = models.ForeignKey("self", on_delete=models.SET(settings.SYSTEM_ADMIN_ID), blank=True, null=True, related_name="user_suspended_by_user", db_column="suspended_by", default=None)
objects = user_manager.ActiveUserManager()
every = models.Manager()
district = models.ForeignKey("District", on_delete=models.CASCADE, blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True)
suspended_at = models.DateTimeField(blank=True, null=True)
suspended_by = models.ForeignKey("self", on_delete=models.SET(settings.SYSTEM_ADMIN_ID), blank=True, null=True,
related_name="user_suspended_by_user", db_column="suspended_by", default=None)
objects = user_manager.ActiveUserManager()
every = models.Manager()

class Meta:
managed = False
Expand All @@ -50,9 +53,10 @@ def save(self, *args, **kwargs):
while User.objects.filter(muid=self.muid).exists():
counter += 1
self.muid = f"{full_name}-{counter}@mulearn"

return super().save(*args, **kwargs)


# class UserMentor(models.Model):
# id = models.CharField(primary_key=True, max_length=36)
# user = models.ForeignKey(User, models.DO_NOTHING)
Expand All @@ -68,43 +72,48 @@ def save(self, *args, **kwargs):
# class Meta:
# managed = False
# db_table = 'user_mentor'

class UserReferralLink(models.Model):
id = models.CharField(primary_key=True, max_length=36, default=uuid.uuid4)
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='user_referral_link_user')
referral = models.ForeignKey(User, on_delete=models.CASCADE, related_name='user_referral_link_referral')
is_coin = models.BooleanField(default=False)
updated_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), related_name='user_referral_link_updated_by', db_column='updated_by')
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), related_name='user_referral_link_created_by', db_column='created_by')
created_at = models.DateTimeField(auto_now_add=True)
id = models.CharField(primary_key=True, max_length=36, default=uuid.uuid4)
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='user_referral_link_user')
referral = models.ForeignKey(User, on_delete=models.CASCADE, related_name='user_referral_link_referral')
is_coin = models.BooleanField(default=False)
updated_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID),
related_name='user_referral_link_updated_by', db_column='updated_by')
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID),
related_name='user_referral_link_created_by', db_column='created_by')
created_at = models.DateTimeField(auto_now_add=True)

class Meta:
managed = False
db_table = 'user_referral_link'


class Role(models.Model):
id = models.CharField(primary_key=True, max_length=36)
title = models.CharField(max_length=75)
description = models.CharField(max_length=300, blank=True, null=True)
updated_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='updated_by', related_name='role_updated_by')
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='created_by', related_name='role_created_by')
created_at = models.DateTimeField(auto_now_add=True)
id = models.CharField(primary_key=True, max_length=36)
title = models.CharField(max_length=75)
description = models.CharField(max_length=300, blank=True, null=True)
updated_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='updated_by',
related_name='role_updated_by')
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='created_by',
related_name='role_created_by')
created_at = models.DateTimeField(auto_now_add=True)

class Meta:
managed = False
db_table = 'role'


class UserRoleLink(models.Model):
id = models.CharField(primary_key=True, max_length=36, default=uuid.uuid4)
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='user_role_link_user')
role = models.ForeignKey(Role, on_delete=models.CASCADE)
verified = models.BooleanField(default=False)
created_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='created_by', related_name='user_role_link_created_by')
created_at = models.DateTimeField(auto_now_add=True)
id = models.CharField(primary_key=True, max_length=36, default=uuid.uuid4)
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='user_role_link_user')
role = models.ForeignKey(Role, on_delete=models.CASCADE)
verified = models.BooleanField(default=False)
created_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='created_by',
related_name='user_role_link_created_by')
created_at = models.DateTimeField(auto_now_add=True)

class Meta:
managed = False
Expand All @@ -115,74 +124,82 @@ class Meta:


class Socials(models.Model):
id = models.CharField(primary_key=True, max_length=36, default=uuid.uuid4)
user = models.ForeignKey(User, on_delete=models.CASCADE)
github = models.CharField(max_length=60, blank=True, null=True)
facebook = models.CharField(max_length=60, blank=True, null=True)
instagram = models.CharField(max_length=60, blank=True, null=True)
linkedin = models.CharField(max_length=60, blank=True, null=True)
dribble = models.CharField(max_length=60, blank=True, null=True)
behance = models.CharField(max_length=60, blank=True, null=True)
stackoverflow = models.CharField(max_length=60, blank=True, null=True)
medium = models.CharField(max_length=60, blank=True, null=True)
hackerrank = models.CharField(max_length=60, blank=True, null=True)
created_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='created_by', related_name='socials_created_by')
updated_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='updated_by', related_name='socials_updated_by')
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(blank=True, null=True, auto_now=True)
id = models.CharField(primary_key=True, max_length=36, default=uuid.uuid4)
user = models.ForeignKey(User, on_delete=models.CASCADE)
github = models.CharField(max_length=60, blank=True, null=True)
facebook = models.CharField(max_length=60, blank=True, null=True)
instagram = models.CharField(max_length=60, blank=True, null=True)
linkedin = models.CharField(max_length=60, blank=True, null=True)
dribble = models.CharField(max_length=60, blank=True, null=True)
behance = models.CharField(max_length=60, blank=True, null=True)
stackoverflow = models.CharField(max_length=60, blank=True, null=True)
medium = models.CharField(max_length=60, blank=True, null=True)
hackerrank = models.CharField(max_length=60, blank=True, null=True)
created_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='created_by',
related_name='socials_created_by')
updated_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='updated_by',
related_name='socials_updated_by')
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(blank=True, null=True, auto_now=True)

class Meta:
managed = False
db_table = 'socials'


class ForgotPassword(models.Model):
id = models.CharField(primary_key=True, max_length=36)
user = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID))
expiry = models.DateTimeField()
created_at = models.DateTimeField(auto_now_add=True)
id = models.CharField(primary_key=True, max_length=36)
user = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID))
expiry = models.DateTimeField()
created_at = models.DateTimeField(auto_now_add=True)

class Meta:
managed = False
db_table = 'forgot_password'


class UserSettings(models.Model):
id = models.CharField(primary_key=True, max_length=36, default=uuid.uuid4)
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="user_settings_user")
is_public = models.BooleanField(default=False)
updated_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='updated_by', related_name='user_settings_updated_by')
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='created_by', related_name='user_settings_created_by')
created_at = models.DateTimeField(auto_now_add=True)
id = models.CharField(primary_key=True, max_length=36, default=uuid.uuid4)
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="user_settings_user")
is_public = models.BooleanField(default=False)
updated_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='updated_by',
related_name='user_settings_updated_by')
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='created_by',
related_name='user_settings_created_by')
created_at = models.DateTimeField(auto_now_add=True)

class Meta:
managed = False
db_table = 'user_settings'


class DynamicRole(models.Model):
id = models.CharField(primary_key=True, max_length=36)
type = models.CharField(max_length=50)
role = models.ForeignKey(Role, on_delete=models.CASCADE, db_column='role', related_name='dynamic_role_role')
updated_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='updated_by', related_name='dynamic_role_updated_by')
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='created_by', related_name='dynamic_role_created_by')
created_at = models.DateTimeField(auto_now_add=True)
id = models.CharField(primary_key=True, max_length=36)
type = models.CharField(max_length=50)
role = models.ForeignKey(Role, on_delete=models.CASCADE, db_column='role', related_name='dynamic_role_role')
updated_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='updated_by',
related_name='dynamic_role_updated_by')
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='created_by',
related_name='dynamic_role_created_by')
created_at = models.DateTimeField(auto_now_add=True)

class Meta:
managed = False
db_table = 'dynamic_role'


class DynamicUser(models.Model):
id = models.CharField(primary_key=True, max_length=36)
type = models.CharField(max_length=50)
user = models.ForeignKey('User', on_delete=models.CASCADE, related_name='dynamic_user_user')
updated_by = models.ForeignKey('User', on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='updated_by', related_name='dynamic_user_updated_by')
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey('User', on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='created_by', related_name='dynamic_user_created_by')
created_at = models.DateTimeField(auto_now_add=True)
id = models.CharField(primary_key=True, max_length=36)
type = models.CharField(max_length=50)
user = models.ForeignKey('User', on_delete=models.CASCADE, related_name='dynamic_user_user')
updated_by = models.ForeignKey('User', on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='updated_by',
related_name='dynamic_user_updated_by')
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey('User', on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='created_by',
related_name='dynamic_user_created_by')
created_at = models.DateTimeField(auto_now_add=True)

class Meta:
managed = False
Expand Down

0 comments on commit 71f05be

Please sign in to comment.