Skip to content

Commit

Permalink
Merge pull request #46 from Bernardo-MG/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Bernardo-MG committed Jul 14, 2015
2 parents 766a0f4 + 9725b19 commit 472dee8
Show file tree
Hide file tree
Showing 35 changed files with 1,137 additions and 273 deletions.
35 changes: 19 additions & 16 deletions cwr_webclient/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
from cwr_webclient.view import *
from cwr_webclient.config import DevConfig
from cwr_webclient.service import DefaultPaginationService, \
WESOApplicationInfoService, WSCWRService
WESOApplicationInfoService, WSCWRService, MeraReportService, \
CWRReportService
from data_web.accessor_web import CWRWebConfiguration

__author__ = 'Bernardo Martínez Garrido'
Expand Down Expand Up @@ -57,29 +58,31 @@ def render_error(error):


def _load_services(app, config):
match_ws = config['ws.match']
match_ws_results = config['ws.match.results']
match_ws_status = config['ws.match.status']
admin_ws = os.environ.get('CWR_ADMIN_WS',
'http://127.0.0.1:33508/cwr/')

if len(match_ws) == 0:
match_ws = os.environ.get('CWR_WEBCLIENT_MATCH_WS',
'http://127.0.0.1:33567/cwr/')
process_cwr = admin_ws + 'process/'

if len(match_ws_results) == 0:
match_ws_results = os.environ.get('CWR_WEBCLIENT_MATCH_WS_RESULTS',
'http://127.0.0.1:33567/cwr/results/')
files = admin_ws + 'files/'

if len(match_ws_status) == 0:
match_ws_status = os.environ.get('CWR_WEBCLIENT_MATCH_WS_STATUS',
'http://127.0.0.1:33567/cwr/status/')
remove_cwr = files + 'remove/'

service_admin = WSCWRService('http://127.0.0.1:33508/cwr/process/',
'http://127.0.0.1:33508/cwr/files/',
'http://127.0.0.1:33508/cwr/files/remove/')
match_begin = admin_ws + 'match/begin/'
match_reject = admin_ws + 'match/reject/'
match_accept = admin_ws + 'match/confirm/'

service_admin = WSCWRService(process_cwr,
files,
remove_cwr,
match_begin,
match_reject,
match_accept)

app.config['CWR_ADMIN_SERVICE'] = service_admin
app.config['PAGINATION_SERVICE'] = DefaultPaginationService(
int(config['perpage']))
app.config['CWR_MATCH_REPORT_SERVICE'] = MeraReportService()
app.config['CWR_REPORT_SERVICE'] = CWRReportService()


def _register_blueprints(app):
Expand Down
62 changes: 0 additions & 62 deletions cwr_webclient/model/user.py

This file was deleted.

38 changes: 0 additions & 38 deletions cwr_webclient/model/workload.py

This file was deleted.

1 change: 1 addition & 0 deletions cwr_webclient/report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__author__ = 'Bernardo'
109 changes: 109 additions & 0 deletions cwr_webclient/report/cwr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# -*- encoding: utf-8 -*-

import StringIO

import xlsxwriter

"""
Web app module.
"""

__author__ = 'Bernardo Martínez Garrido'
__license__ = 'MIT'
__status__ = 'Development'


def generate_cwr_report_excel(cwr):
output = StringIO.StringIO()
workbook = xlsxwriter.Workbook(output, {'in_memory': True})

_generate_cwr_report_excel_general(workbook, cwr)

for group in cwr.transmission.groups:
_generate_cwr_report_excel_group(workbook, group)

workbook.close()

output.seek(0)
return output.read()


def _generate_cwr_report_excel_group(workbook, group):
results_sheet = workbook.add_worksheet(group.group_header.transaction_type)

bold = workbook.add_format({'bold': 1})

row = 1
col = 0

for transaction in group.transactions:
for record in transaction:
results_sheet.write(row, col + 1, record.record_type)
row += 1


def _generate_cwr_report_excel_general(workbook, cwr):
results_sheet = workbook.add_worksheet('General info')

bold = workbook.add_format({'bold': 1})

header = cwr.transmission.header
trailer = cwr.transmission.trailer

row = 1
col = 0

results_sheet.write(row, col, 'Sender ID', bold)
results_sheet.write(row, col + 1, header.sender_id)

row += 1

results_sheet.write(row, col, 'Sender Name', bold)
results_sheet.write(row, col + 1, header.sender_name)

row += 1

results_sheet.write(row, col, 'Sender Type', bold)
results_sheet.write(row, col + 1, header.sender_name)

row += 1
row += 1

results_sheet.write(row, col, 'Creation Date', bold)
results_sheet.write(row, col + 1, header.creation_date_time)

row += 1

results_sheet.write(row, col, 'Transmission Date', bold)
results_sheet.write(row, col + 1, header.transmission_date)

row += 1
row += 1

results_sheet.write(row, col, 'EDI Standard', bold)
results_sheet.write(row, col + 1, header.edi_standard)

row += 1

results_sheet.write(row, col, 'Character Set', bold)
results_sheet.write(row, col + 1, header.character_set)

row += 1
row += 1

results_sheet.write(row, col, 'Counts', bold)

row += 1

results_sheet.write(row, col, 'Groups', bold)
results_sheet.write(row, col + 1, trailer.group_count)

row += 1

results_sheet.write(row, col, 'Transactions', bold)
results_sheet.write(row, col + 1, trailer.transaction_count)

row += 1

results_sheet.write(row, col, 'Records', bold)
results_sheet.write(row, col + 1, trailer.record_count)

0 comments on commit 472dee8

Please sign in to comment.