Skip to content

Commit

Permalink
Merge branch 'develop' into docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
epicadk authored Apr 15, 2021
2 parents f9baf2f + 9571c86 commit 591ade0
Show file tree
Hide file tree
Showing 84 changed files with 12,745 additions and 116 deletions.
66 changes: 66 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"files": [
"README.md"
],
"imageSize": 100,
"contributorsPerLine": 7,
"contributorsSortAlphabetically": false,
"badgeTemplate": "[![All Contributors](https://img.shields.io/badge/all_contributors-<%= contributors.length %>-orange.svg?style=flat-square)](#contributors)",
"skipCi": true,
"contributors": [
{
"login": "isabelcosta",
"name": "Isabel Costa",
"avatar_url": "https://avatars.githubusercontent.com/u/11148726?v=4",
"profile": "https://isabelcosta.github.io/",
"contributions": [
"maintenance"
]
},
{
"login": "vj-codes",
"name": "Vaishnavi Joshi",
"avatar_url": "https://avatars.githubusercontent.com/u/60894542?v=4",
"profile": "https://github.com/vj-codes",
"contributions": [
"maintenance",
"design"
]
},
{
"login": "epicadk",
"name": "Aditya Kurkure",
"avatar_url": "https://avatars.githubusercontent.com/u/56596662?v=4",
"profile": "https://github.com/epicadk",
"contributions": [
"code",
"maintenance",
"test"
]
},
"login": "devkapilbansal",
"name": "Kapil Bansal",
"avatar_url": "https://avatars.githubusercontent.com/u/42766576?v=4",
"profile": "https://github.com/devkapilbansal",
"contributions": [
"code",
"maintenance",
"test"
]
},
{
"login": "gaurivn",
"name": "Gauri V. Nair",
"avatar_url": "https://avatars.githubusercontent.com/u/48416306?v=4",
"profile": "https://github.com/gaurivn",
"contributions": [
"code",
"maintenance"
]
}
],
"projectName": "mentorship-backend",
"projectOwner": "anitab-org",
"repoType": "github",
"repoHost": "https://github.com"
}
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[run]
omit =
# omit everything in the tests directory
tests/*
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* When submitting a PR with changes to user interface (e.g.: new screen, or an email template), please add screenshots to the PR description.
* When you are finished with your work, please squash your commits otherwise we will squash them on your PR (this can help us maintain a clear commit history).
* When writing in-code documentation as Docstrings, please follow [this guide](https://github.com/google/styleguide/blob/gh-pages/pyguide.md#38-comments-and-docstrings).
* When creating an issue to report a bug in the project, please follow our [bug_report.md](ISSUE_TEMPLATE/bug_report.md) template.
* When creating an issue to report a bug in the project, please follow our [bug_report.md](https://github.com/anitab-org/.github/blob/main/.github/ISSUE_TEMPLATE/bug_report.md) template.

## General Guidelines

Expand Down
20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/black.yml

This file was deleted.

55 changes: 55 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: documentation

on:
pull_request:
branches: [develop]
push:
branches: [develop]

jobs:
checks:
if: github.event_name != 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Test Build
run: |
cd docs/
if [ -e yarn.lock ]; then
yarn install --frozen-lockfile
elif [ -e package-lock.json ]; then
npm ci
else
npm i
fi
npm run build
gh-release:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.GH_PAGES_DEPLOY }}
- name: Release to GitHub Pages
env:
USE_SSH: true
GIT_USER: git
run: |
git config --global user.email "[email protected]"
git config --global user.name "gh-actions"
cd docs/
if [ -e yarn.lock ]; then
yarn install --frozen-lockfile
elif [ -e package-lock.json ]; then
npm ci
else
npm i
fi
npm run deploy
19 changes: 13 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Run tests
name: Lint Code and Run Tests

on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
branches: [develop]
push:
branches: [develop]

jobs:
build:

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: psf/black@stable

build:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Run tests
run: |
make docker_test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,7 @@ venv.bak/

# aws-eb
.elasticbeanstalk/

# docusaurus
docs/.docusaurus
docs/node_modules
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![codecov](https://codecov.io/gh/anitab-org/mentorship-backend/branch/develop/graph/badge.svg)](https://codecov.io/gh/anitab-org/mentorship-backend)
[![project chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://anitab-org.zulipchat.com/#narrow/stream/222534-mentorship-system)
[![Python 3.x](https://img.shields.io/badge/python-3.x-blue.svg)](https://www.python.org/downloads/)
[![Docs](https://img.shields.io/badge/documentation-mentorship--backend-blue.svg)](https://anitab-org.github.io/mentorship-backend)


Mentorship System is an application that allows women in tech to mentor each other, on career development topics, through 1:1 relations for a certain period.
Expand All @@ -16,6 +17,7 @@ This API is being used by 3 frontend projects currently being developed:

**Table of Contents**

- [Features](#Features)
- [Setup and run](#setup-and-run)
- [Run app in Windows](#run-app-in-Windows)
- [Run app in Linux](#run-app-in-Linux)
Expand All @@ -27,6 +29,21 @@ This API is being used by 3 frontend projects currently being developed:
- [Contact](#contact)
- [License](#license)

## Features

- Login and register a new user
- Create a user profile, view and edit user profiles
- Change user password, refresh jwt tokens
- Create relation between two users with a fixed period of time
- Both mentor and mentee in a relation can create tasks
- Assign and remove admin roles to users and list all admins
- List all the relationships of a given user
- List details of current, past and pending mentorship relations
- Create a new task in a mentorship relation if the specified user is already involved in it.
- Retrieve and delete tasks from mentorship relation
- Task comment functionalities like create a task comment, get task comments using a task id.
- Get statistics of a user like Pending Requests, Accepted Requests, Rejected Requests, Completed Relations, Cancelled Relations and upto 3 recent achievements

## Setup and run

To setup the project locally read these wiki pages and follow the instructions:
Expand Down Expand Up @@ -194,6 +211,8 @@ black .

## Documentation

Documentation for the project is hosted [here](https://anitab-org.github.io/mentorship-backend/). We use Docusaurus for maintaining the documentation of the project.

You can learn more about this project through the documentation in the [docs](./docs) folder and on [our Wiki](https://github.com/anitab-org/mentorship-backend/wiki).

- **Language:** Python 3
Expand All @@ -219,6 +238,31 @@ Please read our [Contributing guidelines](./.github/CONTRIBUTING.md), [Code of C

Please follow our [Commit Message Style Guide](https://github.com/anitab-org/mentorship-backend/wiki/Commit-Message-Style-Guide) and [Coding Standards](./docs/coding_standards.md) while sending PRs.

### Contributors

Thanks goes to these people ([emoji key](https://github.com/all-contributors/all-contributors#emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://isabelcosta.github.io/"><img src="https://avatars.githubusercontent.com/u/11148726?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Isabel Costa</b></sub></a><br /><a href="#maintenance-isabelcosta" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/vj-codes"><img src="https://avatars.githubusercontent.com/u/60894542?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vaishnavi Joshi</b></sub></a><br /><a href="#maintenance-vj-codes" title="Maintenance">🚧</a> <a href="#design-vj-codes" title="Design">🎨</a></td>
<td align="center"><a href="https://github.com/epicadk"><img src="https://avatars.githubusercontent.com/u/56596662?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aditya Kurkure</b></sub></a><br /><a href="https://github.com/anitab-org/mentorship-backend/commits?author=epicadk" title="Code">💻</a> <a href="#maintenance-epicadk" title="Maintenance">🚧</a> <a href="https://github.com/anitab-org/mentorship-backend/commits?author=epicadk" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/devkapilbansal"><img src="https://avatars.githubusercontent.com/u/42766576?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kapil Bansal</b></sub></a><br /><a href="https://github.com/anitab-org/mentorship-backend/commits?author=devkapilbansal" title="Code">💻</a> <a href="#maintenance-devkapilbansal" title="Maintenance">🚧</a> <a href="https://github.com/anitab-org/mentorship-backend/commits?author=devkapilbansal" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/gaurivn"><img src="https://avatars.githubusercontent.com/u/48416306?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gauri V. Nair</b></sub></a><br /><a href="https://github.com/anitab-org/mentorship-backend/commits?author=gaurivn" title="Code">💻</a> <a href="#maintenance-gaurivn" title="Maintenance">🚧</a></td>
</tr>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification.
Contributions of any kind welcome!

## Branches

The repository has the following permanent branches:
Expand All @@ -227,6 +271,10 @@ The repository has the following permanent branches:

* **develop** This contains the latest code. All the contributing PRs must be sent to this branch. When we want to release the next version of the app, this branch is merged into the `master` branch. This is the branch that is used in the deployed version of the app on Heroku.

* **bit** This branch is for MS-backend version specific to [BridgeInTech](https://github.com/anitab-org/bridge-in-tech-backend) project. All the contributing PRs related to BIT-MS integration issue must be sent to this branch.<br>
**IMPORTANT!!** If this is your first time setting up the BridgeInTech project, please <b>DO NOT RUN</b> the MS backend server from this branch <b>BEFORE</b> you run the BIT backend server. Failing to do this will mess up the postgres db schemas used in BIT project. More instruction on setting up the BridgeInTech project can be found [here](https://github.com/anitab-org/bridge-in-tech-backend/blob/develop/.github/ENV_SETUP_INSTRUCTION.md).


## Contact

You can reach the maintainers and our community on [AnitaB.org Open Source Zulip](https://anitab-org.zulipchat.com/). If you are interested in contributing to the mentorship system, we have a dedicated stream for this project [#mentorship-system](https://anitab-org.zulipchat.com/#narrow/stream/222534-mentorship-system), where you can ask questions and interact with the community, join with us!
Expand Down
8 changes: 4 additions & 4 deletions app/api/dao/mentorship_relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def create_mentorship_relation(self, user_id: int, data: Dict[str, str]):
except ValueError:
return messages.INVALID_END_DATE, HTTPStatus.BAD_REQUEST

now_datetime = datetime.now()
now_datetime = datetime.utcnow()
if end_date_datetime < now_datetime:
return messages.END_TIME_BEFORE_PRESENT, HTTPStatus.BAD_REQUEST

Expand Down Expand Up @@ -110,7 +110,7 @@ def create_mentorship_relation(self, user_id: int, data: Dict[str, str]):
action_user_id=action_user_id,
mentor_user=mentor_user,
mentee_user=mentee_user,
creation_date=datetime.now().timestamp(),
creation_date=datetime.utcnow().timestamp(),
end_date=end_date_timestamp,
state=MentorshipRelationState.PENDING,
notes=notes,
Expand Down Expand Up @@ -361,7 +361,7 @@ def list_past_mentorship_relations(user_id: int):
"""

user = UserModel.find_by_id(user_id)
now_timestamp = datetime.now().timestamp()
now_timestamp = datetime.utcnow().timestamp()
past_relations = list(
filter(
lambda relation: relation.end_date < now_timestamp,
Expand Down Expand Up @@ -409,7 +409,7 @@ def list_pending_mentorship_relations(user_id: int):
"""

user = UserModel.find_by_id(user_id)
now_timestamp = datetime.now().timestamp()
now_timestamp = datetime.utcnow().timestamp()
pending_requests = []
all_relations = user.mentor_relations + user.mentee_relations

Expand Down
8 changes: 5 additions & 3 deletions app/api/dao/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def create_task(user_id: int, mentorship_relation_id: int, data: Dict[str, str])
HTTPStatus.FORBIDDEN,
)

now_timestamp = datetime.now().timestamp()
now_timestamp = datetime.utcnow().timestamp()
relation.tasks_list.add_task(description=description, created_at=now_timestamp)
relation.tasks_list.save_to_db()

Expand Down Expand Up @@ -154,10 +154,12 @@ def complete_task(user_id: int, mentorship_relation_id: int, task_id: int):
return messages.TASK_DOES_NOT_EXIST, HTTPStatus.NOT_FOUND

if task.get("is_done"):
return messages.TASK_WAS_ALREADY_ACHIEVED, HTTPStatus.FORBIDDEN
return messages.TASK_WAS_ALREADY_ACHIEVED, HTTPStatus.CONFLICT
else:
relation.tasks_list.update_task(
task_id=task_id, is_done=True, completed_at=datetime.now().timestamp()
task_id=task_id,
is_done=True,
completed_at=datetime.utcnow().timestamp(),
)

return messages.TASK_WAS_ACHIEVED_SUCCESSFULLY, HTTPStatus.OK
7 changes: 2 additions & 5 deletions app/api/dao/task_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,5 @@ def delete_comment(user_id, _id, task_id, relation_id):
HTTPStatus.NOT_FOUND,
)

if task_comment:
task_comment.delete_from_db()
return messages.TASK_COMMENT_WAS_DELETED_SUCCESSFULLY, HTTPStatus.OK

return messages.TASK_COMMENT_DOES_NOT_EXIST, HTTPStatus.NOT_FOUND
task_comment.delete_from_db()
return messages.TASK_COMMENT_WAS_DELETED_SUCCESSFULLY, HTTPStatus.OK
2 changes: 1 addition & 1 deletion app/api/dao/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def confirm_registration(token: str):
return messages.ACCOUNT_ALREADY_CONFIRMED, HTTPStatus.OK
else:
user.is_email_verified = True
user.email_verification_date = datetime.now()
user.email_verification_date = datetime.utcnow()
user.save_to_db()
return messages.ACCOUNT_ALREADY_CONFIRMED_AND_THANKS, HTTPStatus.OK

Expand Down
Loading

0 comments on commit 591ade0

Please sign in to comment.