-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc8eaeb
commit 39ae05c
Showing
18 changed files
with
408 additions
and
30 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
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,7 @@ | ||
-- Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS | ||
|
||
|
||
ALTER TABLE organization ADD eula_updated_on TIMESTAMPTZ; | ||
ALTER TABLE organization ADD eula_url TEXT; | ||
|
||
ALTER TABLE user_ ADD eula_accepted_on TIMESTAMPTZ; |
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
52 changes: 52 additions & 0 deletions
52
server/parsec/components/postgresql/organization_get_eula.py
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,52 @@ | ||
# Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS | ||
from __future__ import annotations | ||
|
||
from parsec._parsec import ( | ||
DateTime, | ||
OrganizationID, | ||
) | ||
from parsec.components.organization import ( | ||
OrganizationGetEulaBadOutcome, | ||
) | ||
from parsec.components.postgresql import AsyncpgConnection | ||
from parsec.components.postgresql.utils import ( | ||
Q, | ||
) | ||
|
||
_q_get_eula = Q(""" | ||
SELECT | ||
is_expired, | ||
eula_updated_on, | ||
eula_url | ||
FROM organization | ||
WHERE organization_id = $organization_id | ||
LIMIT 1 | ||
""") | ||
|
||
|
||
async def organization_get_eula( | ||
conn: AsyncpgConnection, | ||
id: OrganizationID, | ||
) -> tuple[str, DateTime] | None | OrganizationGetEulaBadOutcome: | ||
row = await conn.fetchrow(*_q_get_eula(organization_id=id.str)) | ||
|
||
if not row: | ||
return OrganizationGetEulaBadOutcome.ORGANIZATION_NOT_FOUND | ||
|
||
match row["is_expired"]: | ||
case True: | ||
return OrganizationGetEulaBadOutcome.ORGANIZATION_EXPIRED | ||
case False: | ||
pass | ||
case unknown: | ||
assert False, unknown | ||
|
||
match (row["eula_updated_on"], row["eula_url"]): | ||
case (None, None): | ||
eula = None | ||
case (DateTime() as eula_updated_on, str() as eula_url): | ||
eula = (eula_url, eula_updated_on) | ||
case unknown: | ||
assert False, unknown | ||
|
||
return eula |
Oops, something went wrong.