Example #1
0
def configure_permissions_test_preconditions(
        registration_status='public',
        schema_response_state=ApprovalStates.APPROVED,
        reviews_workflow=DEFAULT_REVIEWS_WORKFLOW,
        role='admin'):
    '''Create and configure a RegistrationProvider, Registration, SchemaResponse and User.'''
    provider = RegistrationProviderFactory()
    provider.update_group_permissions()
    provider.reviews_workflow = reviews_workflow
    provider.save()

    registration = RegistrationFactory(schema=get_default_test_schema(),
                                       provider=provider)
    registration.provider = provider
    if registration_status == 'public':
        registration.is_public = True
    elif registration_status == 'private':
        registration.is_public = False
    elif registration_status == 'withdrawn':
        registration.moderation_state = 'withdrawn'
    elif registration_status == 'deleted':
        registration.deleted = timezone.now()
    registration.save()

    schema_response = registration.schema_responses.last()
    schema_response.approvals_state_machine.set_state(schema_response_state)
    schema_response.save()

    auth = _configure_permissions_test_auth(registration, role)
    return auth, schema_response, registration, provider
Example #2
0
 def provider(self):
     provider = RegistrationProviderFactory()
     provider.update_group_permissions()
     _ensure_subscriptions(provider)
     provider.reviews_workflow = Workflows.PRE_MODERATION.value
     provider.save()
     return provider
def configure_test_preconditions(
        registration_status='public',
        reviews_workflow=DEFAULT_REVIEWS_WORKFLOW,
        schema_response_state=DEFAULT_SCHEMA_RESPONSE_STATE,
        role='admin'):
    '''Create and Configure a RegistrationProvider, Registration, SchemaResponse, and User.'''
    provider = RegistrationProviderFactory()
    provider.update_group_permissions()
    provider.reviews_workflow = reviews_workflow
    provider.save()
    registration = RegistrationFactory(provider=provider,
                                       schema=get_default_test_schema())
    if registration_status == 'public':
        registration.is_public = True
    elif registration_status == 'private':
        registration.is_public = False
        # set moderation state to a realistic value for a private
        # registration with an approved response
        registration.moderation_state = 'embargo'
    elif registration_status == 'withdrawn':
        registration.moderation_state = 'withdrawn'
    elif registration_status == 'deleted':
        registration.deleted = timezone.now()
    registration.save()
    schema_response = registration.schema_responses.last()
    schema_response.actions.create(creator=schema_response.initiator,
                                   from_state=schema_response.reviews_state,
                                   to_state=schema_response_state.db_name,
                                   trigger=DEFAULT_TRIGGER.db_name)
    schema_response.approvals_state_machine.set_state(schema_response_state)
    schema_response.save()
    auth = configure_user_auth(registration, role)
    return auth, schema_response, registration, provider
Example #4
0
 def provider(self, moderator):
     provider = RegistrationProviderFactory()
     update_provider_auth_groups()
     provider.get_group('moderator').user_set.add(moderator)
     provider.reviews_workflow = Workflows.PRE_MODERATION.value
     provider.save()
     return provider
Example #5
0
    def provider(self, moderator):
        provider = RegistrationProviderFactory()
        update_provider_auth_groups()
        provider.schemas.add(get_default_metaschema())
        provider.get_group('moderator').user_set.add(moderator)
        provider.save()

        return provider
Example #6
0
 def provider(self):
     provider = RegistrationProviderFactory()
     asset_file = ProviderAssetFileFactory(
         name='square_color_no_transparent')
     provider.asset_files.add(asset_file)
     provider.access_token = None
     provider.save()
     return provider
 def provider_with_reg(self, osf_reg_schema, egap_schema, schema,
                       out_dated_schema):
     provider = RegistrationProviderFactory()
     update_provider_auth_groups()
     provider.schemas.add(
         *[osf_reg_schema, schema, out_dated_schema, egap_schema])
     provider.save()
     return provider
 def provider(self, schema, out_dated_schema, invisible_schema,
              inactive_schema):
     provider = RegistrationProviderFactory()
     update_provider_auth_groups()
     provider.schemas.add(
         *[schema, out_dated_schema, invisible_schema, inactive_schema])
     provider.save()
     return provider
    def moderator_wrong_provider(self):
        user = AuthUserFactory()
        provider = RegistrationProviderFactory()
        update_provider_auth_groups()
        provider.schemas.add(get_default_metaschema())
        provider.get_group('moderator').user_set.add(user)
        provider.save()

        return user
Example #10
0
def configure_test_preconditions(
        registration_status='public',
        reviews_workflow=DEFAULT_REVIEWS_WORKFLOW,
        schema_response_state=DEFAULT_SCHEMA_RESPONSE_STATE,
        role='admin'):
    '''Create and Configure a RegistrationProvider, Registration, SchemaResponse, and User.'''
    provider = RegistrationProviderFactory()
    provider.update_group_permissions()
    provider.reviews_workflow = reviews_workflow
    provider.save()

    registration = RegistrationFactory(provider=provider,
                                       schema=get_default_test_schema())
    if registration_status == 'public':
        registration.is_public = True
    elif registration_status == 'private':
        registration.is_public = False
        # set moderation state to a realistic value for a private
        # registration with an approved response
        registration.moderation_state = 'embargo'
    elif registration_status == 'withdrawn':
        registration.moderation_state = 'withdrawn'
    elif registration_status == 'deleted':
        registration.deleted = timezone.now()
    registration.save()

    schema_response = registration.schema_responses.last()
    schema_response.approvals_state_machine.set_state(schema_response_state)
    schema_response.save()
    # Set the required fields on the schema response
    for block in schema_response.response_blocks.all():
        block.set_response(DEFAULT_SCHEMA_RESPONSES.get(block.schema_key))

    auth = configure_user_auth(registration, role)

    # Do this step after configuring auth to ensure any new admin user, gets added
    if schema_response_state is ApprovalStates.UNAPPROVED:
        schema_response.pending_approvers.add(*[
            user
            for user, _ in registration.get_admin_contributors_recursive()
        ])

    if schema_response_state is ApprovalStates.IN_PROGRESS:
        # need valid changes for submission validations
        schema_response.update_responses({'q1': 'update for submission'})
        schema_response.revision_justification = 'has for valid revision_justification for submission'
        schema_response.save()

    return auth, schema_response, registration, provider
Example #11
0
    def setUp(self):
        super().setUp()
        embargo = EmbargoFactory()
        registration = embargo.target_registration
        moderator = AuthUserFactory()
        provider = RegistrationProviderFactory()

        embargo.to_APPROVED()
        embargo.save()
        update_provider_auth_groups()
        provider.get_group('moderator').user_set.add(moderator)
        provider.reviews_workflow = Workflows.PRE_MODERATION.value
        provider.save()
        registration.provider = provider
        registration.update_moderation_state()
        registration.save()

        self.embargo = embargo
        self.registration = registration
        self.user = self.registration.creator
        self.moderator = moderator
        self.provider = provider
Example #12
0
def configure_test_preconditions(registration_status='public',
                                 moderator_workflow=DEFAULT_REVIEWS_WORKFLOW,
                                 updated_response_state=None,
                                 role='admin'):
    '''Create and Configure a RegistrationProvider, Registration, SchemaResponse, and User.'''
    provider = RegistrationProviderFactory()
    provider.update_group_permissions()
    provider.reviews_workflow = moderator_workflow
    provider.save()

    registration = RegistrationFactory(provider=provider)
    if registration_status == 'public':
        registration.is_public = True
    elif registration_status == 'private':
        registration.is_public = False
        # set moderation state to a realistic value for a private
        # registration with an approved response
        registration.moderation_state = 'embargo'
    elif registration_status == 'withdrawn':
        registration.moderation_state = 'withdrawn'
    elif registration_status == 'deleted':
        registration.deleted = timezone.now()
    registration.save()

    initial_response = registration.schema_responses.last()
    initial_response.approvals_state_machine.set_state(ApprovalStates.APPROVED)
    initial_response.save()

    updated_response = None
    if updated_response_state is not None:
        updated_response = SchemaResponse.create_from_previous_response(
            previous_response=initial_response,
            initiator=initial_response.initiator)
        updated_response.approvals_state_machine.set_state(
            updated_response_state)
        updated_response.save()

    auth = configure_auth(registration, role)
    return auth, updated_response, registration, provider
 def provider_with_brand(self, brand):
     registration_provider = RegistrationProviderFactory()
     registration_provider.brand = brand
     registration_provider.save()
     return registration_provider
 def provider_with_egap_only(self, egap_schema):
     provider = RegistrationProviderFactory()
     update_provider_auth_groups()
     provider.schemas.add(egap_schema)
     provider.save()
     return provider
Example #15
0
 def provider_with_v2_prereg_only(self, schema):
     provider = RegistrationProviderFactory()
     update_provider_auth_groups()
     provider.schemas.add(schema)
     provider.save()
     return provider
Example #16
0
 def provider_not_allow_bulk(self, user):
     provider = RegistrationProviderFactory()
     provider.allow_bulk_uploads = False
     provider.add_to_group(user, 'admin')
     provider.save()
     return provider
Example #17
0
 def non_default_provider(self, metaschema_open_ended):
     non_default_provider = RegistrationProviderFactory()
     non_default_provider.schemas.add(metaschema_open_ended)
     non_default_provider.save()
     return non_default_provider
 def moderated_provider(self):
     provider = RegistrationProviderFactory()
     provider.reviews_workflow = Workflows.PRE_MODERATION.value
     provider.save()
     return provider