From 96fb3f4d21d37d77688f5ede254ee788cf3ab412 Mon Sep 17 00:00:00 2001 From: Hrishabh Tiwari Date: Mon, 14 Oct 2024 18:55:00 +0530 Subject: [PATCH 1/5] feat: add qbd di flag --- apps/orgs/models.py | 3 ++- apps/orgs/serializers.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/orgs/models.py b/apps/orgs/models.py index e61239a..171b23a 100644 --- a/apps/orgs/models.py +++ b/apps/orgs/models.py @@ -21,8 +21,9 @@ class Org(models.Model): allow_travelperk = models.BooleanField(default=True, help_text='Allow Travelperk') allow_gusto = models.BooleanField(default=False, help_text='Allow Gusto') allow_dynamics = models.BooleanField(default=False, help_text='Allow Dynamics') + allow_qbd_direct_integration = models.BooleanField(default=False, help_text='Allow QBD Direct Integration') created_at = models.DateTimeField(auto_now_add=True, help_text='Created at datetime') - updated_at = models.DateTimeField(auto_now=True, help_text='Updated at datetime') + updated_at = models.DateTimeField(auto_now=True, help_text='Updated at datetime') class Meta: db_table = 'orgs' diff --git a/apps/orgs/serializers.py b/apps/orgs/serializers.py index 055ce8c..a68e69f 100644 --- a/apps/orgs/serializers.py +++ b/apps/orgs/serializers.py @@ -49,7 +49,8 @@ def update(self, instance, validated): else: auth_tokens = AuthToken.objects.get(user__user_id=self.context['request'].user) cluster_domain = get_cluster_domain(auth_tokens.refresh_token) - org = Org.objects.create(name=org_name, fyle_org_id=org_id, cluster_domain=cluster_domain) + allow_qbd_direct_integration = validated.get('allow_qbd_direct_integration', False) + org = Org.objects.create(name=org_name, fyle_org_id=org_id, cluster_domain=cluster_domain, allow_qbd_direct_integration=allow_qbd_direct_integration) org.user.add(User.objects.get(user_id=self.context['request'].user)) FyleCredential.objects.update_or_create( From b6a7d5ea626277ff62ace1491108a7843fb5ac7f Mon Sep 17 00:00:00 2001 From: Hrishabh Tiwari Date: Mon, 14 Oct 2024 19:02:11 +0530 Subject: [PATCH 2/5] rename docker-compose --- .github/workflows/codecov.yml | 6 +++--- .github/workflows/pytest.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index a04be25..d89c2f5 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -15,9 +15,9 @@ jobs: - uses: actions/checkout@v2 - name: Bring up Services and Run Tests run: | - docker-compose -f docker-compose-pipeline.yml build - docker-compose -f docker-compose-pipeline.yml up -d - docker-compose -f docker-compose-pipeline.yml exec -T api pytest tests/ --cov --cov-report=xml --cov-fail-under=94 + docker compose -f docker-compose-pipeline.yml build + docker compose -f docker-compose-pipeline.yml up -d + docker compose -f docker-compose-pipeline.yml exec -T api pytest tests/ --cov --cov-report=xml --cov-fail-under=94 echo "STATUS=$(cat pytest-coverage.txt | grep 'Required test' | awk '{ print $1 }')" >> $GITHUB_ENV echo "FAILED=$(cat test-reports/report.xml | awk -F'=' '{print $5}' | awk -F' ' '{gsub(/"/, "", $1); print $1}')" >> $GITHUB_ENV - name: Upload coverage reports to Codecov with GitHub Action diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 6404822..057e631 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -12,9 +12,9 @@ jobs: - uses: actions/checkout@v2 - name: Bring up Services and Run Tests run: | - docker-compose -f docker-compose-pipeline.yml build - docker-compose -f docker-compose-pipeline.yml up -d - docker-compose -f docker-compose-pipeline.yml exec -T api pytest tests/ --cov --cov-report=xml --junit-xml=test-reports/report.xml --cov-fail-under=60 + docker compose -f docker-compose-pipeline.yml build + docker compose -f docker-compose-pipeline.yml up -d + docker compose -f docker-compose-pipeline.yml exec -T api pytest tests/ --cov --cov-report=xml --junit-xml=test-reports/report.xml --cov-fail-under=60 echo "STATUS=$(cat pytest-coverage.txt | grep 'Required test' | awk '{ print $1 }')" >> $GITHUB_ENV echo "FAILED=$(cat test-reports/report.xml | awk -F'=' '{print $5}' | awk -F' ' '{gsub(/"/, "", $1); print $1}')" >> $GITHUB_ENV - name: Upload coverage reports to Codecov with GitHub Action From f0e8de05fd1aeded8bc022a130215958a68217b0 Mon Sep 17 00:00:00 2001 From: Hrishabh Tiwari Date: Mon, 14 Oct 2024 19:13:45 +0530 Subject: [PATCH 3/5] fix failing tests --- tests/test_orgs/fixtures.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_orgs/fixtures.py b/tests/test_orgs/fixtures.py index 7766f73..28d8cde 100644 --- a/tests/test_orgs/fixtures.py +++ b/tests/test_orgs/fixtures.py @@ -55,6 +55,7 @@ "allow_travelperk": False, "allow_gusto": False, "allow_dynamics": False, + "allow_qbd_direct_integration": False, "user":[ 2 ] From 41128fb2e103f4b24f76f00e92c52f58829e4021 Mon Sep 17 00:00:00 2001 From: Hrishabh Tiwari Date: Mon, 14 Oct 2024 21:00:10 +0530 Subject: [PATCH 4/5] remove qbd di flag from serializer --- apps/orgs/serializers.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/orgs/serializers.py b/apps/orgs/serializers.py index a68e69f..055ce8c 100644 --- a/apps/orgs/serializers.py +++ b/apps/orgs/serializers.py @@ -49,8 +49,7 @@ def update(self, instance, validated): else: auth_tokens = AuthToken.objects.get(user__user_id=self.context['request'].user) cluster_domain = get_cluster_domain(auth_tokens.refresh_token) - allow_qbd_direct_integration = validated.get('allow_qbd_direct_integration', False) - org = Org.objects.create(name=org_name, fyle_org_id=org_id, cluster_domain=cluster_domain, allow_qbd_direct_integration=allow_qbd_direct_integration) + org = Org.objects.create(name=org_name, fyle_org_id=org_id, cluster_domain=cluster_domain) org.user.add(User.objects.get(user_id=self.context['request'].user)) FyleCredential.objects.update_or_create( From 6679a855cca9cea18f403cb397a47723eeb60e8e Mon Sep 17 00:00:00 2001 From: Hrishabh Tiwari Date: Mon, 14 Oct 2024 21:10:39 +0530 Subject: [PATCH 5/5] Add migration file --- .../0006_org_allow_qbd_direct_integration.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 apps/orgs/migrations/0006_org_allow_qbd_direct_integration.py diff --git a/apps/orgs/migrations/0006_org_allow_qbd_direct_integration.py b/apps/orgs/migrations/0006_org_allow_qbd_direct_integration.py new file mode 100644 index 0000000..3d638f1 --- /dev/null +++ b/apps/orgs/migrations/0006_org_allow_qbd_direct_integration.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.14 on 2024-10-14 15:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('orgs', '0005_add_allow_dynamics'), + ] + + operations = [ + migrations.AddField( + model_name='org', + name='allow_qbd_direct_integration', + field=models.BooleanField(default=False, help_text='Allow QBD Direct Integration'), + ), + ]