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

Added: Table.jsx to Dashboard #9

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
85 changes: 77 additions & 8 deletions project_guide/Venv_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <myproject>
cd <myproject>
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 <version>`

The new python version should be installed in the directory `~/.pyenv/versions/<version>`

## 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 <python file location> <virtual environment name>`

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.
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
28 changes: 28 additions & 0 deletions src/client/README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
7 changes: 7 additions & 0 deletions src/client/src/routes/Dashboard/Table.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from "react";

const Table = () => {
return <div>Table</div>;
};

export default Table;
43 changes: 40 additions & 3 deletions src/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -54,7 +56,7 @@
##### 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
Expand Down Expand Up @@ -228,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,
Expand Down Expand Up @@ -300,3 +302,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 push 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