Пример #1
0
def datagovro_theme_resource_delete(context, data_dict):
    model = context['model']
    resource = model.Resource.get(data_dict['id'])

    if datetime.now() - resource.created > timedelta(days=5):
        return {'success': False, 'msg': ERROR_STRING}
    return resource_delete(context, data_dict)
Пример #2
0
def romania_theme_resource_delete(context, data_dict):
    model = context['model']
    resource = model.Resource.get(data_dict['id'])

    if datetime.now() - resource.created > timedelta(days=5):
        return {'success': False, 'msg': ERROR_STRING}
    return resource_delete(context, data_dict)
Пример #3
0
def spatialingestor_job_submit(context, data):
    res_id, job_type = get_or_bust(data, ['resource_id', 'job_type'])

    if job_type == 'ingest':
        return auth_create.resource_create(context, {'id': res_id})
    elif job_type == 'purge':
        return auth_delete.resource_delete(context, {'id': res_id})
    else:
        return False
Пример #4
0
    def test_no_org_user_cant_delete(self):
        user = factories.User()
        org = factories.Organization()
        dataset = factories.Dataset(owner_org=org['id'],
                                    resources=[factories.Resource()])

        response = auth_delete.resource_delete(
            {'user': user['name'], 'model': model},
            {'id': dataset['resources'][0]['id']})

        assert_equals(response['success'], False)
Пример #5
0
    def test_no_org_user_cant_delete(self):
        user = factories.User()
        org = factories.Organization()
        dataset = factories.Dataset(owner_org=org['id'],
                                    resources=[factories.Resource()])

        response = auth_delete.resource_delete(
            {'user': user['name'], 'model': model},
            {'id': dataset['resources'][0]['id']})

        assert_equals(response['success'], False)
Пример #6
0
    def test_org_user_can_delete(self):
        user = factories.User()
        org_users = [{'name': user['name'], 'capacity': 'editor'}]
        org = factories.Organization(users=org_users)
        dataset = factories.Dataset(owner_org=org['id'],
                                    resources=[factories.Resource()],
                                    user=user)

        response = auth_delete.resource_delete(
            {'user': user['name'], 'model': model},
            {'id': dataset['resources'][0]['id']})

        assert_equals(response['success'], True)
Пример #7
0
    def test_no_org_user_cant_delete(self):
        user = factories.User()
        org = factories.Organization()
        dataset = factories.Dataset(
            owner_org=org["id"], resources=[factories.Resource()]
        )

        response = auth_delete.resource_delete(
            {"user": user["name"], "model": model},
            {"id": dataset["resources"][0]["id"]},
        )

        assert not response["success"]
Пример #8
0
    def test_org_user_can_delete(self):
        user = factories.User()
        org_users = [{'name': user['name'], 'capacity': 'editor'}]
        org = factories.Organization(users=org_users)
        dataset = factories.Dataset(owner_org=org['id'],
                                    resources=[factories.Resource()],
                                    user=user)

        response = auth_delete.resource_delete(
            {'user': user['name'], 'model': model},
            {'id': dataset['resources'][0]['id']})

        assert_equals(response['success'], True)
Пример #9
0
    def test_org_user_can_delete(self):
        user = factories.User()
        org_users = [{"name": user["name"], "capacity": "editor"}]
        org = factories.Organization(users=org_users)
        dataset = factories.Dataset(
            owner_org=org["id"], resources=[factories.Resource()], user=user
        )

        response = auth_delete.resource_delete(
            {"user": user["name"], "model": model, "auth_user_obj": user},
            {"id": dataset["resources"][0]["id"]},
        )

        assert response["success"]
Пример #10
0
def spc_resource_delete(context, data_dict):
    if not is_resource_updatable(data_dict['id']):
        return {'success': False}
    return resource_delete(context, data_dict)