From d5c1916105889cea11717e748a4ed62769f62409 Mon Sep 17 00:00:00 2001 From: Parth Date: Fri, 3 Jan 2020 11:54:20 +0530 Subject: [PATCH 1/5] Update: Documentation --- src/client/README.md | 28 ++++++++++++++++++++++++++++ src/server/README.md | 2 ++ 2 files changed, 30 insertions(+) diff --git a/src/client/README.md b/src/client/README.md index 1b6eeaf..43617f1 100644 --- a/src/client/README.md +++ b/src/client/README.md @@ -1,5 +1,33 @@ # React Project Template +## Folder structure: + +``` +├── /build/ # compiled output +├── /docs/ # Documentation files +├── /node_modules/ # 3rd party lib +├── /public/ # Static files +├── /src/ # The source code of the application +├───── /components/ # React components +├──────├──────/admin # dashboard, admin +├──────├──────/common # shared components +├──────├──────/icons # icons +├──────├──────/news # news specific components +├──────├──────/static # static page +├────── redux/ # redux (Seperate into sub folders based on functions as well as complexity rises) +├──────├──────/actions # action types, action creators +├──────├──────/reducers # reducers +├──────├──────store.js # store.js +├────── /utils/ # server schema and data models +├────── /routes/ # Routes/Page files +├────── /clientScript.js # Client-side startup script +├────── /config.js # application settings +├────── ... +├── /test/ # Unit tests +├── package.json +└── yarn.lock +``` + ## Instructions 1. Install the necessary dependencies. diff --git a/src/server/README.md b/src/server/README.md index 4c9bb16..c67a944 100644 --- a/src/server/README.md +++ b/src/server/README.md @@ -3,6 +3,8 @@ ## Requirements 1. Setup the database server based on the project requirement +For MySQL installation refer to [this](https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-18-04) link. + ### After cloning follow the steps to setup 1. Create virtual environment with `pipenv/virtualenv` for python version 3.7.3 (or higher), visit this [link](https://github.com/masai-oss/open-template/wiki/Virtual-Environment-Guide) for Virtualenv Guide. From 6a7a48256d41f660eeae5908fb34693d788d41e0 Mon Sep 17 00:00:00 2001 From: Parth Date: Fri, 3 Jan 2020 16:17:16 +0530 Subject: [PATCH 2/5] Update: Documentation --- README.md | 2 + project_guide/Venv_guide.md | 85 +++++++++++++++++++++++++++++++++---- src/server/README.md | 13 ++++-- 3 files changed, 88 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index d83e9e0..cbe3630 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,9 @@ https://github.com/masai-oss/open-template/wiki/Backend-Guide ​ ### Frontend Guide https://github.com/masai-oss/open-template/wiki/Frontend-Guide + https://github.com/masai-oss/open-template/wiki/Cypress-Guide + https://github.com/masai-oss/open-template/wiki/OAuth-Guide ​ It is very important to read these documents throughly before starting to code. \ No newline at end of file diff --git a/project_guide/Venv_guide.md b/project_guide/Venv_guide.md index d6f8acf..24784df 100644 --- a/project_guide/Venv_guide.md +++ b/project_guide/Venv_guide.md @@ -4,19 +4,88 @@ Virtual environments are independent groups of Python libraries, one for each pr Python 3 comes bundled with the venv module to create virtual environments. -## Create an environment -Create a project folder and a venv folder within. +## Install pyenv + +To manage multiple versions of python the most popular app is pyenv: + +#### Install dependencies +```bash +sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \ +libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \ +libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl ``` -mkdir -cd -python3 -m venv venv + +#### Install pyenv + +1. `curl https://pyenv.run | bash` + + you should see a message like + +```shell +WARNING: seems you still have not added 'pyenv' to the load path. + +# Load pyenv automatically by adding +# the following to ~/.bashrc: + +export PATH="$HOME/.pyenv/bin:$PATH" +eval "$(pyenv init -)" +eval "$(pyenv virtualenv-init -)" ``` -### Activate the environment -Before you work on your project, activate the corresponding environment: + 2. `nano ~/.bashrc` + 3. paste the message into the file + 4. restart the shell + +P.S if you're using other shell like `zsh` replace the `bash` and `bashrc` accordingly + +#### Install python version + +`pyenv install ` + +The new python version should be installed in the directory `~/.pyenv/versions/` + +## Create an environment +One of the most popular virtual environment manager is `virtualenv` + +### Install `virtualenv` +##### Install pip + +```shell +sudo apt-get install python3-pip ``` + +##### Install `virtualenv ` using `pip3` + +`sudo pip3 install virtualenv` + +##### Create virtual environment + +1. It's recommended to create the virtual environment in their respective folder + +2. `virtualenv -p ` + + ex: + + ​ `virtualenv -p ~/.pyenv/versions/3.7.3/bin/python venv` + +##### Activate the environment +Before you work on your project, activate the corresponding environment: + +```shell source venv/bin/activate ``` -Your terminal will change to show the name of the activated environment. \ No newline at end of file +Your terminal will change to show the name of the activated environment. + +##### Deactivate the environment + +`deactivate` + +### Create `requirements.txt` + +You need `requirements.txt` file to keep track of all the installed packages in your app to create it, follow the following steps + +1. activate the virtual environment +2. `pip freeze` This command shows you all the packages in your virtual environment +3. `pip freeze > requirements.txt`redirects all the package names with their versions into the `requirements.txt` file \ No newline at end of file diff --git a/src/server/README.md b/src/server/README.md index c67a944..646fbf5 100644 --- a/src/server/README.md +++ b/src/server/README.md @@ -3,7 +3,7 @@ ## Requirements 1. Setup the database server based on the project requirement -For MySQL installation refer to [this](https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-18-04) link. + For MySQL installation refer to [this](https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-18-04) link. ### After cloning follow the steps to setup @@ -56,7 +56,7 @@ For MySQL installation refer to [this](https://www.digitalocean.com/community/tu ##### To change the DB settings 1. Create data-base in respective server -2. Open the `settings.py` in the src/server/app/main/ folder +2. Open the `settings.py` in the `src/server/app/main/ ` 3. Change the database URI in `SQLALCHEMY_DATABASE_URI` based on the development env ##### To create migrations folder @@ -230,8 +230,8 @@ from flask import g oauth = OAuth() github = oauth.remote_app('github', - consumer_key="c1d53a4b044962c3379a", - consumer_secret="a2b7acacd1b94dde26fc1dae18b8c6e7f9e1f22f", + consumer_key="", + consumer_secret="", request_token_params={"scope": "user:email"}, base_url="https://api.github.com/", request_token_url=None, @@ -302,3 +302,8 @@ Add the required tokens/credentials as specified under `SECRET_KEYS` in `setting ``` + +### Few things to keep in mind + +1. Run the command `make clean`to clear out all the `__pycache__` folders and files, before you psuh files to github +2. Follow `pep8` rules to avoid commit issues \ No newline at end of file From c385c3b121ad218a4a084331d0256cc7ae18a48a Mon Sep 17 00:00:00 2001 From: codehia Date: Fri, 3 Jan 2020 19:38:12 +0530 Subject: [PATCH 3/5] added static folder --- src/server/README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/server/README.md b/src/server/README.md index 946be53..41a9f1e 100644 --- a/src/server/README.md +++ b/src/server/README.md @@ -304,3 +304,38 @@ Add the required tokens/credentials as specified under `SECRET_KEYS` in `setting ``` +### Few things to keep in mind + +1. Run the command `make clean`to clear out all the `__pycache__` folders and files, before you psuh files to github + +2. Follow `pep8` rules to avoid commit issues including the docstrings in google format + + Example for methods: + + ```python + """method to add todo to the model Todo + Args: + data (dict): data which needs to be stored into Todo table + using Todo model + Returns: + dict: response object containing appropriate response based on the response from save changes, + int: http response code specifying the success or failure of storing data into table + """ + ``` + + + + Example for classes: + + ```python + """SQLAlchemy model for Todo items + containing fileds id and todo_item + id: unique identifier + todo_item: the todo item to be added to the database + Args: + db (object): SQLAlchemy object imported from main + """ + ``` + +3. Add docstrings to the file to describe the function of the file in brief +4. Add your static files to `server/src/app/main/static` folder \ No newline at end of file From 43263c676d4abe97fc4ca2f2c89dd2e766f5555f Mon Sep 17 00:00:00 2001 From: ravipgornal Date: Mon, 6 Jan 2020 15:29:29 +0530 Subject: [PATCH 4/5] first commit --- src/client/src/routes/Dashboard/Sample.jsx | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/client/src/routes/Dashboard/Sample.jsx diff --git a/src/client/src/routes/Dashboard/Sample.jsx b/src/client/src/routes/Dashboard/Sample.jsx new file mode 100644 index 0000000..4c27e69 --- /dev/null +++ b/src/client/src/routes/Dashboard/Sample.jsx @@ -0,0 +1,7 @@ +import React from "react"; + +const Sample = () => { + return
Sample
; +}; + +export default Sample; From dfc78052e5df37d9cb84879808a87a025beca04c Mon Sep 17 00:00:00 2001 From: ravipgornal Date: Mon, 6 Jan 2020 15:37:50 +0530 Subject: [PATCH 5/5] Added Ranking Module for Test --- src/client/src/routes/Dashboard/Ranking.jsx | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/client/src/routes/Dashboard/Ranking.jsx diff --git a/src/client/src/routes/Dashboard/Ranking.jsx b/src/client/src/routes/Dashboard/Ranking.jsx new file mode 100644 index 0000000..9096f1d --- /dev/null +++ b/src/client/src/routes/Dashboard/Ranking.jsx @@ -0,0 +1,7 @@ +import React from "react"; + +const Ranking = () => { + return
Ranking Page
; +}; + +export default Ranking;