From 22f47d02311c45d302952ba1f3186a6bb35b0dd7 Mon Sep 17 00:00:00 2001 From: daphtya <davidpanjaitan1@gmail.com> Date: Fri, 19 Apr 2019 18:57:11 +0700 Subject: [PATCH] added reply name and date --- database/database.py | 2 ++ modules/comment.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/database/database.py b/database/database.py index d0ba707..635677a 100644 --- a/database/database.py +++ b/database/database.py @@ -21,7 +21,9 @@ class User(mongo.Document): class Reply(mongo.EmbeddedDocument): replier_id = mongo.StringField(max_length=20, required =True) + replier_name = mongo.StringField(required=True) reply_text = mongo.StringField(required=True) + date = mongo.DateTimeField(default= datetime.utcnow) class Comment(mongo.Document): commenter_id = mongo.StringField(max_length=20, required=True) diff --git a/modules/comment.py b/modules/comment.py index f5fe31b..47871bf 100644 --- a/modules/comment.py +++ b/modules/comment.py @@ -62,7 +62,7 @@ def add_reply(user): "status":401, "message":"Unauthorized reply" }) - comment.update(reply=db.Reply(replier_id = user.id, reply_text=reply_text)) + comment.update(reply=db.Reply(replier_id = user.id, replier_name= user.name, reply_text=reply_text)) return jsonify({ "status":200, "message":"Reply added successfully" -- GitLab