예제 #1
0
def new_record():
    """Create an empty record with default values."""
    record = dump_empty(RDMRecordSchema)
    defaults = current_app.config.get("APP_RDM_DEPOSIT_FORM_DEFAULTS") or {}
    for key, value in defaults.items():
        set_default_value(record, value, key)
    return record
예제 #2
0
 def deposits_create():
     """Record creation page."""
     forms_config = dict(
         createUrl=("/api/records"),
         vocabularies=Vocabularies.dump(),
     )
     return render_template(
         current_app.config['DEPOSITS_FORMS_BASE_TEMPLATE'],
         forms_config=forms_config,
         record=dump_empty(RDMRecordSchema),
         searchbar_config=dict(searchUrl=search_url))
예제 #3
0
def new_record():
    """Create an empty record with default values."""
    record = dump_empty(RDMRecordSchema)
    record["files"] = {"enabled": True}
    if "doi" in current_rdm_records.records_service.config.pids_providers:
        record["pids"] = {"doi": {"provider": "external", "identifier": ""}}
    else:
        record["pids"] = {}
    defaults = current_app.config.get("APP_RDM_DEPOSIT_FORM_DEFAULTS") or {}
    for key, value in defaults.items():
        set_default_value(record, value, key)
    return record
예제 #4
0
 def deposits_create():
     """Record creation page."""
     forms_config = dict(createUrl=("/api/records"),
                         vocabularies=Vocabularies.dump(),
                         current_locale=str(current_i18n.locale))
     return render_template(
         current_app.config['DEPOSITS_FORMS_BASE_TEMPLATE'],
         forms_config=forms_config,
         record=dump_empty(RDMRecordSchema),
         files=dict(default_preview=None,
                    enabled=True,
                    entries=[],
                    links={}),
         searchbar_config=dict(searchUrl=search_url))
예제 #5
0
def test_dumping_empty_record():
    empty_record = dump_empty(MetadataSchema())

    assert empty_record == {
        '_access': {
            'files_restricted': None,
            'metadata_restricted': None
        },
        '_default_preview':
        None,
        '_communities':
        None,
        '_contact':
        None,
        '_created_by':
        None,
        '_embargo_date':
        None,
        '_files': [{
            'bucket': None,
            'checksum': None,
            'key': None,
            'links': None,
            'size': None,
            'type': None
        }],
        '_internal_notes': [{
            'user': None,
            'timestamp': None,
            'note': None
        }],
        '_owners': [None],
        # 'access_right': None,
        'contributors': [{
            'affiliations': [{
                'name': None,
                'identifiers': None,
            }],
            'family_name':
            None,
            'given_name':
            None,
            'identifiers':
            None,
            'name':
            None,
            'role':
            None,
            'type':
            None,
        }],
        'creators': [{
            'affiliations': [{
                'name': None,
                'identifiers': None,
            }],
            'family_name': None,
            'given_name': None,
            'identifiers': None,
            'name': None,
            'type': None,
        }],
        'dates': [{
            'type': None,
            'end': None,
            'description': None,
            'start': None
        }],
        'extensions':
        None,
        'descriptions': [{
            'type': None,
            'lang': None,
            'description': None
        }],
        'language':
        None,
        'locations': [{
            'description': None,
            'point': {
                'lon': None,
                'lat': None
            },
            'place': None
        }],
        'licenses': [{
            'identifier': None,
            'scheme': None,
            'uri': None,
            'license': None
        }],
        'version':
        None,
        'publication_date':
        None,
        'references': [{
            'scheme': None,
            'reference_string': None,
            'identifier': None
        }],
        'related_identifiers': [{
            'resource_type': {
                'subtype': None,
                'type': None
            },
            'scheme': None,
            'relation_type': None,
            'identifier': None
        }],
        'resource_type': {
            'subtype': None,
            'type': None
        },
        'subjects': [{
            'subject': None,
            'identifier': None,
            'scheme': None
        }],
        'titles': [{
            'type': None,
            'lang': None,
            'title': None
        }],
        # TODO: Investigate the impact of these 2 fields on
        #       frontend to backend to frontend flow
        'identifiers':
        None,
        'recid':
        None
    }