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):
# ----------------------------------------------------------
class DatabaseSetManager(models.Manager):
def create(self, protocol, template, name):
dataset = DatabaseSet(
name=name,
template=template,
protocol=protocol,
hash=hashDataset(protocol.database.fullname(), protocol.name, name),
)
class DatabaseSetQuerySet(models.query.QuerySet):
def create(self, **kwargs):
protocol = kwargs["protocol"]
name = kwargs["name"]
kwargs["hash"] = hashDataset(protocol.database.fullname(), protocol.name, name)
return super().create(**kwargs)
dataset.save()
return dataset
class DatabaseSetManager(models.manager.BaseManager.from_queryset(DatabaseSetQuerySet)):
def get_by_natural_key(
self, database_name, database_version, protocol_name, name, template_name
):
......
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