ontology_helper.rb revision b299dbef5e70f4f78937112b19370a4d5d0e04e3
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanomodule OntologyHelper
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano def current_version
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano o = @ontology.parent ? @ontology.parent : @ontology
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano o.current_version
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano end
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano def download_path(resource)
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano return nil if resource.versions.done.empty?
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano repository_ontology_ontology_version_path(*resource_chain, resource.versions.done.latest.first)
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano end
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano def show_evaluate?
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano show_oops? #|| show_foo?
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano end
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano def status_tag(resource)
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano version = resource.is_a?(Ontology) ? resource.current_version : resource
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano uri = repository_ontology_ontology_version_url(
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano version.ontology.repository, version.ontology, version)
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano html_opts = {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano class: 'ontology-version-state',
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano data: {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano ontology_version_id: version.id,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano uri: uri,
99e4008cad9e959b683c6f48411fcf15a92be3b5Michel Normand state: version.state,
99e4008cad9e959b683c6f48411fcf15a92be3b5Michel Normand }
10fba81b9d0221b8e47aa1e0b43236413b7d28dfMichel Normand }
99e4008cad9e959b683c6f48411fcf15a92be3b5Michel Normand content_tag(:small, html_opts) do
99e4008cad9e959b683c6f48411fcf15a92be3b5Michel Normand status(version)
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano end
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano end
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano def status(resource)
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano html = content_tag :span, resource.state
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano if %w(pending fetching processing).include? resource.state
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano html << " " << image_tag('spinner-16x16.gif', class: 'spinner')
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano end
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano if resource.state == 'failed' and resource.is_a? Ontology
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano version = resource.versions.last
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano link = ' ('
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano link << link_to('error',
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano [resource.repository, resource, :ontology_versions],
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano :'data-original-title' => version.last_error,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano class: 'help'
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano )
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano link << ')'
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano html << content_tag(:span, link.html_safe, class: 'error')
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano end
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano html
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano end
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano def last_file_path(resource)
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano repository_ref_path(repository_id: resource.repository.to_param,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano ref: resource.current_version.commit_oid,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano path: resource.current_version.path,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano action: :show)
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano end
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoend
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano