Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a comment/discussion system in GraphSpace #426

Open
wants to merge 96 commits into
base: comment-system
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
c1c914e
Architecture.png
melvin15may Jun 10, 2017
a66e227
Add files via upload
melvin15may Jun 24, 2017
9d209ac
Added screen-casts for group notifications
melvin15may Jul 2, 2017
3aa78a2
Delete add_new_member.webm
melvin15may Jul 2, 2017
b5ea257
Delete group-notification-tab.webm
melvin15may Jul 2, 2017
fc92a9a
Delete individual-notification.webm
melvin15may Jul 2, 2017
3917fef
Delete mark-all-as-read-notification.webm
melvin15may Jul 2, 2017
1c86293
Delete share-unshare-graph.webm
melvin15may Jul 2, 2017
b78cf01
Add files via upload
melvin15may Jul 2, 2017
7125307
Delete share-layout.webm
melvin15may Jul 2, 2017
f1a7c6f
Delete graph_notification.gif
melvin15may Jul 2, 2017
a1dc11d
Delete layout_notification.gif
melvin15may Jul 2, 2017
0a3804e
Delete group_notification.gif
melvin15may Jul 2, 2017
b016885
Delete group_update_notification.gif
melvin15may Jul 2, 2017
e55794d
Delete notification_page.gif
melvin15may Jul 2, 2017
b1afe02
Add files via upload
melvin15may Jul 2, 2017
d07fe12
Add files via upload
melvin15may Jul 3, 2017
01fa25f
Merge remote-tracking branch 'upstream/master'
melvin15may Aug 14, 2017
f655860
started implementing comments system
bruce-wayne99 Jun 8, 2018
8cbc3cc
added models for comments, comment to node and comment to edge relati…
bruce-wayne99 Jun 9, 2018
71608b7
removed comments folder
bruce-wayne99 Jun 10, 2018
0d4493e
added views and controllers for creating comments
bruce-wayne99 Jun 10, 2018
f0b5d51
update dal.py and models.py
bruce-wayne99 Jun 10, 2018
6639114
added errorcode for creating comment
bruce-wayne99 Jun 10, 2018
ab79a78
removed comments related code from graphs
bruce-wayne99 Jun 16, 2018
87dd719
added comment-system application
bruce-wayne99 Jun 16, 2018
b308319
added views and routes to display and upload comments for testing
bruce-wayne99 Jun 16, 2018
bc2eda9
added asgi for sockets
bruce-wayne99 Jun 16, 2018
163e5c2
django channels added for real-time functionality
bruce-wayne99 Jun 16, 2018
c51eae5
added sockets for frontend and signals
bruce-wayne99 Jun 16, 2018
3f41a4a
added functionality to get edgeId/nodeId based on edge/node name
bruce-wayne99 Jun 21, 2018
db394d8
added ajax handlers to create comments by ajax request
bruce-wayne99 Jun 21, 2018
52b5bb0
added panel for adding comments, viewing comments
bruce-wayne99 Jul 13, 2018
fd0df77
update signals to handle delete,add,edit comments
bruce-wayne99 Jul 13, 2018
e6a5c7e
update controllers,dal,models to handle edit,delete,resolve,add,reply…
bruce-wayne99 Jul 13, 2018
903387c
added views to handle crud operations on comments
bruce-wayne99 Jul 13, 2018
e0a1276
added event listeners to comments for CRUD operations
bruce-wayne99 Jul 13, 2018
5b830aa
updated socket handler functions
bruce-wayne99 Jul 13, 2018
f572c90
added functionality for displaying updated time of comment in real-time
bruce-wayne99 Jul 18, 2018
58f2e66
added functionality for showing the graph associated with a comment
bruce-wayne99 Jul 18, 2018
5156c2a
fixed real-time functionality to highlight graph elements on hovering…
bruce-wayne99 Jul 19, 2018
e8f7940
added permissions for CRUD on comments
bruce-wayne99 Jul 19, 2018
3b3714e
added functionality frontend to highlight graph elements
bruce-wayne99 Jul 19, 2018
3574323
fixed bug real-time functionality
bruce-wayne99 Jul 19, 2018
e50f8d8
added implementation for visualizing comments based on selected graph
bruce-wayne99 Jul 20, 2018
58cc0dc
added functionality for comments dropdown
bruce-wayne99 Jul 21, 2018
dcfc9f3
fixed filtering comments to handle resolved comments
bruce-wayne99 Jul 21, 2018
38b59b7
added backend functionality to handle replies to resolved comments
bruce-wayne99 Jul 24, 2018
a500e07
added errorcodes on trying to reply to resolved comments
bruce-wayne99 Jul 24, 2018
7b48c78
added frontend and socket functionality to handle resolved comments
bruce-wayne99 Jul 24, 2018
e45ec93
did code clean up to remove unnecessary id's for elements
bruce-wayne99 Jul 24, 2018
1fba768
added backend implementation for pinning comments
bruce-wayne99 Jul 27, 2018
cd09b6f
added error codes to handle errors for pinning comments
bruce-wayne99 Jul 27, 2018
62d6c9e
Added frontend code for pinning comments and pagination
bruce-wayne99 Jul 27, 2018
d94f4f3
added real-time functionality to handle pin/unpin/resolve/reopen comm…
bruce-wayne99 Jul 27, 2018
dbd89e3
update graph_page.js, graphspace.css base.html for displaying resolve…
bruce-wayne99 Jul 31, 2018
e37760f
update graphspace.css, graph_page.js for pagination
bruce-wayne99 Aug 1, 2018
591b7b0
added real-time functionality for pagination
bruce-wayne99 Aug 1, 2018
ee2d892
added resolved checkbox for comments
bruce-wayne99 Aug 1, 2018
d025f3f
added functionality to allow owner of the graph to delete comments, a…
bruce-wayne99 Aug 8, 2018
d420f3b
Merge pull request #1 from bruce-wayne99/summer-work
bruce-wayne99 Aug 8, 2018
e4d9c1c
added code documentation
bruce-wayne99 Sep 11, 2018
6f14c60
Merge pull request #2 from bruce-wayne99/summer-work
bruce-wayne99 Sep 11, 2018
03f6fd0
removed upload comment method
bruce-wayne99 Mar 9, 2019
18c1650
changed port for redis server
bruce-wayne99 Mar 17, 2019
01f12c9
added docker configuration files
bruce-wayne99 Mar 17, 2019
bb36d69
update requirements.txt
bruce-wayne99 Mar 17, 2019
57fc838
added code for running the server
bruce-wayne99 Mar 17, 2019
75d3396
added changes for displaying ports
bruce-wayne99 Mar 17, 2019
a77a8d7
changed requirements file and fixed bugs in Dockerfile
bruce-wayne99 Mar 17, 2019
dbe0d2d
changed forwared docker ports
bruce-wayne99 Mar 18, 2019
3a42dcf
fixed bug in docker_command file
bruce-wayne99 Mar 18, 2019
bece9ef
Merge branch 'comment-system' of github.com:bruce-wayne99/GraphSpace …
yash170106065 May 7, 2020
1776df3
solve the merge conflicts
yash170106065 May 16, 2020
a75406b
created discussion app
yash170106065 Jun 8, 2020
e722c76
created table for discussions and updated base.py
yash170106065 Jun 8, 2020
ded5cc3
created add and view discussions on bootstrap table functionality (UI…
yash170106065 Jun 10, 2020
d1ad9fe
add urls and functions for discussion page
yash170106065 Jun 10, 2020
a9b0d7a
designed discussion page UI and backend for adding and view comments
yash170106065 Jun 16, 2020
71d1a2a
modified models for unique discussions in a group
yash170106065 Jun 28, 2020
54be9ec
adding functionality views.py for deleting editing discussions
yash170106065 Jun 28, 2020
5682340
functionality for search close and open discussions
yash170106065 Jun 28, 2020
dfa8fab
adding authorization and error codes for discussions and its function…
yash170106065 Jun 28, 2020
25ba9aa
added delete discussions modal
yash170106065 Jun 28, 2020
6edabc2
created a functionality for read-more and solved the bug for timeago …
yash170106065 Jun 28, 2020
559a9d5
designed the discussion page
yash170106065 Jun 28, 2020
f2d9d53
modified the bootstrap discussion table for discussions
yash170106065 Jun 28, 2020
1cf9dcc
updating the stylesheet for discussion page and table
yash170106065 Jun 28, 2020
b911da2
adding event listeners and CRUD functionalities for discussion page a…
yash170106065 Jun 28, 2020
3fcda4b
added real-time websockets functionalities for discussions
yash170106065 Jun 28, 2020
e24e689
modified comments and code
yash170106065 Jun 30, 2020
c9c1fc8
modified id and classes names and case
yash170106065 Jul 2, 2020
b3f07e8
changed the models and improve the functionalities with docstrings
yash170106065 Jul 29, 2020
2abca88
added the reaction system in discussions
yash170106065 Aug 11, 2020
4447c34
updated the comment system and resolve bugs
yash170106065 Aug 25, 2020
9335334
Resolve edit comment bug
yash170106065 Aug 25, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
FROM ubuntu:16.04
MAINTAINER Subramanyam Makam (makam.subramanyam.code@gmail.com)

RUN apt-get update -y && \
apt-get install -y aptitude && \
aptitude install -y build-essential checkinstall software-properties-common python-software-properties && \
aptitude install -y wget git libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev && \
mkdir ~/Downloads && \
cd ~/Downloads/ && \
wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz && \
tar -xvf Python-2.7.13.tgz && \
cd Python-2.7.13 && \
./configure && \
make && \
make install && \
aptitude install -y nodejs nodejs-legacy npm && \
npm install -g bower && \
cd && \
git config --global user.email "makam.subramanyam.code@gmail.com" && \
git config --global user.name "bruce-wayne99" && \
aptitude update && \
aptitude install -y postgresql postgresql-contrib && \
aptitude install -y python2.7-dev python-pip && \
pip install virtualenv && \
aptitude install -y openjdk-8-jre openjdk-8-jdk && \
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
add-apt-repository -y ppa:webupd8team/java && \
aptitude update && \
aptitude install -y oracle-java8-installer && \
cd ~/Downloads && \
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.1.tar.gz && \
tar xvzf elasticsearch-5.5.1.tar.gz && \
rm -f elasticsearch-5.5.1.tar.gz && \
mv elasticsearch-5.5.1 /elasticsearch && \
aptitude install tcl && \
wget http://download.redis.io/redis-stable.tar.gz && \
tar xzvf redis-stable.tar.gz && \
cd redis-stable && \
make && \
make install && \
mkdir /redis && \
cp redis.conf /redis/ && \
aptitude update && \
aptitude install -y zookeeperd && \
cd / && \
git clone -b comment-system https://github.com/bruce-wayne99/GraphSpace.git && \
aptitude install -y python-psycopg2 libpq-dev && \
chmod -R 777 /GraphSpace && \
rm -r /var/cache/

USER postgres

RUN /etc/init.d/postgresql start && \
psql -c "CREATE DATABASE test;" && \
psql -c "ALTER USER postgres with PASSWORD '987654321';" && \
psql -d test -c "CREATE EXTENSION pg_trgm;" && \
psql -d test -c "CREATE EXTENSION btree_gin;"

USER root

RUN useradd -ms /bin/bash elasticsearch && \
chmod -R 777 /elasticsearch

ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
Empty file.
3 changes: 3 additions & 0 deletions applications/comments/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions applications/comments/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class CommentsConfig(AppConfig):
name = 'comments'
272 changes: 272 additions & 0 deletions applications/comments/controllers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
from sqlalchemy.exc import IntegrityError
import applications.comments.dal as db
import applications.graphs.dal as graphs_db
from graphspace.exceptions import ErrorCodes, BadRequest
from graphspace.wrappers import atomic_transaction


@atomic_transaction
def add_comment(request, text=None, graph_id=None, edges=None, nodes=None, is_closed=0, owner_email=None,
parent_comment_id=None, layout_id=None):
"""

Parameters
----------
request: object
HTTP Request.
text: string
Comment message.
graph_id: Integer
Unique ID of each graph.
edges: List
List of edge names on associated with the comment.
nodes: List
List of node names on associated with the comment.
is_closed: Integer
Integer indicating if the comment is closed or not.
owner_email: string
Email ID of user who comment on the graph.
parent_comment_id: Integer
Unique ID of parent comment.
layout_id: Integer
Unique ID of layout.

Returns
-------
comment: Object
Comment Object.

"""
# Construct new comment to add to database
comment = db.add_comment(request.db_session, text=text, owner_email=owner_email,
is_closed=is_closed, parent_comment_id=parent_comment_id)
comment_to_graph = db.add_comment_to_graph(request.db_session, comment_id=comment.id, graph_id=graph_id,
layout_id=layout_id)
# Add comment edges
if edges != None:
for edge_id in edges:
db.add_comment_to_edge(request.db_session, comment_id=comment.id, edge_id=edge_id)

# Add comment nodes
if nodes != None:
for node_id in nodes:
db.add_comment_to_node(request.db_session, comment_id=comment.id, node_id=node_id)

db.send_comment(comment, comment_to_graph, event="insert")
return comment


def get_comment_by_graph_id(request, graph_id):

"""
Parameters
----------
request: object
HTTP request.
graph_id: Integer
Unique ID of graph.

Returns
-------
return value: Object.
Comment Object.

"""
return db.get_comment_by_graph_id(request.db_session, graph_id=graph_id)


def get_nodes_by_comment_id(request, comment_id):
"""

Parameters
----------
request: object
HTTP request.
comment_id: Integer
Unique ID of comment.

Returns
-------
return value: List.
List of Node Objects.

"""
return db.get_nodes_by_comment_id(request.db_session, comment_id=comment_id)


def get_edges_by_comment_id(request, comment_id):
"""

Parameters
----------
request: object
HTTP request.
comment_id: Integer
Unique ID of comment.

Returns
-------
return value: List.
List of Edge Objects.

"""
return db.get_edges_by_comment_id(request.db_session, comment_id=comment_id)


def get_comment_by_id(request, comment_id):
"""

Parameters
----------
request: object
HTTP request.
comment_id: Integer
Unique ID of comment.

Returns
-------
return value: object.
Comment Object.

"""
return db.get_comment_by_id(request.db_session, id=comment_id)


def get_comment_to_graph(request, comment_id):
"""

Parameters
----------
request: object
HTTP request.
comment_id: Integer
Unique ID of comment.

Returns
-------
return value: object.
Comment Object.

"""
return db.get_comment_to_graph(request.db_session, id=comment_id)


@atomic_transaction
def edit_comment(request, comment_id=None, text=None, is_closed=None):
"""

Parameters
----------
request: object
HTTP request.
comment_id: Integer
Unique ID of comment.
text: String
New comment message.
is_closed: Integer
Indicates if the comment is closed or not.

Returns
-------
return value: object
Edited Comment Object.

"""
updated_comment = {}

# Check if field is present or not.
if is_closed != None:
updated_comment['is_closed'] = is_closed
if text != None:
updated_comment['text'] = text
return db.edit_comment(request.db_session, id=comment_id, updated_comment=updated_comment)

# # Only top comment in a comment thread can be resolved.
comment = db.get_comment_by_id(request.db_session, id=comment_id)
if comment.serialize()['is_closed'] == 0 and is_closed == 1 and comment.serialize()[
'parent_comment_id'] != None:
raise Exception('Reply comments can not be resolved')

return db.update_comment(request.db_session, id=comment_id, updated_comment=updated_comment)


@atomic_transaction
def delete_comment(request, id=None):
"""

Parameters
----------
request: object
HTTP request.
id: Integer
Unique ID of comment.

Returns
-------
return value: object
Deleted Comment Object.

"""
return db.delete_comment(request.db_session, id=id)


def is_user_authorized_to_update_comment(request, username, comment_id):
"""

Parameters
----------
request: object
HTTP request.
username: string
Email ID of user.
comment_id: integer
Unique ID of comment.

Returns
-------
is_authorized: bool
Returns True if the user is authorized to update comment else False.

"""
is_authorized = False
comment = db.get_comment_by_id(request.db_session, comment_id)

if comment is not None: # Comment exists
if comment.owner_email == username:
is_authorized = True

return is_authorized


def is_user_authorized_to_delete_comment(request, username, comment_id):
"""

Parameters
----------
request: object
HTTP request.
username: string
Email ID of user.
comment_id: integer
Unique ID of comment.

Returns
-------
is_authorized: bool
Returns True if the user is authorized to delete comment else False.

"""
is_authorized = False

comment = db.get_comment_by_id(request.db_session, comment_id)
if comment is not None:
comment_to_graph = db.get_comment_to_graph(request.db_session, comment_id)
graph = graphs_db.get_graph_by_id(request.db_session, comment_to_graph.graph_id)

if comment is not None: # Comment exists
if comment.owner_email == username:
is_authorized = True
elif graph.owner_email == username:
is_authorized = True

return is_authorized
Loading