-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from cuenca-mx/custom-query-validator
Add Custom query validator
- Loading branch information
Showing
3 changed files
with
34 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from typing import Any | ||
|
||
from fast_agave.blueprints import RestApiBlueprint | ||
from starlette_context import context | ||
|
||
|
||
class CustomQueryBlueprint(RestApiBlueprint): | ||
@property | ||
def custom(self) -> str: | ||
return context['custom'] | ||
|
||
def property_filter_required(self) -> bool: | ||
return context.get('custom_filter_required') | ||
|
||
def custom_filter_required(self, query_params: Any, model: any) -> None: | ||
if self.property_filter_required() and hasattr(model, 'custom'): | ||
query_params.custom = self.custom | ||
|
||
def user_id_filter_required(self) -> bool: | ||
return False | ||
|
||
def platform_id_filter_required(self) -> bool: | ||
return 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
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 +1 @@ | ||
__version__ = '0.4.0' | ||
__version__ = '0.5.0' |