Commit 072089e5 authored by Samuel GAIST's avatar Samuel GAIST

[common][models] Add create_object to VersionableManager

This should allow to centralize versionable only
object creation like Database and ProtocolTemplate.
parent 239bb6a2
......@@ -390,6 +390,29 @@ class VersionableManager(ShareableManager):
def is_last_version(self, object):
return not self.filter(name=object.name, version__gt=object.version).exists()
def create_object(
self,
name,
short_description="",
description="",
declaration=None,
version=1,
previous_version=None,
fork_of=None,
):
create = getattr(self, "create_{}".format(self.model.__name__.lower()))
return create(
name=name,
short_description=short_description,
description=description,
declaration=declaration,
version=version,
previous_version=previous_version,
fork_of=fork_of,
)
# ----------------------------------------------------------
......
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