Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GeoInt_SIDT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mario Chirinos Colunga
GeoInt_SIDT
Commits
242d42f3
Commit
242d42f3
authored
Mar 27, 2019
by
Ulises Morales Ramírez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pdf v2
parent
2f9a1f16
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
75 deletions
+65
-75
views.py
reports/views.py
+65
-75
No files found.
reports/views.py
View file @
242d42f3
...
@@ -18,8 +18,6 @@ from django.views.decorators.csrf import csrf_exempt
...
@@ -18,8 +18,6 @@ from django.views.decorators.csrf import csrf_exempt
from
GeoInt_SIDT.settings
import
BASE_URL
from
GeoInt_SIDT.settings
import
BASE_URL
from
catalog.models
import
Purchase
from
catalog.models
import
Purchase
from
reportlab.pdfgen.canvas
import
Canvas
from
reportlab.pdfgen.canvas
import
Canvas
from
reportlab.lib.pagesizes
import
letter
from
reportlab.lib.pagesizes
import
letter
from
reportlab.lib.styles
import
getSampleStyleSheet
from
reportlab.lib.styles
import
getSampleStyleSheet
...
@@ -30,6 +28,7 @@ from reportlab.graphics.charts.barcharts import VerticalBarChart
...
@@ -30,6 +28,7 @@ from reportlab.graphics.charts.barcharts import VerticalBarChart
from
reportlab.graphics.shapes
import
Drawing
,
String
from
reportlab.graphics.shapes
import
Drawing
,
String
from
reportlab.graphics.charts.textlabels
import
Label
,
LabelOffset
from
reportlab.graphics.charts.textlabels
import
Label
,
LabelOffset
from
reportlab.graphics.charts.legends
import
Legend
from
reportlab.graphics.charts.legends
import
Legend
# -------------------------------------------------------------------------------
# -------------------------------------------------------------------------------
########### lee archivo de configuración ################
########### lee archivo de configuración ################
...
@@ -47,12 +46,11 @@ def report_L2ASCL(request, purchase_id):
...
@@ -47,12 +46,11 @@ def report_L2ASCL(request, purchase_id):
template
=
"sclData.html"
template
=
"sclData.html"
reporteDir
=
'mask'
reporteDir
=
'mask'
folders
=
""
folders
=
""
purchase
=
Purchase
.
objects
.
values
(
'user__email'
,
'is_public'
)
.
filter
(
pk
=
purchase_id
)
purchase
=
Purchase
.
objects
.
values
(
'user__email'
,
'is_public'
)
.
filter
(
pk
=
purchase_id
)
email
=
purchase
[
0
][
'user__email'
]
email
=
purchase
[
0
][
'user__email'
]
path
=
USERS_PATH
+
email
+
'/'
+
purchase_id
+
'/'
path
=
USERS_PATH
+
email
+
'/'
+
purchase_id
+
'/'
scl_data_path
=
USERS_PATH
+
email
+
"/"
+
purchase_id
+
"/scl_data.json"
scl_data_path
=
USERS_PATH
+
email
+
"/"
+
purchase_id
+
"/scl_data.json"
with
open
(
USERS_PATH
+
email
+
"/"
+
purchase_id
+
"/findProducts.json"
)
as
p
:
with
open
(
USERS_PATH
+
email
+
"/"
+
purchase_id
+
"/findProducts.json"
)
as
p
:
dataProduct
=
json
.
load
(
p
)
dataProduct
=
json
.
load
(
p
)
startDate
=
str
(
dataProduct
[
'startDate'
])[:
4
]
+
'-'
+
str
(
dataProduct
[
'startDate'
])[
4
:
6
]
+
'-'
+
str
(
startDate
=
str
(
dataProduct
[
'startDate'
])[:
4
]
+
'-'
+
str
(
dataProduct
[
'startDate'
])[
4
:
6
]
+
'-'
+
str
(
...
@@ -60,29 +58,31 @@ def report_L2ASCL(request, purchase_id):
...
@@ -60,29 +58,31 @@ def report_L2ASCL(request, purchase_id):
endDate
=
str
(
dataProduct
[
'endDate'
])[:
4
]
+
'-'
+
str
(
dataProduct
[
'endDate'
])[
4
:
6
]
+
'-'
+
str
(
endDate
=
str
(
dataProduct
[
'endDate'
])[:
4
]
+
'-'
+
str
(
dataProduct
[
'endDate'
])[
4
:
6
]
+
'-'
+
str
(
dataProduct
[
'endDate'
])[
6
:
8
]
dataProduct
[
'endDate'
])[
6
:
8
]
graphData
,
label
,
defaultLabel
,
defaultDataset
,
datasets
=
ProcessChartData
(
scl_data_path
)
graphData
,
label
,
defaultLabel
,
defaultDataset
,
datasets
=
ProcessChartData
(
scl_data_path
)
image_path
=
email
+
"/"
+
purchase_id
+
"/"
+
"out/"
+
reporteDir
+
"/TCI/thumbnails/"
image_path
=
email
+
"/"
+
purchase_id
+
"/"
+
"out/"
+
reporteDir
+
"/TCI/thumbnails/"
SCL_path
=
email
+
"/"
+
purchase_id
+
"/"
+
"out/"
+
reporteDir
+
"/SCL/"
SCL_path
=
email
+
"/"
+
purchase_id
+
"/"
+
"out/"
+
reporteDir
+
"/SCL/"
if
os
.
path
.
exists
(
path
+
reporteDir
+
".pdf"
):
print
(
"si existe"
)
PDFGenerator
(
request
,
path
,
reporteDir
,
datasets
)
else
:
PDFGenerator
(
request
,
path
,
reporteDir
,
datasets
)
return
render
(
request
,
template
,
{
"graphData"
:
json
.
dumps
(
graphData
),
return
render
(
request
,
template
,
{
"graphData"
:
json
.
dumps
(
graphData
),
"report_name"
:
"SCL Image Classification Data(Km²)"
,
"report_name"
:
"SCL Image Classification Data(Km²)"
,
"startDate"
:
startDate
,
"endDate"
:
endDate
,
"startDate"
:
startDate
,
"endDate"
:
endDate
,
"clouds"
:
dataProduct
[
'clouds'
],
"platform"
:
dataProduct
[
'platform'
],
"clouds"
:
dataProduct
[
'clouds'
],
"platform"
:
dataProduct
[
'platform'
],
"productLevel"
:
dataProduct
[
'productLevel'
],
"IMAGE_PATH"
:
image_path
,
"productLevel"
:
dataProduct
[
'productLevel'
],
"IMAGE_PATH"
:
image_path
,
"SCL_PATH"
:
SCL_path
,
'dafaultLabel'
:
defaultLabel
,
"SCL_PATH"
:
SCL_path
,
'dafaultLabel'
:
defaultLabel
,
'defaultDataSet'
:
defaultDataset
,
"folders"
:
folders
,
'defaultDataSet'
:
defaultDataset
,
"folders"
:
folders
,
"zone"
:
reporteDir
,
"purchaseID"
:
purchase_id
,
"zone"
:
reporteDir
,
"purchaseID"
:
purchase_id
,
"labels"
:
graphData
[
'data'
][
'labels'
],
"labels"
:
graphData
[
'data'
][
'labels'
],
"polygon"
:
dataProduct
[
'wkt'
],
"email"
:
email
})
"polygon"
:
dataProduct
[
'wkt'
],
"email"
:
email
})
# -------------------------------------------------------------------------------def Reports(request):
# -------------------------------------------------------------------------------def Reports(request):
def
Reports
(
request
):
def
Reports
(
request
):
progress
=
0
progress
=
0
productList
=
[]
productList
=
[]
...
@@ -90,7 +90,8 @@ def Reports(request):
...
@@ -90,7 +90,8 @@ def Reports(request):
folders
=
[]
folders
=
[]
zip
=
""
zip
=
""
product_list
=
Purchase
.
objects
.
values
(
'id'
,
'productList'
,
'aggreg_date'
,
'search__clouds'
,
'search__startDate'
,
product_list
=
Purchase
.
objects
.
values
(
'id'
,
'productList'
,
'aggreg_date'
,
'search__clouds'
,
'search__startDate'
,
'search__endDate'
,
'search__process_id__name'
,
'search__search_name'
,
'is_public'
)
.
filter
(
'search__endDate'
,
'search__process_id__name'
,
'search__search_name'
,
'is_public'
)
.
filter
(
user_id
=
request
.
user
.
id
,
purchased
=
1
)
user_id
=
request
.
user
.
id
,
purchased
=
1
)
for
producto
in
product_list
:
for
producto
in
product_list
:
log_info
=
USERS_PATH
+
request
.
user
.
email
+
"/"
+
str
(
producto
[
'id'
])
+
"/L2ASCL_AreaProcessing.log"
log_info
=
USERS_PATH
+
request
.
user
.
email
+
"/"
+
str
(
producto
[
'id'
])
+
"/L2ASCL_AreaProcessing.log"
...
@@ -133,22 +134,19 @@ def Reports(request):
...
@@ -133,22 +134,19 @@ def Reports(request):
print
(
"folder out noes not exists"
)
print
(
"folder out noes not exists"
)
else
:
else
:
for
files
in
os
.
listdir
(
absolute_path
):
for
files
in
os
.
listdir
(
absolute_path
):
if
files
==
'scl_data.json'
:
if
files
==
'scl_data.json'
:
#print(files)
#
print(files)
initial_folder
=
files
[:
8
]
initial_folder
=
files
[:
8
]
break
break
elif
files
.
endswith
(
'_sclData.json'
):
elif
files
.
endswith
(
'_sclData.json'
):
initial_folder
=
files
[:
14
]
initial_folder
=
files
[:
14
]
#
if len(folders) == 0:
#
if len(folders) == 0:
# initial_folder = "../#"
# initial_folder = "../#"
#
else:
#
else:
# initial_folder = folders.pop(0) + "_sclData"
# initial_folder = folders.pop(0) + "_sclData"
print
(
initial_folder
)
print
(
initial_folder
)
zip_path
=
USERS_PATH
+
request
.
user
.
email
+
"/"
+
str
(
producto
[
'id'
])
zip_path
=
USERS_PATH
+
request
.
user
.
email
+
"/"
+
str
(
producto
[
'id'
])
# print(zip_path)
# print(zip_path)
...
@@ -193,7 +191,7 @@ def wsProcessProgress(request):
...
@@ -193,7 +191,7 @@ def wsProcessProgress(request):
if
request
.
is_ajax
():
if
request
.
is_ajax
():
progress
=
0
progress
=
0
productList2
=
[]
productList2
=
[]
product_list
=
Purchase
.
objects
.
values
(
'id'
,
'user__email'
,
'productList'
,
'aggreg_date'
,
'search__clouds'
,
product_list
=
Purchase
.
objects
.
values
(
'id'
,
'user__email'
,
'productList'
,
'aggreg_date'
,
'search__clouds'
,
'search__startDate'
,
'search__endDate'
,
'search__startDate'
,
'search__endDate'
,
'search__process_id__name'
,
'progress'
)
.
filter
(
user_id
=
request
.
user
.
id
,
'search__process_id__name'
,
'progress'
)
.
filter
(
user_id
=
request
.
user
.
id
,
purchased
=
1
)
purchased
=
1
)
...
@@ -240,6 +238,7 @@ def wsProcessProgress(request):
...
@@ -240,6 +238,7 @@ def wsProcessProgress(request):
else
:
else
:
raise
Http404
raise
Http404
# tiles
# tiles
def
tiles
(
request
,
purchase_id
,
report
,
layer_type
,
date
,
z
,
x
,
y
):
def
tiles
(
request
,
purchase_id
,
report
,
layer_type
,
date
,
z
,
x
,
y
):
purchase
=
Purchase
.
objects
.
values
(
'user__email'
,
'is_public'
)
.
filter
(
pk
=
purchase_id
)
purchase
=
Purchase
.
objects
.
values
(
'user__email'
,
'is_public'
)
.
filter
(
pk
=
purchase_id
)
...
@@ -271,8 +270,6 @@ def tileinfo(request):
...
@@ -271,8 +270,6 @@ def tileinfo(request):
purchase
=
Purchase
.
objects
.
values
(
'user__email'
)
.
filter
(
pk
=
int
(
req
[
'purchase_id'
][
0
]))
purchase
=
Purchase
.
objects
.
values
(
'user__email'
)
.
filter
(
pk
=
int
(
req
[
'purchase_id'
][
0
]))
email
=
purchase
[
0
][
'user__email'
]
email
=
purchase
[
0
][
'user__email'
]
resource_path
=
"{}{}/{}/out/{}/TCI/tiles/{}_TCI_10m/tilemapresource.xml"
.
format
(
resource_path
=
"{}{}/{}/out/{}/TCI/tiles/{}_TCI_10m/tilemapresource.xml"
.
format
(
USERS_PATH
,
email
,
req
[
'purchase_id'
][
0
],
req
[
'report'
][
0
],
USERS_PATH
,
email
,
req
[
'purchase_id'
][
0
],
req
[
'report'
][
0
],
req
[
'date'
][
0
]
req
[
'date'
][
0
]
...
@@ -281,7 +278,6 @@ def tileinfo(request):
...
@@ -281,7 +278,6 @@ def tileinfo(request):
if
not
os
.
path
.
exists
(
resource_path
):
if
not
os
.
path
.
exists
(
resource_path
):
raise
Http404
raise
Http404
tree
=
ET
.
parse
(
resource_path
)
tree
=
ET
.
parse
(
resource_path
)
bounding_box
=
tree
.
find
(
'BoundingBox'
)
bounding_box
=
tree
.
find
(
'BoundingBox'
)
sets
=
[
int
(
set
.
get
(
'order'
))
for
set
in
tree
.
findall
(
'TileSets/TileSet'
)]
sets
=
[
int
(
set
.
get
(
'order'
))
for
set
in
tree
.
findall
(
'TileSets/TileSet'
)]
...
@@ -305,7 +301,6 @@ def tileinfo(request):
...
@@ -305,7 +301,6 @@ def tileinfo(request):
raise
Http404
raise
Http404
# ------------------------------------------------------------------------
# ------------------------------------------------------------------------
# take the data and make ready for paragraph
# take the data and make ready for paragraph
def
dataToParagraph
(
name
,
data
):
def
dataToParagraph
(
name
,
data
):
...
@@ -322,42 +317,37 @@ def dataToParagraph(name, data):
...
@@ -322,42 +317,37 @@ def dataToParagraph(name, data):
# take the data and convert to list of strings ready for table
# take the data and convert to list of strings ready for table
def
dataToTable
(
name
,
data
):
def
dataToTable
(
name
,
data
):
data
=
[
str
(
x
)
for
x
in
data
]
data
=
[
str
(
x
)
for
x
in
data
]
data
.
insert
(
0
,
name
)
data
.
insert
(
0
,
name
)
return
data
return
data
# create the table for our document
# create the table for our document
def
myTable
(
path1
,
path2
,
basefile
):
def
myTable
(
path1
,
path2
,
basefile
):
image1
=
Image
(
path1
,
height
=
300
,
width
=
200
,
mask
=
'auto'
)
image1
=
Image
(
path1
,
height
=
300
,
width
=
200
,
mask
=
'auto'
)
path
,
dirs
,
files
=
next
(
os
.
walk
(
path2
))
path
,
dirs
,
files
=
next
(
os
.
walk
(
path2
))
for
file
in
files
:
for
file
in
files
:
if
file
.
startswith
(
basefile
[:
8
]):
if
file
.
startswith
(
basefile
[:
8
]):
if
file
.
endswith
(
'.tif'
)
and
not
file
.
endswith
(
'0.tif'
):
if
file
.
endswith
(
'.tif'
)
and
not
file
.
endswith
(
'0.tif'
):
#image2 = Image(path2 + file, height=300, width=200, mask='auto')
#
image2 = Image(path2 + file, height=300, width=200, mask='auto')
image2
=
image1
image2
=
image1
data
=
[[
'TCI'
,
'SCL'
],
[
image1
,
image2
]]
data
=
[[
'TCI'
,
'SCL'
],
[
image1
,
image2
]]
t
=
Table
(
data
)
t
=
Table
(
data
)
GRID_STYLE
=
TableStyle
(
GRID_STYLE
=
TableStyle
(
[
[
(
'ALIGN'
,(
0
,
0
),(
-
1
,
-
1
),
'CENTER'
),
(
'ALIGN'
,
(
0
,
0
),
(
-
1
,
-
1
),
'CENTER'
),
(
'VALIGN'
,(
0
,
0
),(
-
1
,
-
1
),
'TOP'
),
(
'VALIGN'
,
(
0
,
0
),
(
-
1
,
-
1
),
'TOP'
),
],
],
)
)
t
.
setStyle
(
GRID_STYLE
)
t
.
setStyle
(
GRID_STYLE
)
return
t
return
t
# create a bar chart and specify positions, sizes, and colors
# create a bar chart and specify positions, sizes, and colors
def
myBarChart
(
data
,
maxi
,
fecha
):
def
myBarChart
(
data
,
maxi
,
fecha
):
drawing
=
Drawing
(
600
,
200
)
drawing
=
Drawing
(
600
,
200
)
bc
=
VerticalBarChart
()
bc
=
VerticalBarChart
()
...
@@ -378,7 +368,7 @@ def myBarChart(data,maxi,fecha):
...
@@ -378,7 +368,7 @@ def myBarChart(data,maxi,fecha):
bc
.
categoryAxis
.
labels
.
boxAnchor
=
'ne'
bc
.
categoryAxis
.
labels
.
boxAnchor
=
'ne'
bc
.
categoryAxis
.
labels
.
dx
=
8
bc
.
categoryAxis
.
labels
.
dx
=
8
bc
.
categoryAxis
.
labels
.
dy
=
-
2
bc
.
categoryAxis
.
labels
.
dy
=
-
2
catNames
=
fecha
[
6
:
8
]
+
"/"
+
fecha
[
4
:
6
]
+
"/"
+
fecha
[
0
:
4
]
catNames
=
fecha
[
6
:
8
]
+
"/"
+
fecha
[
4
:
6
]
+
"/"
+
fecha
[
0
:
4
]
catNames
=
catNames
.
split
()
catNames
=
catNames
.
split
()
bc
.
categoryAxis
.
categoryNames
=
catNames
bc
.
categoryAxis
.
categoryNames
=
catNames
...
@@ -390,7 +380,7 @@ def myBarChart(data,maxi,fecha):
...
@@ -390,7 +380,7 @@ def myBarChart(data,maxi,fecha):
bc
.
bars
[
4
]
.
fillColor
=
colors
.
darkgray
bc
.
bars
[
4
]
.
fillColor
=
colors
.
darkgray
bc
.
bars
[
5
]
.
fillColor
=
colors
.
green
bc
.
bars
[
5
]
.
fillColor
=
colors
.
green
bc
.
bars
[
6
]
.
fillColor
=
colors
.
yellow
bc
.
bars
[
6
]
.
fillColor
=
colors
.
yellow
#bc.bars[7].fillColor = colors.black
#
bc.bars[7].fillColor = colors.black
bc
.
barSpacing
=
1
bc
.
barSpacing
=
1
bc
.
categoryAxis
.
labels
.
dx
=
8
bc
.
categoryAxis
.
labels
.
dx
=
8
...
@@ -425,8 +415,8 @@ def myBarLegend(drawing, labels):
...
@@ -425,8 +415,8 @@ def myBarLegend(drawing, labels):
(
colors
.
lightblue
,
labels
[
3
]),
(
colors
.
lightblue
,
labels
[
3
]),
(
colors
.
darkgray
,
labels
[
4
]),
(
colors
.
darkgray
,
labels
[
4
]),
(
colors
.
green
,
labels
[
5
]),
(
colors
.
green
,
labels
[
5
]),
(
colors
.
yellow
,
labels
[
6
]
+
"km2"
),
(
colors
.
yellow
,
labels
[
6
]
+
"km2"
),
#(colors.black, labels[7]),
#
(colors.black, labels[7]),
]
]
swatches
.
colorNamePairs
=
items
swatches
.
colorNamePairs
=
items
...
@@ -436,7 +426,6 @@ def myBarLegend(drawing, labels):
...
@@ -436,7 +426,6 @@ def myBarLegend(drawing, labels):
def
PDFGenerator
(
request
,
ruta
,
reporteDir
,
datasets
):
def
PDFGenerator
(
request
,
ruta
,
reporteDir
,
datasets
):
thumbs
=
ruta
+
'out/'
+
reporteDir
+
'/TCI/thumbnails/'
thumbs
=
ruta
+
'out/'
+
reporteDir
+
'/TCI/thumbnails/'
SCL
=
ruta
+
'out/'
+
reporteDir
+
'/SCL/split/'
SCL
=
ruta
+
'out/'
+
reporteDir
+
'/SCL/split/'
story
=
[]
story
=
[]
...
@@ -445,26 +434,29 @@ def PDFGenerator(request, ruta, reporteDir, datasets):
...
@@ -445,26 +434,29 @@ def PDFGenerator(request, ruta, reporteDir, datasets):
styleN
=
styles
[
'Normal'
]
styleN
=
styles
[
'Normal'
]
# Header
# Header
im
=
Image
(
USERS_PATH
+
'header.png'
,
width
=
300
,
height
=
70
)
im
=
Image
(
USERS_PATH
+
'header.png'
,
width
=
300
,
height
=
70
)
im
.
hAlign
=
'CENTER'
im
.
hAlign
=
'CENTER'
story
.
append
(
im
)
story
.
append
(
im
)
story
.
append
(
PageBreak
())
story
.
append
(
PageBreak
())
path
,
dirs
,
files
=
next
(
os
.
walk
(
thumbs
))
path
,
dirs
,
files
=
next
(
os
.
walk
(
thumbs
))
print
(
len
(
files
))
for
index
,
file
in
enumerate
(
files
):
for
index
,
file
in
enumerate
(
files
):
values
=
[]
values
=
[]
labels
=
[]
labels
=
[]
maxi
=
0
maxi
=
0
for
data
in
datasets
:
#for data in datasets:
for
data
in
datasets
[:
len
(
datasets
)
-
1
]:
if
maxi
>
data
[
'data'
][
index
]:
if
maxi
>
data
[
'data'
][
index
]:
maxi
=
maxi
maxi
=
maxi
else
:
else
:
maxi
=
data
[
'data'
][
index
]
maxi
=
data
[
'data'
][
index
]
#print (maxi)
values
.
append
([
data
[
'data'
][
index
]])
values
.
append
([
data
[
'data'
][
index
]])
labels
.
append
(
data
[
'label'
])
labels
.
append
(
data
[
'label'
])
path1
=
thumbs
+
file
path1
=
thumbs
+
file
# Header
# Header
im
=
Image
(
USERS_PATH
+
'header.png'
,
width
=
300
,
height
=
70
)
im
=
Image
(
USERS_PATH
+
'header.png'
,
width
=
300
,
height
=
70
)
im
.
hAlign
=
'CENTER'
im
.
hAlign
=
'CENTER'
...
@@ -473,41 +465,38 @@ def PDFGenerator(request, ruta, reporteDir, datasets):
...
@@ -473,41 +465,38 @@ def PDFGenerator(request, ruta, reporteDir, datasets):
story
.
append
(
Spacer
(
1
,
.5
*
inch
))
story
.
append
(
Spacer
(
1
,
.5
*
inch
))
# add the title
# add the title
#story.append(Paragraph("<strong>Results for Vizard Experiment</strong>", styleN))
#
story.append(Paragraph("<strong>Results for Vizard Experiment</strong>", styleN))
#story.append(Spacer(1, .25 * inch))
#
story.append(Spacer(1, .25 * inch))
# convert data to paragraph form and then add paragraphs
# convert data to paragraph form and then add paragraphs
#story.append(Paragraph(dataToParagraph(subject1, results1), styleN))
#
story.append(Paragraph(dataToParagraph(subject1, results1), styleN))
#story.append(Spacer(1, .25 * inch))
#
story.append(Spacer(1, .25 * inch))
#story.append(Paragraph(dataToParagraph(subject2, results2), styleN))
#
story.append(Paragraph(dataToParagraph(subject2, results2), styleN))
#story.append(Spacer(1, .5 * inch))
#
story.append(Spacer(1, .5 * inch))
# table with images
# table with images
story
.
append
(
myTable
(
path1
,
SCL
,
file
))
story
.
append
(
myTable
(
path1
,
SCL
,
file
))
story
.
append
(
Spacer
(
1
,
.5
*
inch
))
story
.
append
(
Spacer
(
1
,
.5
*
inch
))
# add barchart and legend
# add barchart and legend
drawing
=
myBarChart
(
values
[:
len
(
values
)
-
1
],
maxi
,
file
)
#drawing = myBarChart(values[:len(values) - 1], maxi, file)
drawing
=
myBarLegend
(
drawing
,
labels
[:
len
(
labels
)
-
1
])
drawing
=
myBarChart
(
values
,
maxi
,
file
)
#drawing = myBarLegend(drawing, labels[:len(labels) - 1])
drawing
=
myBarLegend
(
drawing
,
labels
)
drawing
.
hAlign
=
'CENTER'
drawing
.
hAlign
=
'CENTER'
story
.
append
(
drawing
)
story
.
append
(
drawing
)
story
.
append
(
PageBreak
())
story
.
append
(
PageBreak
())
# build our document with the list of flowables we put together
# build our document with the list of flowables we put together
doc
=
SimpleDocTemplate
(
ruta
+
reporteDir
+
".pdf"
,
pagesize
=
letter
,
topMargin
=
0
)
doc
=
SimpleDocTemplate
(
ruta
+
reporteDir
+
".pdf"
,
pagesize
=
letter
,
topMargin
=
0
)
doc
.
build
(
story
)
doc
.
build
(
story
)
pass
print
(
"hecho"
)
pass
# -----------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------
def
ProcessChartData
(
path
):
def
ProcessChartData
(
path
):
with
open
(
path
)
as
f
:
with
open
(
path
)
as
f
:
json_data
=
OrderedDict
(
json
.
load
(
f
))
json_data
=
OrderedDict
(
json
.
load
(
f
))
...
@@ -553,18 +542,19 @@ def ProcessChartData(path):
...
@@ -553,18 +542,19 @@ def ProcessChartData(path):
label
=
graphData
[
'data'
][
'labels'
][
0
]
label
=
graphData
[
'data'
][
'labels'
][
0
]
defaultLabel
=
graphData
[
'data'
][
'labels'
][
0
]
defaultLabel
=
graphData
[
'data'
][
'labels'
][
0
]
defaultDataset
=
label
[
0
:
4
]
+
"/"
+
label
[
4
:
6
]
+
"/"
+
label
[
6
:]
defaultDataset
=
label
[
0
:
4
]
+
"/"
+
label
[
4
:
6
]
+
"/"
+
label
[
6
:]
return
graphData
,
label
,
defaultLabel
,
defaultDataset
,
data
[
'datasets'
]
return
graphData
,
label
,
defaultLabel
,
defaultDataset
,
data
[
'datasets'
]
#---------------------------------------------------------------------------------
#
---------------------------------------------------------------------------------
def
wsIs_Public
(
request
):
def
wsIs_Public
(
request
):
if
request
.
is_ajax
():
if
request
.
is_ajax
():
status
=
request
.
GET
.
get
(
"status"
)
status
=
request
.
GET
.
get
(
"status"
)
path
=
"/reports/"
+
request
.
GET
.
get
(
"purchase_id"
)
+
"/scl_data"
path
=
"/reports/"
+
request
.
GET
.
get
(
"purchase_id"
)
+
"/scl_data"
purchase
=
Purchase
.
objects
.
get
(
pk
=
request
.
GET
.
get
(
"purchase_id"
))
purchase
=
Purchase
.
objects
.
get
(
pk
=
request
.
GET
.
get
(
"purchase_id"
))
purchase
.
is_public
=
request
.
GET
.
get
(
"status"
)
purchase
.
is_public
=
request
.
GET
.
get
(
"status"
)
purchase
.
save
()
purchase
.
save
()
#print (purchase.aggreg_date)
#
print (purchase.aggreg_date)
return
HttpResponse
(
"hola"
)
return
HttpResponse
(
"hola"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment