예제 #1
0
def ensure_egap_schema():
    schema = ensure_schema_structure(from_json('egap-registration.json'))
    schema_obj, created = RegistrationSchema.objects.update_or_create(
        name=schema['name'],
        schema_version=schema.get('version', 1),
        defaults={
            'schema': schema,
        })
    if created:
        schema_obj.save()
    return RegistrationSchema.objects.get(name='EGAP Registration')
예제 #2
0
    def handle(self, *args, **options):
        egap_registration_schema = ensure_schema_structure(
            from_json('egap-registration-3.json'))
        schema_obj, created = RegistrationSchema.objects.update_or_create(
            name=egap_registration_schema['name'],
            schema_version=egap_registration_schema.get('version', 1),
            defaults={
                'schema': egap_registration_schema,
            })

        if created:
            logger.info('Added schema {} to the database'.format(
                egap_registration_schema['name']))
        else:
            logger.info('updated existing schema {}'.format(
                egap_registration_schema['name']))
예제 #3
0
def get_file_questions(json_file):
    uploader = {
        'id': 'uploader',
        'type': 'osf-upload',
        'format': 'osf-upload-toggle'
    }
    questions = []
    schema = from_json(json_file)
    for item in schema['pages']:
        for question in item['questions']:
            if question['type'] == 'osf-upload':
                questions.append((question['qid'], question['title']))
                continue
            properties = question.get('properties')
            if properties is None:
                continue
            if uploader in properties:
                questions.append((question['qid'], question['title']))
    return questions
예제 #4
0
def get_file_questions(json_file):
    uploader = {
        'id': 'uploader',
        'type': 'osf-upload',
        'format': 'osf-upload-toggle'
    }
    questions = []
    schema = from_json(json_file)
    for item in schema['pages']:
        for question in item['questions']:
            if question['type'] == 'osf-upload':
                questions.append((question['qid'], question['title']))
                continue
            properties = question.get('properties')
            if properties is None:
                continue
            if uploader in properties:
                questions.append((question['qid'], question['title']))
    return questions
예제 #5
0
def add_schema(apps, schema_editor):
    schema = ensure_schema_structure(from_json('secondary-data.json'))

    RegistrationSchema.objects.filter(name=schema['name']).update(
        visible=False, active=True)