Skip to content
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
Binary file modified .coverage
Binary file not shown.
Binary file not shown.
Binary file not shown.
21 changes: 20 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,39 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/psf/black
rev: 20.8b1
rev: stable
hooks:
- id: black
args: # arguments to configure black
- --line-length=100
- --exclude="""\.git |
\.__pycache__|
\.mypy_cache|
\.tox|
\.python-version|
_build|
build|
dist
"""
description: "Formatting code"
language: python
language_version: 3.8.5
- repo: https://github.com/PyCQA/flake8
rev: 3.8.4
hooks:
- id: flake8
args: # arguments to configure flake8
- "--max-line-length=100"
- "--max-complexity=18"
- "--ignore=E203,E266,E501,W503,F403,F401,E402"
description: "Styling guide enforcement"
language: python
language_version: 3.8.5
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.790'
hooks:
- id: mypy
- repo: https://github.com/pre-commit/mirrors-isort
rev: '' # Use the revision sha / tag you want to point at
hooks:
- id: isort
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ install: # install the dependencies

test: # run test coverage
@echo "testing ..."
${RUN} pytest --cov=. --cov-report html
${RUN} run pytest --cov=. --cov-report html --hypothesis-show-statistics

quality: # run test, formating the code, check for typing, check if the code is safe
@echo "check for linting, Typing, code formating, safety"
Expand Down
32 changes: 31 additions & 1 deletion ajo/home/home.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from fastapi import APIRouter, Request
from datetime import date

from fastapi import APIRouter, Form, Request
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates

from .salary import Salary

router = APIRouter()

templates = Jinja2Templates(directory="templates")
Expand All @@ -10,3 +14,29 @@
@router.get("/home", response_class=HTMLResponse)
async def home(request: Request):
return templates.TemplateResponse("home.html", {"request": request})


@router.post("/home", response_class=HTMLResponse)
async def home_form(
request: Request,
period: str = Form(...),
salary: int = Form(...),
start_date: date = Form(...),
mojo: float = Form(...),
):

saving_type = Salary(salary=salary)

return templates.TemplateResponse(
"home.html",
{
"request": request,
"period": period,
"salary": salary,
"start_date": start_date,
"mojo": mojo,
"smile": salary * saving_type.smile,
"maintenance": salary * saving_type.maintenance,
"mojo_progress": saving_type.mojo_progress(mojo),
},
)
35 changes: 35 additions & 0 deletions ajo/home/salary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from dataclasses import dataclass
from typing import Union


@dataclass
class Salary:
salary: Union[float, int]
already_in_mojo: Union[float, int] = 0
mojo: float = 0.2
smile: float = 0.1
maintenance: float = 0.1
other: float = 0.6

@property
def check_salary(self) -> Union[int, float]:
"""
:return: zero should be returned
"""
if self.salary is None:
self.salary = 0
return self.salary

def mojo_progress(self, mojo_goal: Union[float, int]) -> float:
"""
:param mojo_goal: Amount you are aiming to attain
:return: Amount you currently have in your mojo account
"""

self.salary = self.check_salary

if not isinstance(self.salary, (int, float)):
raise ValueError("salary can either be integer or float")

mojo_percent = self.salary * self.mojo * 100
return self.already_in_mojo + mojo_percent / mojo_goal
2 changes: 2 additions & 0 deletions ajo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from ajo.access import access
from ajo.home import home
from ajo.login import login
from ajo.setup import setup

app = FastAPI()

Expand All @@ -13,3 +14,4 @@
app.include_router(access.router)
app.include_router(home.router)
app.include_router(login.router)
app.include_router(setup.router)
Empty file added ajo/setup/__init__.py
Empty file.
199 changes: 199 additions & 0 deletions ajo/setup/setup.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
.container {
position: relative;
width: 100%;
height: 100%;
max-width: 800px;
margin: 0 auto;
padding: 0 20px;
box-sizing: border-box;
}

/*-------header style--------*/
header .field-header {
padding: 10px;
}

header .field-header .user-name {
display: inline;
margin: 0 auto;
padding-top: 20px;
position: relative;
}

select {
appearance: none;
border: none;
text-align: right;
text-transform: uppercase;
cursor: pointer;
font-size: 15px;
letter-spacing: 4px;
position: relative;
margin: 10px;
padding: 10px;
width: 200px;
text-align: right;
transition-duration: 0.4s;
overflow: hidden;
box-shadow: 0 5px 15px #149937;
float:right;
}

select:after {
appearance: none;
border: none;
}

select option {
appearance: none;
border: none;
background-color: transparent;
}

/*------End: header style------*/

.container .section-row {
margin: 0 auto;
padding: 10px;
}
.container .section-row .field-row {
margin: 0 auto;
padding: 10px;
}

fieldset {
padding: 20px;
border: 2px solid #149937;
border-radius: 10px;
box-shadow: 0 5px 10px greenyellow;
}

/*----Start: legend style------*/
.legend-header{
font-size:large;
text-transform: uppercase;
cursor: pointer;
font-size: 15px;
}

.legend-row {
text-transform: uppercase;
cursor: pointer;
font-size: 15px;
}


/*---End legend style----*/

/*-----Start: form text------*/
input[type=text] {
border-radius: 5px;
width: 40%;
height: 30px;
border: 2px solid #149937;

}
/*-----End: form text----------*/

/*-----Start: form date----------*/
input[type=date] {
border-radius: 5px;
width: 40%;
height: 30px;
border: 2px solid #149937;

}
/*-----End: form date--------------*/

/*------Start: form range----------------*/
.container .section-row table .td-range {
width: 100%;
}

input[type="range"] {
padding: 1px;
height: 35px;
width: 90%;
-webkit-appearance: none;
}

input[type="range"]:focus {
outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
width: 90%;
height: 15px;
cursor: pointer;
animate: 0.2s;
background: transparent;
border-radius: 5px;
border: 2px solid #149937;
}

input[type=range]::-webkit-slider-thumb {
box-shadow: 1px 1px 1px greenyellow;
border: 1px solid #149937;
height: 30px;
width: 30px;
border-radius: 15px;
background: yellowgreen;
cursor: pointer;
-webkit-appearance: none;
margin: -8px;
}
/*------End: form range----------------*/

/* -----form button ----------*/
button[type=submit] {
appearance: none;
}

button[type=submit] {
text-align: center;
text-transform: uppercase;
cursor: pointer;
font-size: 20px;
letter-spacing: 4px;
position: relative;
background-color: white;
border: solid #149937;
color: #149937;
margin: 10px;
padding: 10px;
width: 200px;
text-align: center;
transition-duration: 0.4s;
overflow: hidden;
box-shadow: 0 5px 15px #149937;
border-radius: 10px;
float: right;
}
button[type=submit]:hover {
background: #fff;
box-shadow: 0px 2px 10px 5px #1abc9c;
color: #000;
}

button[type=submit]:after {
content: "";
background: green;
display: block;
position: absolute;
padding-top: 300%;
padding-left: 350%;
margin-left: -20px !important;
margin-top: -120%;
opacity: 0;
transition: all 0.8s
}

button[type=submit]:active:after {
padding: 0;
margin: 0;
opacity: 1;
transition: 0s
}

button[type=submit]:focus { outline:0; }
/* -----form button ----------*/
Loading