Beispiel #1
0
def view_job_container(context, request):
    resource_model = get_resource_model(context)
    jobresources = get_all_data(resource_model, context,
                        methodcaller('order_by', asc(resource_model.title)))
    jobservices = get_all_data(JobService, context,
                        methodcaller('order_by', desc(JobService.id)))
    bootstraps = get_all_data(Bootstrap, context,
                        methodcaller('order_by', desc(Bootstrap.id)))
    return {
        'api': template_api(context, request),
        'jobresources': jobresources,
        'jobservices': jobservices,
        'bootstraps': bootstraps,
    }
Beispiel #2
0
def deferred_bootstrap_widget(node, kw):
    parent = kw['request'].context.parent
    context = get_context_or_parent(parent, u'jobcontainer')
    bootstraps = get_all_data(Bootstrap, context)
    availables = [bootstrap.title.encode('utf-8') for bootstrap in bootstraps]
    widget = CommaSeparatedListWidget(
        template='kotti_mapreduce:templates/deform/bootstrap-list',
        available_bootstraps=availables,
    )
    return widget
Beispiel #3
0
def deferred_resource_data(node, kw):
    values = None
    context = kw['request'].context
    resource = get_resource_model(context)
    if resource:
        order_by = methodcaller('order_by', asc(resource.title))
        job_container = get_context_or_parent(context, u'jobcontainer')
        data = get_all_data(resource, job_container, order_by=order_by)
        values = map(attrgetter('id', 'title'), data)
    return SelectWidget(values=values)
Beispiel #4
0
def deferred_bootstrap_validator(node, kw):
    def raise_invalid_bootstrap(node, value):
        raise colander.Invalid(
            node, _(u"The Bootstrap is not found."))

    request = kw['request']
    if request.POST:
        parent = request.context.parent
        context = get_context_or_parent(parent, u'jobcontainer')
        bootstraps = get_all_data(Bootstrap, context)
        availables = [bootstrap.title for bootstrap in bootstraps]
        posted_bootstraps = request.params.get('bootstrap_titles')
        if posted_bootstraps:
            for posted_bootstrap in posted_bootstraps.split(','):
                if posted_bootstrap not in availables:
                    return raise_invalid_bootstrap