Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
4048a302
Commit
4048a302
authored
9 years ago
by
Kevin S. Hahn
Browse files
Options
Downloads
Patches
Plain Diff
dynamically set search schema scan types enum list
parent
efebbf0c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core.py
+55
-48
55 additions, 48 deletions
core.py
with
55 additions
and
48 deletions
core.py
+
55
−
48
View file @
4048a302
...
...
@@ -365,59 +365,66 @@ class Core(base.RequestHandler):
],
}
SEARCH_POST_SCHEMA
=
{
'
$schema
'
:
'
http://json-schema.org/draft-04/schema#
'
,
'
title
'
:
'
File
'
,
'
type
'
:
'
object
'
,
'
properties
'
:
{
'
subj_code
'
:
{
'
title
'
:
'
Subject Code
'
,
'
type
'
:
'
string
'
,
},
'
scan_type
'
:
{
# MR SPECIFIC!!!
'
title
'
:
'
Scan Type
'
,
'
type
'
:
'
string
'
,
},
'
date_from
'
:
{
'
title
'
:
'
Date From
'
,
'
type
'
:
'
string
'
,
},
'
date_to
'
:
{
'
title
'
:
'
Date To
'
,
'
type
'
:
'
string
'
,
},
'
psd
'
:
{
# MR SPECIFIC!!!
'
title
'
:
'
PSD Name
'
,
'
type
'
:
'
string
'
,
},
'
subj_age_max
'
:
{
# age in years
'
title
'
:
'
Subject Age Max
'
,
'
type
'
:
'
integer
'
,
},
'
subj_age_min
'
:
{
# age in years
'
title
'
:
'
Subject Age Min
'
,
'
type
'
:
'
integer
'
,
},
'
exam
'
:
{
'
title
'
:
'
Exam Number
'
,
'
type
'
:
'
integer
'
,
},
'
description
'
:
{
'
title
'
:
'
Description
'
,
'
type
'
:
'
string
'
,
},
},
# 'required': ['subj_code', 'scan_type', 'date_from', 'date_to', 'psd_name', 'operator', 'subj_age_max', 'subj_age_min', 'exam'],
'
additionalProperties
'
:
False
}
def
search
(
self
):
"""
Search.
"""
SEARCH_POST_SCHEMA
=
{
'
$schema
'
:
'
http://json-schema.org/draft-04/schema#
'
,
'
title
'
:
'
File
'
,
'
type
'
:
'
object
'
,
'
properties
'
:
{
'
subj_code
'
:
{
'
title
'
:
'
Subject Code
'
,
'
type
'
:
'
string
'
,
},
'
subj_firstname
'
:
{
'
title
'
:
'
Subject First Name
'
,
# hash
'
type
'
:
'
string
'
,
},
'
subj_lastname
'
:
{
'
title
'
:
'
Subject Last Name
'
,
'
type
'
:
'
string
'
,
},
'
scan_type
'
:
{
# MR SPECIFIC!!!
'
title
'
:
'
Scan Type
'
,
'
enum
'
:
self
.
app
.
db
.
acquisitions
.
distinct
(
'
types.kind
'
)
},
'
date_from
'
:
{
'
title
'
:
'
Date From
'
,
'
type
'
:
'
string
'
,
},
'
date_to
'
:
{
'
title
'
:
'
Date To
'
,
'
type
'
:
'
string
'
,
},
'
psd
'
:
{
# MR SPECIFIC!!!
'
title
'
:
'
PSD Name
'
,
'
type
'
:
'
string
'
,
# 'enum': self.app.db.acquisitions.distinct('psd'),
},
'
subj_age_max
'
:
{
# age in years
'
title
'
:
'
Subject Age Max
'
,
'
type
'
:
'
integer
'
,
},
'
subj_age_min
'
:
{
# age in years
'
title
'
:
'
Subject Age Min
'
,
'
type
'
:
'
integer
'
,
},
'
exam
'
:
{
'
title
'
:
'
Exam Number
'
,
'
type
'
:
'
integer
'
,
},
'
description
'
:
{
'
title
'
:
'
Description
'
,
'
type
'
:
'
string
'
,
},
},
# 'required': ['subj_code', 'scan_type', 'date_from', 'date_to', 'psd_name', 'operator', 'subj_age_max', 'subj_age_min', 'exam'],
# 'additionalProperties': False
}
if
self
.
request
.
method
==
'
GET
'
:
return
self
.
SEARCH_POST_SCHEMA
return
SEARCH_POST_SCHEMA
try
:
json_body
=
self
.
request
.
json_body
jsonschema
.
validate
(
json_body
,
self
.
SEARCH_POST_SCHEMA
)
jsonschema
.
validate
(
json_body
,
SEARCH_POST_SCHEMA
)
except
(
ValueError
,
jsonschema
.
ValidationError
)
as
e
:
self
.
abort
(
400
,
str
(
e
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment