-
Notifications
You must be signed in to change notification settings - Fork 40
GraphSpace Email Lists #393
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
Open
JingVT
wants to merge
31
commits into
Murali-group:develop
Choose a base branch
from
JingVT:GraphSpace_email_lists
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
e30eed4
Create PULL_REQUEST_TEMPLATE.md
adbharadwaj 52ddf6e
Changes for controllers.py
JingVT a0bf6a7
Changes in model for email lists features
JingVT 462358e
Update activate account page
JingVT ff7dafe
Update templates
JingVT 6198a53
Update log in js file
JingVT 052c249
Add mailmanclient to requirements
JingVT 670cd44
Add email lists docs
JingVT d132866
Add email lists settings
JingVT 4e179b5
Update local.py
JingVT 9cc9572
Update local.py
JingVT 9d7321c
Update views.py
JingVT 499d9cf
Update templates
JingVT 5328d0f
Update views.py
JingVT 382ca36
Update PULL_REQUEST_TEMPLATE.md
JingVT 40aeb5b
Update PULL_REQUEST_TEMPLATE.md
JingVT d3201f4
Add email lists docs images
JingVT d921ae7
Change data type
JingVT 5196423
Change data type
JingVT 12e361a
change '1' to 1
JingVT f5a6d6d
Change '1' to 1
JingVT 3c28afc
Update local.py
JingVT 5909b49
Update local.py
JingVT 43e0f70
Update local.py
JingVT 63d8c6f
Update local.py
JingVT 752c508
Update local.py
JingVT 9a33289
Update local.py
JingVT 45c5b02
Update models.py
JingVT 0f443ec
Update requirements.txt
JingVT 235b064
Update controllers.py
JingVT 43ec81e
Update dal.py
JingVT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| ## Purpose | ||
| Built announcements and users email lists to post important announcements and allow users to communicate with each other. | ||
|
|
||
| ## Approach | ||
| 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)) | ||
| - [ ] 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)) | ||
|
|
||
|
|
||
| #### Blog Posts | ||
| - [How to Pull Request](https://github.com/flexyford/pull-request) Github Repo with Learning focused Pull Request Template. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,13 @@ | |
| from graphspace.exceptions import BadRequest, ErrorCodes | ||
| from graphspace.utils import generate_uid | ||
|
|
||
| # The mailmanclient library provides official Python bindings for the GNU Mailman 3 REST API. | ||
| from mailmanclient import Client | ||
|
|
||
| # In order to talk to Mailman, the engine's REST server must be running. | ||
| # Begin by instantiating a client object to access the root of the REST hierarchy, providing it the base URL, user name and password (for Basic Auth) | ||
| client = Client('http://localhost:8001/3.1', 'restadmin', 'restpass') | ||
|
|
||
| # import the logging library | ||
| import logging | ||
|
|
||
|
|
@@ -30,21 +37,35 @@ 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 | ||
| if password is not 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 +147,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. | ||
|
|
@@ -142,11 +165,17 @@ def add_user(request, email=None, password="graphspace_public_user", is_admin=0) | |
| :param email: User ID of the user. Default value is dynamically generated user id. | ||
| :param password: Password of the user. Default value is "public". | ||
| :param admin: 1 if user has admin access else 0. Default value is 0. | ||
| :param user_account_status: 1 if the user has created account successfully else 0. | ||
| :param email_confirmation_code: confirmation code sent to email when the user creates account | ||
| :param email_list_announcement: 1 if the user has chosen to join GraphSpace announcement email list else 0 | ||
| :param email_list_user: 1 if the user has chosen to join GraphSpace users email list else 0 | ||
| :return: User | ||
| """ | ||
| email = "public_user_%[email protected]" % 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): | ||
|
|
@@ -290,6 +319,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 +344,12 @@ 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_from = "GraphSpace Admin" | ||
|
|
||
| return send_mail(mail_title, message, email_from, [email], fail_silently=False) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,13 +17,21 @@ class User(IDMixin, TimeStampMixin, Base): | |
| :param email: Email ID of the user. | ||
| :param password: Password of the user. | ||
| :param admin: 1 if the user has admin access else 0. | ||
| :param user_account_status: 1 if the user has created account successfully else 0. | ||
| :param email_confirmation_code: confirmation code sent to email when the user creates account | ||
| :param email_list_announcement: 1 if the user has chosen to join GraphSpace announcement email list else 0 | ||
| :param email_list_user: 1 if the user has chosen to join GraphSpace users email list else 0 | ||
| """ | ||
| __tablename__ = "user" | ||
|
|
||
| email = Column(String, nullable=False, unique=True, index=True) | ||
| password = Column(String, nullable=False) | ||
| is_admin = Column(Integer, nullable=False, default=0) | ||
|
|
||
| user_account_status = Column(Integer, nullable=False, default=0) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add documentation about the newly added fields? Since account status is integer what are the possible values and what they mean? |
||
| email_confirmation_code = Column(String, nullable=False, default=0) | ||
| email_list_announcement = Column(Integer, nullable=False, default=0) | ||
| email_list_user = Column(Integer, nullable=False, default=0) | ||
|
|
||
| password_reset_codes = relationship("PasswordResetCode", back_populates="user", cascade="all, delete-orphan") | ||
| owned_groups = relationship("Group", back_populates="owner", cascade="all, delete-orphan") | ||
| owned_graphs = relationship("Graph", back_populates="owner", cascade="all, delete-orphan") | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
|
|
||
| # Email Lists for GraphSpace | ||
|
|
||
| [GraphSpace](http://graphspace.org) built announcements and users email lists to post important announcements and allow users to communicate with each other. | ||
|
|
||
| ## Users Email List for GraphSpace | ||
| The users list is meant for all users of GraphSpace to communicate with each other and with the GraphSpace administrators. Please use this list to pose questions about GraphSpace, discuss any problems you may have, give us feedback, request features etc. | ||
|
|
||
| ### Subscribe | ||
| To subscribe you can choose "Please add me to the users email list for GraphSpace" when create account, | ||
|
|
||
|  | ||
|
|
||
| or send an email with 'subscribe' in the subject to [[email protected]](mailto:[email protected]). | ||
|
|
||
| ### Unsubscribe | ||
| To unsubscribe from users list, send an email with 'unsubscribe' in the subject to [[email protected]](mailto:[email protected]). | ||
|
|
||
| ### Post | ||
| To post to users list, send your email to [[email protected]](mailto:[email protected]). | ||
|
|
||
| ### Archives | ||
| You can access the [archives](http://email.graphspace.org/hyperkitty/list/[email protected]/) of the users list. | ||
|
|
||
| ## Announcements Email List for GraphSpace | ||
| The GraphSpace administrators will use this list to post important announcements about GraphSpace. Note that you will not be able to post to this mailing list. If you have a question about GraphSpace, please join the graphspace-users mailing list and post there. | ||
|
|
||
| ### Subscribe | ||
| To subscribe you can choose "Please add me to the announcements email list for GraphSpace" when create account, | ||
|
|
||
|  | ||
|
|
||
| or send an email with 'subscribe' in the subject to [[email protected]](mailto:[email protected]). | ||
|
|
||
| ### Unsubscribe | ||
| To unsubscribe from announcements list, send an email with 'unsubscribe' in the subject to [[email protected]](mailto:[email protected]). | ||
|
|
||
| ### Archives | ||
| You can access the [archives](http://email.graphspace.org/hyperkitty/list/[email protected]/) of the announcements list. |
Binary file added
BIN
+24.9 KB
docs/_static/images/email-list/gs-Screenshot-register-announcements-email-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+22.3 KB
docs/_static/images/email-list/gs-Screenshot-register-users-email-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,10 @@ | |
| # Path to GraphSPace | ||
| PATH = "/Path_to_GraphSpace" | ||
|
|
||
| # Email lists of graphspace | ||
| ANNOUNCEMENTS_LIST = '[email protected]' | ||
| USERS_LIST = '[email protected]' | ||
|
|
||
| # SHOULD NEVER CHANGE THIS VALUE | ||
| SECRET_KEY = 'this-is-a-secret-key-for-local-settings-only' | ||
|
|
||
|
|
@@ -45,4 +49,4 @@ | |
| 'HOST': 'localhost', | ||
| 'PORT': '5432' | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,3 +28,4 @@ elasticsearch-dsl>=5.0.0,<6.0.0 | |
| sphinx-rtd-theme | ||
| sphinx | ||
| recommonmark | ||
| mailmanclient==3.1.1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you merge the latest changes to develop branches on Main repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to merge validates email address by sending a confirmation email to users, before merging email lists. Do you mind to review pull#238 before I merge it? Thank you.