From 17ec3dbf21bbfc38f45f466bca493e131aeb4bf1 Mon Sep 17 00:00:00 2001 From: Ishankoradia Date: Wed, 25 Sep 2024 14:26:40 +0530 Subject: [PATCH] added a field to check llm optin --- ddpui/api/user_org_api.py | 2 +- ddpui/core/orguserfunctions.py | 2 ++ ddpui/migrations/0102_orguser_llm_optin.py | 17 +++++++++++++++++ ddpui/models/org_user.py | 3 +++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 ddpui/migrations/0102_orguser_llm_optin.py diff --git a/ddpui/api/user_org_api.py b/ddpui/api/user_org_api.py index 8225a47b..5059369f 100644 --- a/ddpui/api/user_org_api.py +++ b/ddpui/api/user_org_api.py @@ -136,6 +136,7 @@ def get_current_user_v2(request): is_demo=( curr_orguser.org.type == OrgType.DEMO if curr_orguser.org else False ), + llm_optin=curr_orguser.llm_optin, ) ) @@ -284,7 +285,6 @@ def put_organization_user_self(request, payload: OrgUserUpdate): response=OrgUserResponse, auth=auth.CustomAuthMiddleware(), ) -@has_permission(["can_edit_orguser"]) def put_organization_user_self_v1(request, payload: OrgUserUpdatev1): """update the requestor's OrgUser""" orguser: OrgUser = request.orguser diff --git a/ddpui/core/orguserfunctions.py b/ddpui/core/orguserfunctions.py index c67c5324..9be8ed38 100644 --- a/ddpui/core/orguserfunctions.py +++ b/ddpui/core/orguserfunctions.py @@ -152,6 +152,8 @@ def update_orguser_v1(orguser: OrgUser, payload: OrgUserUpdatev1): orguser.user.is_active = payload.active if payload.role_uuid: orguser.new_role = Role.objects.filter(uuid=payload.role_uuid).first() + if payload.llm_optin is not None: + orguser.llm_optin = payload.llm_optin orguser.user.save() orguser.save() diff --git a/ddpui/migrations/0102_orguser_llm_optin.py b/ddpui/migrations/0102_orguser_llm_optin.py new file mode 100644 index 00000000..c52ca5f9 --- /dev/null +++ b/ddpui/migrations/0102_orguser_llm_optin.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2 on 2024-09-25 08:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("ddpui", "0101_llmsession_updated_by"), + ] + + operations = [ + migrations.AddField( + model_name="orguser", + name="llm_optin", + field=models.BooleanField(default=False), + ), + ] diff --git a/ddpui/models/org_user.py b/ddpui/models/org_user.py index 3d114fbf..ed2fc704 100644 --- a/ddpui/models/org_user.py +++ b/ddpui/models/org_user.py @@ -72,6 +72,7 @@ class OrgUser(models.Model): ) new_role = models.ForeignKey(Role, on_delete=models.SET_NULL, null=True) email_verified = models.BooleanField(default=False) + llm_optin = models.BooleanField(default=False) created_at = models.DateTimeField(auto_created=True, default=timezone.now) updated_at = models.DateTimeField(auto_now=True) @@ -104,6 +105,7 @@ class OrgUserUpdatev1(Schema): role_uuid: uuid.UUID = None email: str = None active: bool = None + llm_optin: bool = False class OrgUserUpdateNewRole(Schema): @@ -131,6 +133,7 @@ class OrgUserResponse(Schema): is_demo: bool = False new_role_slug: str | None permissions: list[dict] + llm_optin: bool = None class Invitation(models.Model):