Commit 25d3882e authored by Samuel GAIST's avatar Samuel GAIST

[utils][commands][install] Make link_contribution_versions aware of author

This avoids the need to have a dedicated version of Database
as well as ProtocolTemplates
parent 837dcc81
......@@ -901,33 +901,20 @@ def upload_dispatcher(prefix, project, type, name, data):
return True
def link_database_versions():
"""Link object versions together"""
from ....databases.models import Database
for obj in Database.objects.all():
if obj.version > 1:
# search for similar
try:
existing = Database.objects.get(name=obj.name, version=obj.version - 1)
logger.info("Linking database `%s' -> `%s' (version)", obj, existing)
obj.previous_version = existing
obj.save()
except Database.DoesNotExist:
pass # ignores
def link_contribution_versions(klass):
"""Link object versions together"""
for obj in klass.objects.all():
if obj.version > 1:
# search for similar
args = {"name": obj.name, "version": obj.version - 1}
if hasattr(obj, "author"):
args["author"] = obj.author
try:
existing = klass.objects.get(
author=obj.author, name=obj.name, version=obj.version - 1
)
existing = klass.objects.get(**args)
logger.info(
"Linking %s `%s' -> `%s' (version)",
klass.__name__.lower(),
......@@ -995,7 +982,10 @@ def install_contributions(source_prefix, project, template_data, db_root_file=No
if k in db_root:
template_data["root_folder"] = db_root[k]
upload_dispatcher(source_prefix, project, "databases", k, template_data)
link_database_versions()
from ....databases.models import Database
link_contribution_versions(Database)
for k in list_objects(source_prefix, project, "toolchains", "*.json"):
upload_dispatcher(source_prefix, project, "toolchains", k, template_data)
......
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