-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(profilesdao): remove useless Profiles
- Loading branch information
1 parent
af2706e
commit 328e84d
Showing
1 changed file
with
33 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,39 @@ | ||
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"} | ||
|
||
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"} |