Skip to content

Commit

Permalink
(#135) Adicionando o context para pegar os posts quando o usuario for…
Browse files Browse the repository at this point in the history
… um estudante

Co-authored-by: Thiago Paiva <thiagohdaqw@gmail.com>
  • Loading branch information
victorhugo21 and thiagohdaqw committed May 3, 2021
1 parent ac3eafe commit 79dc79a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/controller/post_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@ def post(self):
return make_response(jsonify(message), status_code)
except ValidationError as err:
return make_response(jsonify(err.messages), 400)

@jwt_required()
def get(self):
user = current_user
ps = post_schema.PostSchema(many=True)
if not user.is_professor():
ps = post_schema.PostSchema(
many=True, context={'reg_student': user.reg})
else:
ps = post_schema.PostSchema(many=True)
return make_response(ps.jsonify(user.posts), 200)



class PostAgreesList(Resource):
@student_required()
def post(self):
Expand Down Expand Up @@ -68,10 +71,7 @@ def post(self):
return make_response(jsonify(err.messages), 400)





def configure(api):
api.add_resource(PostList, "/post")
api.add_resource(PostAgreesList, "/post/agree")
api.add_resource(PostDisagreesList, "/post/disagree")
api.add_resource(PostDisagreesList, "/post/disagree")

0 comments on commit 79dc79a

Please sign in to comment.