Commit a481e45c authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[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(
hash=hashDataset(protocol.database.fullname(),, name),
class DatabaseSetQuerySet(models.query.QuerySet):
def create(self, **kwargs):
protocol = kwargs["protocol"]
name = kwargs["name"]
kwargs["hash"] = hashDataset(protocol.database.fullname(),, name)
return super().create(**kwargs)
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
Supports Markdown
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