Commit 0239870f authored by Christophe Benz's avatar Christophe Benz

If latest tag, display doc_url, else project URL at ref

parent f0fdc2f8
......@@ -50,7 +50,7 @@
</a>
{% endif %}
{% if schema_current_version == 'master' %}
{% if doc_url and doc_url != schema_info.homepage %}
<a href="{{ doc_url }}" target="_blank" class="card-link d-block ml-0">Documentation</a>
{% endif %}
{% endmacro %}
......
......@@ -74,11 +74,10 @@ class SchemaInstance:
if schema_reference is None:
abort(400, "Schéma '{}' non trouvé dans le catalogue de la section '{}'".format(self.name, self.section_name))
self.doc_url = schema_reference.doc_url
if isinstance(schema_reference, GitSchemaReference):
latest_tag = schema_reference.get_latest_tag()
if self.ref is None:
schema_ref = schema_reference.get_latest_tag() or schema_reference.get_default_branch()
schema_ref = latest_tag or schema_reference.get_default_branch()
abort(redirect(compute_validation_form_url({
'schema_name': self.schema_and_section_name,
'schema_ref': schema_ref.name
......@@ -87,6 +86,9 @@ class SchemaInstance:
tag_names = [tag.name for tag in self.tags]
self.branches = [branch for branch in schema_reference.iter_branches()
if branch.name not in tag_names]
self.doc_url = schema_reference.doc_url \
if self.ref == latest_tag.name \
else schema_reference.get_project_url(self.ref)
self.url = schema_reference.get_schema_url(ref=self.ref)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment