-
Notifications
You must be signed in to change notification settings - Fork 1
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 #19 from InbarShirizly/testing-and-code-architecture
Testing and code architecture
- Loading branch information
Showing
25 changed files
with
262 additions
and
173 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,20 @@ | ||
from functools import wraps | ||
from flask_restful import abort | ||
from server import auth | ||
from server.models.orm import ClassroomModel | ||
from server import app | ||
from server.config import RestErrors | ||
|
||
# This decorator fucntion will make sure that the classroom belongs to the current user | ||
def validate_classroom(fnc): | ||
def inner(class_id, report_id=None): | ||
if ClassroomModel.query.filter_by(id=class_id, teacher=auth.current_user()).first() is None: | ||
abort(400, message="Invalid class id") | ||
return fnc(class_id, report_id) | ||
return inner | ||
|
||
|
||
# Error handler for 404 | ||
@app.errorhandler(404) | ||
def not_found(error): | ||
return {"message": RestErrors.INVALID_ROUTE} |
Empty file.
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,9 @@ | ||
from flask_restful import fields | ||
|
||
|
||
class StudentItemField(fields.Raw): # Custom field to parse StudentModel object | ||
def format(self, value): | ||
without_none = {k: v for k, v in value.__dict__ .items() if v is not None} # Getting only attributes which are not None | ||
del without_none['_sa_instance_state'] | ||
del without_none['class_id'] | ||
return without_none |
Oops, something went wrong.