From 773bca1ccce66acb3b6ec8e5f9cc0819dfaaaccb Mon Sep 17 00:00:00 2001
From: daphtya <davidpanjaitan1@gmail.com>
Date: Mon, 15 Apr 2019 10:03:24 +0700
Subject: [PATCH] added user name to comments

---
 database/database.py | 1 +
 modules/comment.py   | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/database/database.py b/database/database.py
index 3cf5e36..d0ba707 100644
--- a/database/database.py
+++ b/database/database.py
@@ -25,6 +25,7 @@ class Reply(mongo.EmbeddedDocument):
 
 class Comment(mongo.Document):
     commenter_id = mongo.StringField(max_length=20, required=True)
+    commenter_name = mongo.StringField(required=True)
     comment_text = mongo.StringField(required=True)
     page = mongo.ReferenceField('VizData', required=True)
     date = mongo.DateTimeField(default = datetime.utcnow)
diff --git a/modules/comment.py b/modules/comment.py
index d03e9cb..f5fe31b 100644
--- a/modules/comment.py
+++ b/modules/comment.py
@@ -37,7 +37,7 @@ def add_comment(user):
     text = req.get("text")
     try:
         page = db.VizData.objects.with_id(page_id)
-        new_comment = db.Comment(commenter_id = user.id, comment_text=text, page = page)
+        new_comment = db.Comment(commenter_id = user.id, commenter_name=user.name, comment_text=text, page = page)
         new_comment.save()
         return jsonify({
             "status":200,
-- 
GitLab