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)
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)
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
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)
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)
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"]
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"]
def spc_resource_delete(context, data_dict): if not is_resource_updatable(data_dict['id']): return {'success': False} return resource_delete(context, data_dict)