-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Kalkuli/develop
Solve 125 Criar Release do Projeto
- Loading branch information
Showing
10 changed files
with
303 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
__pycache__ | ||
env | ||
.vscode/ | ||
.vscode/ | ||
htmlcov/ |
This file contains 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,16 @@ | ||
sudo: required | ||
services: | ||
- docker | ||
env: | ||
DOCKER_COMPOSE_VERSION: 1.21.1 | ||
before_install: | ||
- sudo rm /usr/local/bin/docker-compose | ||
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose | ||
- chmod +x docker-compose | ||
- sudo mv docker-compose /usr/local/bin | ||
before_script: | ||
- docker-compose -f docker-compose-dev.yml up --build -d | ||
script: | ||
- docker-compose -f docker-compose-dev.yml run base python manage.py test | ||
after_script: | ||
- docker-compose -f docker-compose-dev.yml down |
This file contains 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,2 @@ | ||
web: gunicorn -b 0.0.0.0:$PORT manage:app | ||
release: python manage.py recreatedb |
This file contains 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 |
---|---|---|
@@ -1,28 +1,61 @@ | ||
# Configurando o ambiente | ||
Para instruções de como instalar o Docker e o Docker-compose clique [aqui](https://github.com/Kalkuli/2018.2-Kalkuli_Front-End/blob/master/README.md). | ||
# Serviço de Geração de Relatórios | ||
|
||
<div style="text-align: center"> | ||
|
||
<a href="https://travis-ci.com/Kalkuli/2018.2-Kalkuli_Reports"><img src="https://travis-ci.org/Kalkuli/2018.2-Kalkuli_Reports.svg?branch=master" /></a> | ||
<a href="https://codeclimate.com/github/Kalkuli/2018.2-Kalkuli_Reports/test_coverage"><img src="https://api.codeclimate.com/v1/badges/1f500530c8778423167f/test_coverage" /></a> | ||
<a href="https://codeclimate.com/github/Kalkuli/2018.2-Kalkuli_Reports/maintainability"><img src="https://api.codeclimate.com/v1/badges/1f500530c8778423167f/maintainability" /></a> | ||
<a href="https://opensource.org/licenses/GPL-3.0"><img src="https://img.shields.io/badge/license-GPL-%235DA8C1.svg"/></a> | ||
|
||
</div> | ||
|
||
|
||
<br> | ||
## Deploy | ||
|
||
A ultima versão do app pode ser encontrada em: https://kalkuli-reports.herokuapp.com | ||
|
||
*** | ||
|
||
## Configurando o ambiente | ||
Para instruções de como instalar o Docker e o Docker-compose clique [aqui](https://github.com/Kalkuli/2018.2-Kalkuli_Front-End/blob/master/README.md). | ||
|
||
*** | ||
|
||
## Colocando no ar | ||
Com o Docker e Docker-Compose instalados, basta apenas utilizar os comandos: | ||
Com o _Docker_ e _Docker-Compose_ instalados, basta apenas utilizar os comandos: | ||
|
||
``` | ||
chmod +x entrypoint.sh | ||
```chmod +x entrypoint.sh``` | ||
docker-compose -f docker-compose-dev.yml build | ||
```docker-compose -f docker-compose-dev.yml build``` | ||
docker-compose -f docker-compose-dev.yml up | ||
``` | ||
|
||
e | ||
Abra outro terminal, e execute o comando: | ||
|
||
```docker-compose -f docker-compose-dev.yml up``` | ||
|
||
``` | ||
docker-compose -f docker-compose-dev.yml run base python manage.py recreatedb | ||
``` | ||
|
||
Acesse o servidor local no endereço apresentado abaixo: | ||
|
||
http://localhost:5004/ | ||
|
||
[localhost:5004](http://localhost:5004/) | ||
|
||
Agora você já pode começar a contribuir! | ||
|
||
*** | ||
|
||
## Testando | ||
|
||
```docker-compose -f docker-compose-dev.yml run base python manage.py test``` | ||
``` | ||
docker-compose -f docker-compose-dev.yml run base python manage.py test | ||
``` | ||
|
||
Execute o comando abaixo para checar a cobertura: | ||
|
||
``` | ||
docker-compose -f docker-compose-dev.yml run base python manage.py cov | ||
``` |
This file contains 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 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 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 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,73 @@ | ||
from flask import Blueprint, request, jsonify | ||
from project.api.models import Report | ||
|
||
from sqlalchemy import exc | ||
from project import db | ||
|
||
|
||
reports_blueprint = Blueprint('/report', __name__) | ||
|
||
|
||
@reports_blueprint.route('/report', methods=['POST']) | ||
def reports(): | ||
|
||
data = request.get_json() | ||
|
||
if not data: | ||
return jsonify({ | ||
'error': 'empty json' | ||
}), 400 | ||
|
||
reports = data.get('receipts') | ||
|
||
sum = 0 | ||
|
||
for report in reports: | ||
if not report.get('total_price'): | ||
return jsonify({ | ||
'error': 'empty total_price' | ||
}), 400 | ||
sum += report.get('total_price') | ||
|
||
sum = str(sum) | ||
|
||
return jsonify({ | ||
'receipts': reports, | ||
'total_cost': sum | ||
}), 200 | ||
|
||
|
||
@reports_blueprint.route('/add_report', methods=['POST']) | ||
def add_report(): | ||
data = request.get_json() | ||
|
||
if not data: | ||
return jsonify({ | ||
'error': 'Report can not be saved' | ||
}), 400 | ||
|
||
reports = data.get('receipts') | ||
|
||
company_id = None | ||
data_from = data.get('date_from') | ||
data_to = data.get('date_to') | ||
total_cost = data.get('total_cost') | ||
total_tax_cost = None | ||
|
||
|
||
try: | ||
report = Report(company_id, data_from, data_to, total_cost, total_tax_cost) | ||
db.session.add(report) | ||
db.session.commit() | ||
|
||
return jsonify({ | ||
'status': 'success', | ||
'data': { | ||
'message': 'Report was created!' | ||
} | ||
}), 200 | ||
except exc.IntegrityError: | ||
db.session.rollback() | ||
return jsonify({ | ||
'error': 'Report can not be saved' | ||
}), 400 |
This file contains 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.