-
Notifications
You must be signed in to change notification settings - Fork 7
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
495662c
commit b2ac591
Showing
11 changed files
with
320 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from models.main import db, UserAuthorization, User | ||
from models.enums import FeatureEnum | ||
from services import memory_service, permission_service | ||
|
||
|
||
def has_segment_authorization(id_segment: int, user: User): | ||
if id_segment == None: | ||
# some cases dont have a segment defined | ||
return True | ||
|
||
if permission_service.has_maintainer_permission(user): | ||
return True | ||
|
||
if memory_service.has_feature(FeatureEnum.AUTHORIZATION_SEGMENT.value): | ||
auth = ( | ||
db.session.query(UserAuthorization) | ||
.filter(UserAuthorization.idUser == user.id) | ||
.filter(UserAuthorization.idSegment == id_segment) | ||
.first() | ||
) | ||
|
||
if auth != None: | ||
return True | ||
|
||
return False | ||
|
||
return True |
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
Oops, something went wrong.