Skip to content

Commit

Permalink
Adding show_chat_help field on Organization serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
ericosta-dev committed Aug 28, 2024
1 parent 2691cd0 commit 9c98888
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions connect/api/v2/organizations/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Meta:
"is_suspended",
"extra_integration",
"enforce_2fa",
'show_chat_help'
]
ref_name = None

Expand Down Expand Up @@ -73,6 +74,8 @@ class Meta:
),
)

show_chat_help = serializers.SerializerMethodField()

def create(self, validated_data):
# Billing Cycle
# Added for the manager to set the date when new invoice will be generated
Expand Down Expand Up @@ -141,6 +144,11 @@ def publish_create_org_message(self, instance: Organization, user: User):
rabbitmq_publisher = RabbitmqPublisher()
rabbitmq_publisher.send_message(message_body, exchange="orgs.topic", routing_key="")

def get_show_chat_help(self, obj):
if obj.config.get('show_chat_help'):
return True
return obj.authorizations.order_by("created_at").first().user.number_people == 4


class PendingAuthorizationOrganizationSerializer(serializers.ModelSerializer):
class Meta:
Expand Down
23 changes: 23 additions & 0 deletions connect/common/migrations/0085_auto_20240828_1910.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.23 on 2024-08-28 19:10

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('common', '0084_auto_20240710_1828'),
]

operations = [
migrations.AddField(
model_name='organization',
name='config',
field=models.JSONField(default=dict),
),
migrations.AlterField(
model_name='recentactivity',
name='action',
field=models.CharField(choices=[('ADD', 'Add'), ('TRAIN', 'Entity Trained'), ('DELETE', 'Entity Deleted'), ('CREATE', 'Entity Created'), ('INTEGRATE', 'Entity integrated'), ('UPDATE', 'Entity updated')], max_length=15),
),
]
1 change: 1 addition & 0 deletions connect/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class Meta:
_("Only users with external provider can access the organization"),
default=False,
)
config = models.JSONField(default=dict)
objects = OrganizationManager()

def __str__(self):
Expand Down

0 comments on commit 9c98888

Please sign in to comment.