Skip to content

Commit

Permalink
Issue 685
Browse files Browse the repository at this point in the history
  • Loading branch information
ashokrayal committed Sep 9, 2020
1 parent 858a7d7 commit 7a6bcff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 10 additions & 1 deletion app/api/models/mentorship_relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def add_models_to_namespace(api_namespace):
] = mentorship_request_response_body_for_user_dashboard_body
api_namespace.models[user_dashboard_user_details.name] = user_dashboard_user_details
api_namespace.models[task_comment_model.name] = task_comment_model
api_namespace.models[user_detail.name] = user_detail
api_namespace.models[task_comments_model.name] = task_comments_model


Expand Down Expand Up @@ -164,11 +165,19 @@ def add_models_to_namespace(api_namespace):
{"comment": fields.String(required=True, description="Task comment.")},
)

user_detail = Model(

This comment has been minimized.

Copy link
@PrashanthPuneriya

PrashanthPuneriya Sep 10, 2020

Can't we just use dict instead of Model(....)? I think we don't need to create a separate model for it.

This comment has been minimized.

Copy link
@ashokrayal

ashokrayal Sep 12, 2020

Author Owner

There are multiple places where I saw similar use so I just wanted to keep it consistent.

"User model.",
{"id": fields.Integer(required=True, description="User's id."),

This comment has been minimized.

Copy link
@PrashanthPuneriya

PrashanthPuneriya Sep 10, 2020

I think { and } in two different lines makes this piece of code style consistent

This comment has been minimized.

Copy link
@ashokrayal

ashokrayal Sep 12, 2020

Author Owner

yes right.

"name": fields.String(required=True, description="User's name.")},
)

task_comments_model = Model(
"Task comments model.",
{
"id": fields.Integer(required=True, description="Task comment's id."),
"user_id": fields.Integer(required=True, description="User's id."),
"sent_by_me":fields.Boolean(

This comment has been minimized.

Copy link
@PrashanthPuneriya

PrashanthPuneriya Sep 10, 2020

Add a space after :

This comment has been minimized.

Copy link
@ashokrayal

ashokrayal Sep 12, 2020

Author Owner

ok

required=True, description="Comment is done by current user indication"),
"user": fields.Nested(user_detail),
"task_id": fields.Integer(required=True, description="Task's id."),
"relation_id": fields.Integer(required=True, description="Relation's id."),
"creation_date": fields.Float(
Expand Down
8 changes: 7 additions & 1 deletion app/api/resources/mentorship_relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,12 +836,18 @@ def get(cls, relation_id, task_id):
"""
Lists the task comments.
"""
user_id = get_jwt_identity()

response = TaskCommentDAO.get_all_task_comments_by_task_id(
get_jwt_identity(), task_id, relation_id
user_id, task_id, relation_id
)

if isinstance(response, tuple):
return response

for task in response:

This comment has been minimized.

Copy link
@PrashanthPuneriya

PrashanthPuneriya Sep 10, 2020

This doesn't make any sense to me. What's the use of for loop? You have created a for loop but, you haven't gained anything from it.

This comment has been minimized.

Copy link
@ashokrayal

ashokrayal Sep 12, 2020

Author Owner

response is list of comments so I am assigning user and sent_by_me to all comments.

task['user'] = userDAO.get_user(task['user_id'])
task['sent_by_me'] = user_id==task['user_id']

else:
return marshal(response, task_comments_model), HTTPStatus.OK

1 comment on commit 7a6bcff

@ashokrayal
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue anitab-org#685 fix

Please sign in to comment.