-
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 #28 from Som-Energia/NEW_endpoint_reports
New endpoint reports
- Loading branch information
Showing
19 changed files
with
1,143 additions
and
279 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,4 +1,5 @@ | ||
__version__ = VERSION = '1.3.2' | ||
|
||
from .api import contracts, f1_measures, cch, modcontracts, registration | ||
from .api import (contracts, cch, f1_measures, modcontracts, registration, | ||
reports) | ||
from .app import app |
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 @@ | ||
from .reports import bp_reports |
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,39 @@ | ||
from sanic import Blueprint | ||
from sanic.log import logger | ||
from sanic.response import json | ||
from sanic.views import HTTPMethodView | ||
from sanic_jwt.decorators import protected, inject_user | ||
|
||
from infoenergia_api.contrib import beedataApi, get_report_ids | ||
from infoenergia_api.contrib import PaginationLinksMixin | ||
|
||
|
||
bp_reports = Blueprint('reports') | ||
|
||
class ReportsView(PaginationLinksMixin, HTTPMethodView): | ||
decorators = [ | ||
inject_user(), | ||
protected(), | ||
] | ||
|
||
endpoint_name = 'reports.reports' | ||
|
||
async def post(self, request, user): | ||
logger.info("Uploading contracts") | ||
report_ids, month = await get_report_ids(request) | ||
|
||
request.app.loop.create_task( | ||
beedataApi().process_reports(report_ids, month) | ||
) | ||
|
||
response = { | ||
'reports': len(report_ids), | ||
} | ||
return json(response) | ||
|
||
|
||
bp_reports.add_route( | ||
ReportsView.as_view(), | ||
'/reports', | ||
name='reports', | ||
) |
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
Oops, something went wrong.