-
Notifications
You must be signed in to change notification settings - Fork 9
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
66acad9
commit ab06371
Showing
4 changed files
with
55 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
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,23 @@ | ||
from app.models.project import Project | ||
from app.schemas.project import ProjectListSchema | ||
from flask import current_app | ||
from flask_restful import Resource, request | ||
from app.models.project import Project | ||
from flask_jwt_extended import jwt_required | ||
import json | ||
|
||
|
||
class GenericSearchView(Resource): | ||
@jwt_required | ||
def get(self): | ||
keywords = request.args.get('keywords', '') | ||
|
||
#Schemas | ||
projectSchema = ProjectListSchema(many=True) | ||
|
||
# projects | ||
projects = Project.query.filter(Project.name.ilike('%'+keywords+'%')).order_by(Project.date_created.desc()) | ||
|
||
project_data , errors = projectSchema.dumps(projects) | ||
|
||
return dict(projects=json.loads(project_data)) , 200 |
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