Beispiel #1
0
def update_draft(request, draft_pk):

	get_schema_or_fail = lambda query: get_or_http_error(MetaSchema, query)

	data = json.load(request)

	draft = get_draft_obj(draft_pk)

	schema_data = data['schema_data']

	schema_name = data['schema_name']
	schema_version = data['schema_version']

	if schema_name:
	    meta_schema = get_schema_or_fail(
	        Q('name', 'eq', schema_name) &
	        Q('schema_version', 'eq', schema_version)
	    )

	    existing_schema = draft[0].registration_schema
	    if (existing_schema.name, existing_schema.schema_version) != (meta_schema.name, meta_schema.schema_version):
	        draft[0].registration_schema = meta_schema

	try:
		draft[0].update_metadata(schema_data)
	except (NodeStateError):
	    raise HTTPError(http.BAD_REQUEST)
	response = serialize_draft_registration(draft[0], draft[1])
	return HttpResponse(json.dumps(response), content_type='application/json')
Beispiel #2
0
def update_draft(request, draft_pk):

    get_schema_or_fail = lambda query: get_or_http_error(MetaSchema, query)

    data = json.load(request)

    draft = get_draft_obj(draft_pk)

    schema_data = data['schema_data']

    schema_name = data['schema_name']
    schema_version = data['schema_version']

    if schema_name:
        meta_schema = get_schema_or_fail(
            Q('name', 'eq', schema_name)
            & Q('schema_version', 'eq', schema_version))

        existing_schema = draft[0].registration_schema
        if (existing_schema.name, existing_schema.schema_version) != (
                meta_schema.name, meta_schema.schema_version):
            draft[0].registration_schema = meta_schema

    try:
        draft[0].update_metadata(schema_data)
    except (NodeStateError):
        raise HTTPError(http.BAD_REQUEST)
    response = serialize_draft_registration(draft[0], draft[1])
    return HttpResponse(json.dumps(response), content_type='application/json')
def get_draft(draft_pk):
	auth = Auth(adminUser)
	
	draft = DraftRegistration.find(
        Q('_id', 'eq', draft_pk)
    )

	return utils.serialize_draft_registration(draft[0], auth), http.OK
Beispiel #4
0
def get_all_drafts():
	# TODO[lauren]: add query parameters to only retrieve submitted drafts, they will have an approval associated with them
	all_drafts = DraftRegistration.find()

	auth = Auth(adminUser)

	serialized_drafts = {
		'drafts': [utils.serialize_draft_registration(d, auth) for d in all_drafts]
	}
	return serialized_drafts
def get_all_drafts():
	# TODO 
	# add query parameters to only retrieve submitted drafts
	all_drafts = DraftRegistration.find()

	auth = Auth(adminUser)

	serialized_drafts = {
		'drafts': [utils.serialize_draft_registration(d, auth) for d in all_drafts]
	}
	return serialized_drafts
Beispiel #6
0
def get_all_drafts():
    # TODO[lauren]: add query parameters to only retrieve submitted drafts, they will have an approval associated with them
    all_drafts = DraftRegistration.find()

    auth = Auth(adminUser)

    serialized_drafts = {
        'drafts':
        [utils.serialize_draft_registration(d, auth) for d in all_drafts]
    }
    return serialized_drafts
Beispiel #7
0
def get_draft(draft_pk):
    auth = Auth(adminUser)

    draft = DraftRegistration.find(Q('_id', 'eq', draft_pk))

    return utils.serialize_draft_registration(draft[0], auth), http.OK