-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactore: get the agreement statues from db instead of session (#552)
* style: fix the loading * chore: update the signatureIcon * chore: fix type * chore: release @petercatai/assistant@1.0.18 * refactore: get the agreement statues from db instead of session * chore: remove log * chore: fix ci * chore: fix test
- Loading branch information
1 parent
5f33065
commit 11e80d1
Showing
7 changed files
with
108 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from core.dao.BaseDAO import BaseDAO | ||
from supabase.client import Client | ||
|
||
from core.models.profiles import Profiles | ||
from petercat_utils.db.client.supabase import get_client | ||
|
||
class ProfilesDAO(BaseDAO): | ||
client: Client | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self.client = get_client() | ||
|
||
def get_agreement_status(self, user_id: str): | ||
|
||
resp = self.client.table("profiles")\ | ||
.select("agreement_accepted") \ | ||
.eq("id", user_id) \ | ||
.execute() | ||
agreement_accepted = resp.data[0] | ||
return agreement_accepted | ||
|
||
def accept_agreement(self, user_id: str): | ||
try: | ||
response = self.client.table("profiles").update({"agreement_accepted": True}).match({"id": user_id}).execute() | ||
|
||
if not response.data: | ||
return False, {"message": "User does not exist, accept failed."} | ||
return response.data[0] | ||
except Exception as e: | ||
print("Error: ", e) | ||
return False, {"message": "Profile Update failed"} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from pydantic import BaseModel | ||
from datetime import datetime | ||
from typing import Optional | ||
|
||
class Profiles(BaseModel): | ||
id: str | ||
created_at: datetime = datetime.now() | ||
nickname: Optional[str] = "" | ||
name: Optional[str] = "" | ||
picture: Optional[str] = "" | ||
sid: Optional[str] = "" | ||
sub: Optional[str] = "" | ||
agreement_accepted: Optional[bool] = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters