-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check user belongs to dataset organization before creation (#437)
* Check user belongs to dataset organization before creation * Prevent ADMIN from creating dataset outside own org, refactor tests * Refine * Check user belongs to organization before update (#455) * Check user belongs to organization before update * Test ADMIN cannot update in other org either
- Loading branch information
1 parent
0425084
commit fdc0df4
Showing
19 changed files
with
384 additions
and
137 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class CannotCreateDataset(Exception): | ||
pass | ||
|
||
|
||
class CannotUpdateDataset(Exception): | ||
pass |
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,11 @@ | ||
from server.domain.auth.entities import Account | ||
from server.domain.catalogs.entities import Catalog | ||
from server.domain.datasets.entities import Dataset | ||
|
||
|
||
def can_create_dataset(catalog: Catalog, account: Account) -> bool: | ||
return catalog.organization.siret == account.organization_siret | ||
|
||
|
||
def can_update_dataset(dataset: Dataset, account: Account) -> bool: | ||
return dataset.catalog_record.organization.siret == account.organization_siret |
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,8 +1,16 @@ | ||
import uuid | ||
from typing import NewType | ||
|
||
from pydantic import BaseModel | ||
|
||
ID = NewType("ID", uuid.UUID) | ||
|
||
|
||
def id_factory() -> ID: | ||
return ID(uuid.uuid4()) | ||
|
||
|
||
class Skip(BaseModel): | ||
""" | ||
A marker class for when an operation should be skipped. | ||
""" |
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
Oops, something went wrong.