From e30eed4fbc053e4f79918c040db15c91282e9f9e Mon Sep 17 00:00:00 2001 From: Aditya Bharadwaj Date: Sat, 3 Mar 2018 20:36:51 -0500 Subject: [PATCH 1/8] Create PULL_REQUEST_TEMPLATE.md Adding a pull request template to standardize the description of the proposed changes from contributors. Project contributors will automatically see the template's contents in the pull request body. More details can be found [here](https://help.github.com/articles/creating-a-pull-request-template-for-your-repository/). --- PULL_REQUEST_TEMPLATE.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 PULL_REQUEST_TEMPLATE.md diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..9de17e17 --- /dev/null +++ b/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,20 @@ +## Purpose +_Describe the problem or feature in addition to a link to the issues._ + +Example: +Fixes # . + +## Approach +_How does this change address the problem?_ + +#### Open Questions and Pre-Merge TODOs +- [ ] Use github checklists. When solved, check the box and explain the answer. + +## Learning +_Describe the research stage_ + +_Links to blog posts, patterns, libraries or addons used to solve this problem_ + +#### Blog Posts +- [How to Pull Request](https://github.com/flexyford/pull-request) Github Repo with Learning focused Pull Request Template. + From a54e238aeac1a5747fc9e2b47efdca21c95c826e Mon Sep 17 00:00:00 2001 From: JingVT <33851894+JingVT@users.noreply.github.com> Date: Tue, 14 Aug 2018 10:10:59 -0400 Subject: [PATCH 2/8] Update PULL_REQUEST_TEMPLATE.md --- PULL_REQUEST_TEMPLATE.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index 9de17e17..e30346ba 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -1,19 +1,19 @@ ## Purpose -_Describe the problem or feature in addition to a link to the issues._ - -Example: -Fixes # . +Built announcements and users email lists to post important announcements and allow users to communicate with each other. ## Approach -_How does this change address the problem?_ +Invoke GNU Mailman3 REST API. #### Open Questions and Pre-Merge TODOs -- [ ] Use github checklists. When solved, check the box and explain the answer. +- [ ] Merge [validates email address by sending a confirmation email to users](https://github.com/Murali-group/GraphSpace/pull/368) +- [ ] [Install and Configure Mailman3 Suite for GraphSpace](https://github.com/Murali-group/GraphSpace/wiki/Install-and-Configure-Mailman3-Suite-for-GraphSpace-(Ubuntu-16.04,-PostgreSQL,-Apache2,-Postfix) +- [ ] Create the email lists of GraphSpace and add them to settings file +- [ ] Update the database. ## Learning -_Describe the research stage_ +[Mailman 3 suite documents](http://docs.mailman3.org/en/latest/) +[Install and Configure Mailman3 Suite for GraphSpace](https://github.com/Murali-group/GraphSpace/wiki/Install-and-Configure-Mailman3-Suite-for-GraphSpace-(Ubuntu-16.04,-PostgreSQL,-Apache2,-Postfix) -_Links to blog posts, patterns, libraries or addons used to solve this problem_ #### Blog Posts - [How to Pull Request](https://github.com/flexyford/pull-request) Github Repo with Learning focused Pull Request Template. From 56ba549b2a0ffab554e9baf8054c6f115d4bc26c Mon Sep 17 00:00:00 2001 From: JingVT <33851894+JingVT@users.noreply.github.com> Date: Tue, 14 Aug 2018 10:16:22 -0400 Subject: [PATCH 3/8] Update PULL_REQUEST_TEMPLATE.md --- PULL_REQUEST_TEMPLATE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index e30346ba..2a8ac35d 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -12,6 +12,7 @@ Invoke GNU Mailman3 REST API. ## Learning [Mailman 3 suite documents](http://docs.mailman3.org/en/latest/) + [Install and Configure Mailman3 Suite for GraphSpace](https://github.com/Murali-group/GraphSpace/wiki/Install-and-Configure-Mailman3-Suite-for-GraphSpace-(Ubuntu-16.04,-PostgreSQL,-Apache2,-Postfix) From 73cb7985665e944a5705a29a8c3bfa3c2871dd56 Mon Sep 17 00:00:00 2001 From: JingVT <33851894+JingVT@users.noreply.github.com> Date: Tue, 14 Aug 2018 10:18:51 -0400 Subject: [PATCH 4/8] Update PULL_REQUEST_TEMPLATE.md --- PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index 2a8ac35d..c0312c02 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -6,7 +6,7 @@ Invoke GNU Mailman3 REST API. #### Open Questions and Pre-Merge TODOs - [ ] Merge [validates email address by sending a confirmation email to users](https://github.com/Murali-group/GraphSpace/pull/368) -- [ ] [Install and Configure Mailman3 Suite for GraphSpace](https://github.com/Murali-group/GraphSpace/wiki/Install-and-Configure-Mailman3-Suite-for-GraphSpace-(Ubuntu-16.04,-PostgreSQL,-Apache2,-Postfix) +- [ ] [Install and Configure Mailman3 Suite for GraphSpace](https://github.com/Murali-group/GraphSpace/wiki/Running-GraphSpace-Locally) - [ ] Create the email lists of GraphSpace and add them to settings file - [ ] Update the database. From 4855a7e40e19d20cd21329f912cada34e77debf9 Mon Sep 17 00:00:00 2001 From: JingVT <33851894+JingVT@users.noreply.github.com> Date: Tue, 14 Aug 2018 10:20:15 -0400 Subject: [PATCH 5/8] Update PULL_REQUEST_TEMPLATE.md --- PULL_REQUEST_TEMPLATE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index c0312c02..2160943c 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -6,14 +6,14 @@ Invoke GNU Mailman3 REST API. #### Open Questions and Pre-Merge TODOs - [ ] Merge [validates email address by sending a confirmation email to users](https://github.com/Murali-group/GraphSpace/pull/368) -- [ ] [Install and Configure Mailman3 Suite for GraphSpace](https://github.com/Murali-group/GraphSpace/wiki/Running-GraphSpace-Locally) +- [ ] [Install and Configure Mailman3 Suite for GraphSpace](https://github.com/Murali-group/GraphSpace/wiki/Install-and-Configure-Mailman3-Suite-for-GraphSpace-(Ubuntu-16.04,-PostgreSQL,-Apache2,-Postfix)) - [ ] Create the email lists of GraphSpace and add them to settings file - [ ] Update the database. ## Learning [Mailman 3 suite documents](http://docs.mailman3.org/en/latest/) -[Install and Configure Mailman3 Suite for GraphSpace](https://github.com/Murali-group/GraphSpace/wiki/Install-and-Configure-Mailman3-Suite-for-GraphSpace-(Ubuntu-16.04,-PostgreSQL,-Apache2,-Postfix) +[Install and Configure Mailman3 Suite for GraphSpace](https://github.com/Murali-group/GraphSpace/wiki/Install-and-Configure-Mailman3-Suite-for-GraphSpace-(Ubuntu-16.04,-PostgreSQL,-Apache2,-Postfix)) #### Blog Posts From 71b5aea52da9d77cba7246209713c3de4d8f37b3 Mon Sep 17 00:00:00 2001 From: JingVT <33851894+JingVT@users.noreply.github.com> Date: Tue, 14 Aug 2018 10:32:58 -0400 Subject: [PATCH 6/8] Update PULL_REQUEST_TEMPLATE.md --- PULL_REQUEST_TEMPLATE.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index 2160943c..9de17e17 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -1,20 +1,19 @@ ## Purpose -Built announcements and users email lists to post important announcements and allow users to communicate with each other. +_Describe the problem or feature in addition to a link to the issues._ + +Example: +Fixes # . ## Approach -Invoke GNU Mailman3 REST API. +_How does this change address the problem?_ #### Open Questions and Pre-Merge TODOs -- [ ] Merge [validates email address by sending a confirmation email to users](https://github.com/Murali-group/GraphSpace/pull/368) -- [ ] [Install and Configure Mailman3 Suite for GraphSpace](https://github.com/Murali-group/GraphSpace/wiki/Install-and-Configure-Mailman3-Suite-for-GraphSpace-(Ubuntu-16.04,-PostgreSQL,-Apache2,-Postfix)) -- [ ] Create the email lists of GraphSpace and add them to settings file -- [ ] Update the database. +- [ ] Use github checklists. When solved, check the box and explain the answer. ## Learning -[Mailman 3 suite documents](http://docs.mailman3.org/en/latest/) - -[Install and Configure Mailman3 Suite for GraphSpace](https://github.com/Murali-group/GraphSpace/wiki/Install-and-Configure-Mailman3-Suite-for-GraphSpace-(Ubuntu-16.04,-PostgreSQL,-Apache2,-Postfix)) +_Describe the research stage_ +_Links to blog posts, patterns, libraries or addons used to solve this problem_ #### Blog Posts - [How to Pull Request](https://github.com/flexyford/pull-request) Github Repo with Learning focused Pull Request Template. From b8b9b42d0eed94217e27ff17e721faa3f8051d6d Mon Sep 17 00:00:00 2001 From: jing Date: Sat, 18 Aug 2018 23:44:53 -0400 Subject: [PATCH 7/8] Update shared graphs in group sorting --- applications/graphs/controllers.py | 4 +- applications/users/controllers.py | 62 +++++++++++++++++++++++++----- applications/users/views.py | 9 ++++- 3 files changed, 63 insertions(+), 12 deletions(-) diff --git a/applications/graphs/controllers.py b/applications/graphs/controllers.py index 7f012a05..d52f9c79 100644 --- a/applications/graphs/controllers.py +++ b/applications/graphs/controllers.py @@ -309,11 +309,11 @@ def _convert_order_query_term_to_database_order_object(order_query): def search_graphs_by_group_ids(request, group_ids=None, owner_email=None, names=None, nodes=None, edges=None, tags=None, - limit=None, offset=None): + limit=None, offset=None, order_by=None): if group_ids is None: raise Exception("Atleast one group id is required.") return db.find_graphs(request.db_session, group_ids=group_ids, owner_email=owner_email, names=names, nodes=nodes, - edges=edges, tags=tags, limit=limit, offset=offset) + edges=edges, tags=tags, limit=limit, offset=offset, order_by=order_by) def add_graph_to_group(request, group_id, graph_id): diff --git a/applications/users/controllers.py b/applications/users/controllers.py index be2fe623..87d75c87 100644 --- a/applications/users/controllers.py +++ b/applications/users/controllers.py @@ -8,6 +8,11 @@ from graphspace.exceptions import BadRequest, ErrorCodes from graphspace.utils import generate_uid + +from mailmanclient import Client + +client = Client('http://localhost:8001/3.1', 'restadmin', 'restpass') + # import the logging library import logging @@ -30,13 +35,16 @@ def authenticate_user(request, username=None, password=None): 'id': user.id, 'user_id': user.email, 'password': user.password, - 'admin': user.is_admin + 'admin': user.is_admin, + 'user_account_status':user.user_account_status, + 'email_list_announcement': user.email_list_announcement, + 'email_list_user': user.email_list_user } else: return None -def update_user(request, user_id, email=None, password=None, is_admin=None): +def update_user(request, user_id, email=None, password=None, is_admin=None, user_account_status=None, email_list_announcement=None, email_list_user=None): user = {} if email is not None: user['email'] = email @@ -44,7 +52,18 @@ def update_user(request, user_id, email=None, password=None, is_admin=None): user['password'] = bcrypt.hashpw(password, bcrypt.gensalt()) if is_admin is not None: user['is_admin'] = is_admin - + if user_account_status is not None: + user['user_account_status'] = user_account_status + if email_list_announcement is not None: + user['email_list_announcement'] = email_list_announcement + if email_list_announcement == '1': + client_list_announcement = client.get_list(settings.ANNOUNCEMENTS_LIST) + client_list_announcement.subscribe(email, pre_verified=True, pre_confirmed=True) + if email_list_user is not None: + user['email_list_user'] = email_list_user + if email_list_user == '1': + client_list_user = client.get_list(settings.USERS_LIST) + client_list_user.subscribe(email, pre_verified=True, pre_confirmed=True) return db.update_user(request.db_session, id=user_id, updated_user=user) @@ -126,14 +145,16 @@ def search_users(request, email=None, limit=20, offset=0, order='desc', sort='na return total, users -def register(request, username=None, password=None): +def register(request, username=None, password=None, user_account_status=None, email_confirmation_code=None, email_list_announcement=None, email_list_user=None): if db.get_user(request.db_session, username): raise BadRequest(request, error_code=ErrorCodes.Validation.UserAlreadyExists, args=username) - return add_user(request, email=username, password=password) + return add_user(request, email=username, password=password, user_account_status=user_account_status, + email_confirmation_code=email_confirmation_code, email_list_announcement=email_list_announcement, + email_list_user=email_list_user) -def add_user(request, email=None, password="graphspace_public_user", is_admin=0): +def add_user(request, email=None, password="graphspace_public_user", is_admin=0, user_account_status=None, email_confirmation_code=None, email_list_announcement=None, email_list_user=None): """ Add a new user. If email and password is not passed, it will create a user with default values. By default a user has no admin access. @@ -146,7 +167,9 @@ def add_user(request, email=None, password="graphspace_public_user", is_admin=0) """ email = "public_user_%s@graphspace.com" % generate_uid(size=10) if email is None else email - return db.add_user(request.db_session, email=email, password=bcrypt.hashpw(password, bcrypt.gensalt()), is_admin=is_admin) + return db.add_user(request.db_session, email=email, password=bcrypt.hashpw(password, bcrypt.gensalt()), is_admin=is_admin, + user_account_status=user_account_status, email_confirmation_code=email_confirmation_code, email_list_announcement=email_list_announcement, + email_list_user=email_list_user) def is_member_of_group(request, username, group_id): @@ -267,7 +290,10 @@ def delete_group_member(request, group_id, member_id): return -def search_group_graphs(request, group_id, owner_email, names=None, nodes=None, edges=None, limit=20, offset=0): +def search_group_graphs(request, group_id, owner_email, names=None, nodes=None, edges=None, limit=20, offset=0, order='asc', sort='name'): + sort_attr = getattr(db.Graph, sort if sort is not None else 'name') + orber_by = getattr(db, order if order is not None else 'desc')(sort_attr) + total, group_graphs = graphs.controllers.search_graphs_by_group_ids(request, group_ids=[group_id], owner_email=owner_email, @@ -275,7 +301,8 @@ def search_group_graphs(request, group_id, owner_email, names=None, nodes=None, nodes=nodes, edges=edges, limit=limit, - offset=offset) + offset=offset, + order_by=orber_by) return total, group_graphs @@ -290,6 +317,9 @@ def delete_group_graph(request, group_id, graph_id): def get_password_reset_by_code(request, code): return db.get_password_reset_by_code(request.db_session, code) +def get_email_confirmation_code(request, code): + return db.get_email_confirmation_code(request.db_session, code) + def delete_password_reset_code(request, id): return db.delete_password_reset(request.db_session, id) @@ -312,3 +342,17 @@ def send_password_reset_email(request, password_reset_code): email_from = "GraphSpace Admin" return send_mail(mail_title, message, email_from, [password_reset_code.email], fail_silently=False) + +def send_confirmation_email(request, email, token, email_list_announcement, email_list_user): + # Construct email message + mail_title = 'Activate your account for GraphSpace!' + message = 'Please confirm your email address to complete the registration ' + settings.URL_PATH + 'activate_account/?activation_code=' + token #+ '/?email_list_announcement=' + email_list_announcement + '/?email_list_user=' + email_list_user #str(test_form) + email_from = "GraphSpace Admin" + + return send_mail(mail_title, message, email_from, [email], fail_silently=False) + +#def send_account_creation_confirmation(request, email): + # Construct confimation message + #message = 'Congratuation' + email + '. You have created your account successfully.' +# return HttpResponse(json.dumps(json_success_response(200, message='congraduations')), +# content_type="application/json") diff --git a/applications/users/views.py b/applications/users/views.py index ccc0cd6e..488356b8 100644 --- a/applications/users/views.py +++ b/applications/users/views.py @@ -751,6 +751,10 @@ def _get_group_graphs(request, group_id): Search for graphs with the given node names. In order to search for graphs with either of the given node names as a substring, wrap the node name with percentage symbol. For example, %xyz% will search for all graphs with xyz in their node names. edges : list of strings Search for graphs with the given edges. An edge can be represented as :. In order to perform a substring on edges, wrap the node names with percentage symbol. For example, %xyz%:%abc% will search for all graphs with edges between nodes with xyz in their node names to nodes with abc in their node name. + order : string + Defines the column sort order, can only be 'asc' or 'desc'. + sort : string + Defines which column will be sorted. Parameters ---------- @@ -785,7 +789,10 @@ def _get_group_graphs(request, group_id): nodes=nodes if nodes is None or isinstance(nodes, list) else [nodes], edges=edges if edges is None or isinstance(edges, list) else [edges], limit=request.GET.get('limit', 20), - offset=request.GET.get('offset', 0)) + offset=request.GET.get('offset', 0), + order=request.GET.get('order', 'asc'), + sort=request.GET.get('sort', 'name') + ) return { 'total': total, From f5df53388e9e6217f769c59c5d4cfb014f2d063e Mon Sep 17 00:00:00 2001 From: jing Date: Sat, 18 Aug 2018 23:54:34 -0400 Subject: [PATCH 8/8] Update shared graphs in group sorting --- applications/users/controllers.py | 55 ++++--------------------------- 1 file changed, 7 insertions(+), 48 deletions(-) diff --git a/applications/users/controllers.py b/applications/users/controllers.py index 87d75c87..15e0f581 100644 --- a/applications/users/controllers.py +++ b/applications/users/controllers.py @@ -8,11 +8,6 @@ from graphspace.exceptions import BadRequest, ErrorCodes from graphspace.utils import generate_uid - -from mailmanclient import Client - -client = Client('http://localhost:8001/3.1', 'restadmin', 'restpass') - # import the logging library import logging @@ -35,16 +30,13 @@ def authenticate_user(request, username=None, password=None): 'id': user.id, 'user_id': user.email, 'password': user.password, - 'admin': user.is_admin, - 'user_account_status':user.user_account_status, - 'email_list_announcement': user.email_list_announcement, - 'email_list_user': user.email_list_user + 'admin': user.is_admin } else: return None -def update_user(request, user_id, email=None, password=None, is_admin=None, user_account_status=None, email_list_announcement=None, email_list_user=None): +def update_user(request, user_id, email=None, password=None, is_admin=None): user = {} if email is not None: user['email'] = email @@ -52,18 +44,7 @@ def update_user(request, user_id, email=None, password=None, is_admin=None, user user['password'] = bcrypt.hashpw(password, bcrypt.gensalt()) if is_admin is not None: user['is_admin'] = is_admin - if user_account_status is not None: - user['user_account_status'] = user_account_status - if email_list_announcement is not None: - user['email_list_announcement'] = email_list_announcement - if email_list_announcement == '1': - client_list_announcement = client.get_list(settings.ANNOUNCEMENTS_LIST) - client_list_announcement.subscribe(email, pre_verified=True, pre_confirmed=True) - if email_list_user is not None: - user['email_list_user'] = email_list_user - if email_list_user == '1': - client_list_user = client.get_list(settings.USERS_LIST) - client_list_user.subscribe(email, pre_verified=True, pre_confirmed=True) + return db.update_user(request.db_session, id=user_id, updated_user=user) @@ -145,16 +126,14 @@ def search_users(request, email=None, limit=20, offset=0, order='desc', sort='na return total, users -def register(request, username=None, password=None, user_account_status=None, email_confirmation_code=None, email_list_announcement=None, email_list_user=None): +def register(request, username=None, password=None): if db.get_user(request.db_session, username): raise BadRequest(request, error_code=ErrorCodes.Validation.UserAlreadyExists, args=username) - return add_user(request, email=username, password=password, user_account_status=user_account_status, - email_confirmation_code=email_confirmation_code, email_list_announcement=email_list_announcement, - email_list_user=email_list_user) + return add_user(request, email=username, password=password) -def add_user(request, email=None, password="graphspace_public_user", is_admin=0, user_account_status=None, email_confirmation_code=None, email_list_announcement=None, email_list_user=None): +def add_user(request, email=None, password="graphspace_public_user", is_admin=0): """ Add a new user. If email and password is not passed, it will create a user with default values. By default a user has no admin access. @@ -167,9 +146,7 @@ def add_user(request, email=None, password="graphspace_public_user", is_admin=0, """ email = "public_user_%s@graphspace.com" % generate_uid(size=10) if email is None else email - return db.add_user(request.db_session, email=email, password=bcrypt.hashpw(password, bcrypt.gensalt()), is_admin=is_admin, - user_account_status=user_account_status, email_confirmation_code=email_confirmation_code, email_list_announcement=email_list_announcement, - email_list_user=email_list_user) + return db.add_user(request.db_session, email=email, password=bcrypt.hashpw(password, bcrypt.gensalt()), is_admin=is_admin) def is_member_of_group(request, username, group_id): @@ -289,7 +266,6 @@ def delete_group_member(request, group_id, member_id): db.delete_group_to_user(request.db_session, group_id=group_id, user_id=member_id) return - def search_group_graphs(request, group_id, owner_email, names=None, nodes=None, edges=None, limit=20, offset=0, order='asc', sort='name'): sort_attr = getattr(db.Graph, sort if sort is not None else 'name') orber_by = getattr(db, order if order is not None else 'desc')(sort_attr) @@ -317,9 +293,6 @@ def delete_group_graph(request, group_id, graph_id): def get_password_reset_by_code(request, code): return db.get_password_reset_by_code(request.db_session, code) -def get_email_confirmation_code(request, code): - return db.get_email_confirmation_code(request.db_session, code) - def delete_password_reset_code(request, id): return db.delete_password_reset(request.db_session, id) @@ -342,17 +315,3 @@ def send_password_reset_email(request, password_reset_code): email_from = "GraphSpace Admin" return send_mail(mail_title, message, email_from, [password_reset_code.email], fail_silently=False) - -def send_confirmation_email(request, email, token, email_list_announcement, email_list_user): - # Construct email message - mail_title = 'Activate your account for GraphSpace!' - message = 'Please confirm your email address to complete the registration ' + settings.URL_PATH + 'activate_account/?activation_code=' + token #+ '/?email_list_announcement=' + email_list_announcement + '/?email_list_user=' + email_list_user #str(test_form) - email_from = "GraphSpace Admin" - - return send_mail(mail_title, message, email_from, [email], fail_silently=False) - -#def send_account_creation_confirmation(request, email): - # Construct confimation message - #message = 'Congratuation' + email + '. You have created your account successfully.' -# return HttpResponse(json.dumps(json_success_response(200, message='congraduations')), -# content_type="application/json")