Commit a481e45c authored by Samuel GAIST's avatar Samuel GAIST

[databases][models] Use a custom QuerySet for DatabaseSet

This allows to properly create it when using the
get_or_create QuerySet method.
parent ef854288
...@@ -415,18 +415,15 @@ class DatabaseSetTemplate(models.Model): ...@@ -415,18 +415,15 @@ class DatabaseSetTemplate(models.Model):
# ---------------------------------------------------------- # ----------------------------------------------------------
class DatabaseSetManager(models.Manager): class DatabaseSetQuerySet(models.query.QuerySet):
def create(self, protocol, template, name): def create(self, **kwargs):
dataset = DatabaseSet( protocol = kwargs["protocol"]
name=name, name = kwargs["name"]
template=template, kwargs["hash"] = hashDataset(protocol.database.fullname(),, name)
protocol=protocol, return super().create(**kwargs)
hash=hashDataset(protocol.database.fullname(),, name),
return dataset
class DatabaseSetManager(models.manager.BaseManager.from_queryset(DatabaseSetQuerySet)):
def get_by_natural_key( def get_by_natural_key(
self, database_name, database_version, protocol_name, name, template_name self, database_name, database_version, protocol_name, name, template_name
): ):
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment