Skip to content

Commit

Permalink
Merge pull request #60 from Build-Squad/GEN-97-Twitter-Account-Detail…
Browse files Browse the repository at this point in the history
…s-API

Get Twitter Account API
  • Loading branch information
Parikshit85 authored Jan 3, 2024
2 parents 70dc833 + 992df3f commit 87c8db0
Show file tree
Hide file tree
Showing 10 changed files with 283 additions and 46 deletions.
28 changes: 28 additions & 0 deletions src/api/marketplace/accounts/migrations/0009_accountlanguage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.2.7 on 2024-01-02 11:54

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

dependencies = [
('core', '0003_languagemaster_delete_language'),
('accounts', '0008_rename_walletproider_walletprovider'),
]

operations = [
migrations.CreateModel(
name='AccountLanguage',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name='Account Language ID')),
('language', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='acc_language_master_id', to='core.languagemaster')),
('user_account', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='acc_user_account_id', to=settings.AUTH_USER_MODEL)),
],
options={
'db_table': 'account_language',
},
),
]
16 changes: 14 additions & 2 deletions src/api/marketplace/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.db import models
from django.contrib.auth.models import AbstractUser
from django.db.models import SET_NULL
from core.models import Currency
from core.models import Currency, LanguageMaster
from core.models import Country
import uuid

Expand Down Expand Up @@ -49,7 +49,7 @@ class AccountCategory(models.Model):
null=True)

class Meta:
db_table = "account_category"
db_table = "account_category"


class Role(models.Model):
Expand Down Expand Up @@ -97,6 +97,18 @@ class Meta:
def __str__(self):
return self.username


class AccountLanguage(models.Model):
id = models.UUIDField(primary_key=True, verbose_name='Account Language ID', default=uuid.uuid4, editable=False)
user_account = models.ForeignKey(User, related_name='acc_user_account_id', on_delete=SET_NULL,
null=True)
language = models.ForeignKey(LanguageMaster, related_name='acc_language_master_id', on_delete=SET_NULL,
null=True)

class Meta:
db_table = "account_language"


class BankAccount(models.Model):

id = models.UUIDField(
Expand Down
12 changes: 11 additions & 1 deletion src/api/marketplace/accounts/serializers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from unicodedata import category
from rest_framework import serializers
from uuid import UUID
from .models import TwitterAccount, CategoryMaster, AccountCategory, User, BankAccount, Role

from core.serializers import LanguageMasterSerializer
from .models import AccountLanguage, TwitterAccount, CategoryMaster, AccountCategory, User, BankAccount, Role

class CategoryMasterSerializer(serializers.ModelSerializer):
class Meta:
Expand Down Expand Up @@ -60,9 +62,17 @@ class Meta:
fields = "__all__"


class AccountLanguageSerializer(serializers.ModelSerializer):
language = LanguageMasterSerializer(read_only=True)

class Meta:
model = AccountLanguage
fields = "__all__"

class UserSerializer(serializers.ModelSerializer):
twitter_account = TwitterAccountSerializer(read_only=True)
role = RoleSerializer(read_only=True)
account_languages = AccountLanguageSerializer(many=True, read_only=True, source='acc_user_account_id')

class Meta:
model = User
Expand Down
Loading

0 comments on commit 87c8db0

Please sign in to comment.