diff --git a/InvenTree/InvenTree/version.py b/InvenTree/InvenTree/version.py index 307e801121..33a4aa3c0e 100644 --- a/InvenTree/InvenTree/version.py +++ b/InvenTree/InvenTree/version.py @@ -70,7 +70,7 @@ def inventreeInstanceTitle(): def inventreeVersion(): """ Returns the InvenTree version string """ - return INVENTREE_SW_VERSION + return INVENTREE_SW_VERSION.lower().strip() def inventreeVersionTuple(version=None): @@ -84,6 +84,33 @@ def inventreeVersionTuple(version=None): return [int(g) for g in match.groups()] +def isInvenTreeDevelopmentVersion(): + """ + Return True if current InvenTree version is a "development" version + """ + + print("is dev?", inventreeVersion()) + + return inventreeVersion().endswith('dev') + + +def inventreeDocsVersion(): + """ + Return the version string matching the latest documentation. + + Development -> "latest" + Release -> "major.minor" + + """ + + if isInvenTreeDevelopmentVersion(): + return "latest" + else: + major, minor, patch = inventreeVersionTuple() + + return f"{major}.{minor}" + + def isInvenTreeUpToDate(): """ Test if the InvenTree instance is "up to date" with the latest version. diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index 3b88deb504..ce4ead853a 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -136,6 +136,21 @@ def inventree_version(*args, **kwargs): return version.inventreeVersion() +@register.simple_tag() +def inventree_is_development(*args, **kwargs): + return version.isInvenTreeDevelopmentVersion() + + +@register.simple_tag() +def inventree_is_release(*args, **kwargs): + return not version.isInvenTreeDevelopmentVersion() + + +@register.simple_tag() +def inventree_docs_version(*args, **kwargs): + return version.inventreeDocsVersion() + + @register.simple_tag() def inventree_api_version(*args, **kwargs): """ Return InvenTree API version """ @@ -169,7 +184,10 @@ def inventree_github_url(*args, **kwargs): @register.simple_tag() def inventree_docs_url(*args, **kwargs): """ Return URL for InvenTree documenation site """ - return "https://inventree.readthedocs.io/" + + tag = version.inventreeDocsVersion() + + return f"https://inventree.readthedocs.io/en/{tag}" @register.simple_tag() diff --git a/InvenTree/templates/about.html b/InvenTree/templates/about.html index 0750b9711a..aaa14adce5 100644 --- a/InvenTree/templates/about.html +++ b/InvenTree/templates/about.html @@ -22,13 +22,39 @@