Skip to content
GitLab
Explore
Sign in
Commits on Source (2)
Remove all segments from the database while updating
· ef985a52
Marco De Donno
authored
Dec 16, 2019
ef985a52
Update the admin tenprint edit page
· 582fd0b6
Marco De Donno
authored
Dec 16, 2019
582fd0b6
Expand all
Hide whitespace changes
Inline
Side-by-side
views/images/__init__.py
View file @
582fd0b6
...
...
@@ -315,6 +315,9 @@ def do_image_tenprint_segmentation( tenprint_id ):
data
=
(
tenprint_id
,
)
zones
=
config
.
db
.
query_fetchall
(
sql
,
data
)
sql
=
"
DELETE FROM files_segments WHERE tenprint = %s
"
config
.
db
.
query
(
sql
,
(
tenprint_id
,
)
)
for
z
in
zones
:
current_app
.
logger
.
debug
(
"
Segmenting fpc
'
{}
'"
.
format
(
z
[
"
fpc
"
]
)
)
...
...
@@ -329,22 +332,11 @@ def do_image_tenprint_segmentation( tenprint_id ):
file_data
=
base64
.
b64encode
(
file_data
)
file_data
=
do_encrypt_dek
(
file_data
,
submission_id
)
sql
=
"
SELECT id FROM files_segments WHERE tenprint = %s AND pc = %s
"
q
=
config
.
db
.
query_fetchone
(
sql
,
(
tenprint_id
,
z
[
"
fpc
"
],
)
)
if
q
==
None
:
current_app
.
logger
.
debug
(
"
Inserting to the database
"
)
sql
=
utils
.
sql
.
sql_insert_generate
(
"
files_segments
"
,
[
"
tenprint
"
,
"
uuid
"
,
"
pc
"
,
"
data
"
]
)
data
=
(
tenprint_id
,
str
(
uuid4
()
),
z
[
"
fpc
"
],
file_data
)
config
.
db
.
query
(
sql
,
data
)
current_app
.
logger
.
debug
(
"
Inserting to the database
"
)
sql
=
utils
.
sql
.
sql_insert_generate
(
"
files_segments
"
,
[
"
tenprint
"
,
"
uuid
"
,
"
pc
"
,
"
data
"
]
)
data
=
(
tenprint_id
,
str
(
uuid4
()
),
z
[
"
fpc
"
],
file_data
)
config
.
db
.
query
(
sql
,
data
)
else
:
current_app
.
logger
.
debug
(
"
Updating the database
"
)
sql
=
"
UPDATE files_segments SET data = %s WHERE tenprint = %s AND pc = %s
"
data
=
(
file_data
,
tenprint_id
,
z
[
"
fpc
"
]
)
config
.
db
.
query
(
sql
,
data
)
config
.
db
.
commit
()
return
True
views/submission/__init__.py
View file @
582fd0b6
...
...
@@ -1506,12 +1506,11 @@ def admin_tenprint( submission_id, tenprint_id ):
files.uuid,
files.format, files.resolution, files.width, files.height, files.size,
files.creation_time, files.type,
file_template.template,
files.quality,
files.quality,
users.username
FROM files
LEFT JOIN submissions ON files.folder = submissions.id
LEFT JOIN users ON submissions.donor_id = users.id
LEFT JOIN file_template ON files.uuid = file_template.file
WHERE
submissions.uuid = %s AND
files.uuid = %s
...
...
@@ -1564,8 +1563,26 @@ def admin_tenprint( submission_id, tenprint_id ):
############################################################################
zones
=
get_tenprint_template_zones
(
tenprint_file
[
"
template
"
],
side
)
datacolumns
=
[
"
tl_x
"
,
"
tl_y
"
,
"
br_x
"
,
"
br_y
"
,
"
angle
"
]
sql
=
"
SELECT width, height, resolution FROM files WHERE uuid = %s LIMIT 1
"
img_info
=
config
.
db
.
query_fetchone
(
sql
,
(
tenprint_id
,
)
)
svg_hw_factor
=
float
(
img_info
[
"
width
"
]
)
/
float
(
img_info
[
"
height
"
]
)
############################################################################
sql
=
"
SELECT * FROM segments_locations WHERE tenprint_id = %s ORDER BY fpc ASC
"
zones_raw
=
config
.
db
.
query_fetchall
(
sql
,
(
tenprint_id
,
)
)
zones
=
[]
for
z
in
zones_raw
:
tmp
=
{}
tmp
[
"
fpc
"
]
=
z
[
"
fpc
"
]
for
k
in
[
"
x
"
,
"
width
"
]:
tmp
[
k
]
=
z
[
k
]
/
img_info
[
"
width
"
]
for
k
in
[
"
y
"
,
"
height
"
]:
tmp
[
k
]
=
z
[
k
]
/
img_info
[
"
height
"
]
zones
.
append
(
tmp
)
############################################################################
...
...
@@ -1581,7 +1598,6 @@ def admin_tenprint( submission_id, tenprint_id ):
img_info
=
img_info
,
svg_hw_factor
=
svg_hw_factor
,
zones
=
zones
,
datacolumns
=
datacolumns
,
tenprint_templates
=
tenprint_templates
,
quality_type
=
quality_type
)
...
...
views/submission/templates/admin/tenprint.html
View file @
582fd0b6
This diff is collapsed.
Click to expand it.