Skip to content
Commits on Source (4)
......@@ -1408,9 +1408,9 @@ def upload_file():
else:
try:
upload_uuid = request.form.get( "submission_id" )
submission_uuid = request.form.get( "submission_id" )
sql = "SELECT id FROM submissions WHERE uuid = %s"
r = config.db.query( sql, ( upload_uuid, ) )
r = config.db.query( sql, ( submission_uuid, ) )
submission_id = r.fetchone()[ "id" ]
except:
......@@ -1433,7 +1433,7 @@ def upload_file():
if file_extension in config.NIST_file_extensions:
file_data = fp.getvalue()
file_data = base64.b64encode( file_data )
file_data = do_encrypt_dek( file_data, upload_uuid )
file_data = do_encrypt_dek( file_data, submission_uuid )
try:
n = NISTf_auto( fp )
......@@ -1462,7 +1462,7 @@ def upload_file():
buff.seek( 0 )
img_data = buff.getvalue()
img_data = base64.b64encode( img_data )
img_data = do_encrypt_dek( img_data, upload_uuid )
img_data = do_encrypt_dek( img_data, submission_uuid )
sql = sql_insert_generate( "files_segments", [ "tenprint", "uuid", "pc", "data" ] )
data = ( file_uuid, str( uuid4() ), fpc, img_data, )
......@@ -1505,7 +1505,7 @@ def upload_file():
file_data = buff.getvalue()
if upload_type in [ "tenprint_card_front", "tenprint_card_back" ]:
create_thumbnail( file_uuid, img, upload_uuid )
create_thumbnail( file_uuid, img, submission_uuid )
else:
file_data = fp.getvalue()
......@@ -1520,7 +1520,7 @@ def upload_file():
if upload_type == "consent_form":
sql = "SELECT email_aes FROM submissions WHERE uuid = %s"
email = config.db.query_fetchone( sql, ( upload_uuid, ) )[ "email_aes" ]
email = config.db.query_fetchone( sql, ( submission_uuid, ) )[ "email_aes" ]
email = do_decrypt_user_session( email )
sql = "SELECT username, email FROM users WHERE type = 2 ORDER BY id DESC"
......@@ -1578,12 +1578,12 @@ def upload_file():
config.db.query( sql , data )
sql = "UPDATE submissions SET consent_form = true WHERE uuid = %s"
config.db.query( sql, ( upload_uuid, ) )
config.db.query( sql, ( submission_uuid, ) )
config.db.commit()
else:
file_data = do_encrypt_dek( file_data, upload_uuid )
file_data = do_encrypt_dek( file_data, submission_uuid )
sql = sql_insert_generate( "files", [
"folder", "creator",
......@@ -2339,7 +2339,7 @@ def submission_tenprint( submission_id, tenprint_id ):
files.uuid, files.filename, files.note,
files.format, files.resolution, files.width, files.height, files.size,
files.creation_time, files.type,
file_template.template
file_template.template, files.quality
FROM files
LEFT JOIN file_template ON files.uuid = file_template.file
WHERE
......@@ -2391,6 +2391,11 @@ def submission_tenprint( submission_id, tenprint_id ):
############################################################################
sql = "SELECT id, name FROM quality_type"
quality_type = config.db.query_fetchall( sql )
############################################################################
zones = get_tenprint_template_zones( tenprint_file[ "template" ], t )
datacolumns = [ "tl_x", "tl_y", "br_x", "br_y", "angle" ]
......@@ -2414,7 +2419,8 @@ def submission_tenprint( submission_id, tenprint_id ):
svg_hw_factor = svg_hw_factor,
zones = zones,
datacolumns = datacolumns,
tenprint_templates = tenprint_templates
tenprint_templates = tenprint_templates,
quality_type = quality_type
)
@app.route( baseurl + "/submission/<submission_id>/tenprint/<tenprint_id>/delete" )
......@@ -2486,6 +2492,22 @@ def submission_file_set_note( submission_id, file_type, tenprint_id ):
"error": False
} )
@app.route( baseurl + "/submission/<submission_id>/tenprint/<tenprint_id>/set/quality", methods = [ "POST" ] )
@submitter_required
def submission_tenprint_set_quality( submission_id, tenprint_id ):
"""
Store the user encrypted notes for a tenprint image.
"""
quality = request.form.get( "quality" )
sql = "UPDATE files SET quality = %s WHERE uuid = %s RETURNING id"
config.db.query( sql, ( quality, tenprint_id, ) )
config.db.commit()
return jsonify( {
"error": False
} )
################################################################################
# Tenprint segments
......
......@@ -35,7 +35,8 @@ CREATE TABLE public.files (
height integer,
format character varying,
resolution integer,
note character varying
note character varying,
quality integer
);
......
......@@ -30,7 +30,8 @@ CREATE VIEW public.files_v AS
files.height,
files.uuid,
files.format,
files.note
files.note,
files.quality
FROM public.files;
......
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: quality_type; Type: TABLE; Schema: public; Owner: icnml
--
CREATE TABLE public.quality_type (
id integer NOT NULL,
name character varying NOT NULL
);
ALTER TABLE public.quality_type OWNER TO icnml;
--
-- Name: newtable_id_seq; Type: SEQUENCE; Schema: public; Owner: icnml
--
CREATE SEQUENCE public.newtable_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.newtable_id_seq OWNER TO icnml;
--
-- Name: newtable_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: icnml
--
ALTER SEQUENCE public.newtable_id_seq OWNED BY public.quality_type.id;
--
-- Name: quality_type id; Type: DEFAULT; Schema: public; Owner: icnml
--
ALTER TABLE ONLY public.quality_type ALTER COLUMN id SET DEFAULT nextval('public.newtable_id_seq'::regclass);
--
-- Data for Name: quality_type; Type: TABLE DATA; Schema: public; Owner: icnml
--
INSERT INTO public.quality_type VALUES (1, 'Prestine');
INSERT INTO public.quality_type VALUES (2, 'Medium');
INSERT INTO public.quality_type VALUES (3, 'Bad');
--
-- Name: newtable_id_seq; Type: SEQUENCE SET; Schema: public; Owner: icnml
--
SELECT pg_catalog.setval('public.newtable_id_seq', 3, true);
--
-- PostgreSQL database dump complete
--
......@@ -70,6 +70,29 @@
} );
}
var update_quality_db = function()
{
var quality = $( "#file_{{ file[ 'uuid' ] }}_quality > select > option:checked" ).val();
$.ajax( {
url: "{{ url_for( 'submission_tenprint_set_quality', submission_id = submission_id, tenprint_id = file[ 'uuid' ] ) }}",
dataType: "json",
method: "POST",
data: {
quality: quality
},
success: function( data )
{
if( data.error )
toastr.error( "Error while saving the quality value" );
},
error: function( data )
{
toastr.error( "Network error" );
}
} );
}
var update_note_db = function()
{
var note = $( "#file_note" ).val() || null;
......@@ -321,6 +344,18 @@
</select>
</div>
<div>Quality</div>
<div id="file_{{ file[ 'uuid' ] }}_quality">
<select name="tenprint_quality_select">
<option value="0" id="tenprint_quality_none_option" selected>None</option>
{% for quality_type in quality_type %}
<option value="{{ quality_type[ 'id' ] }}" id="tenprint_quality_{{ quality_type[ 'id' ] }}_option">
{{ quality_type[ 'name' ] }}
</option>
{% endfor %}
</select>
</div>
<div>Notes</div>
<div><textarea rows="6" id="file_note"></textarea></div>
</div>
......@@ -372,8 +407,11 @@
$( "#delete_button" ).on( "click", delete_tenprint );
$( "#file_{{ file[ 'uuid' ] }}_template > select" ).on( "change", update_template_db );
$( "#file_{{ file[ 'uuid' ] }}_quality > select" ).on( "change", update_quality_db );
$( "#{{ file[ 'template' ] }}_option" ).prop( "selected", true );
$( "#tenprint_quality_{{ file[ 'quality' ] }}_option" ).prop( "selected", true );
{% if file[ "template" ] == None or file[ "template" ] == 0 %}
$( "#segmentation_button" )
.removeClass( "ui-state-default" )
......