From f6e55addd9bcfe2a851abd2a432ace10144f9734 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Tue, 28 Jun 2016 12:29:53 +0200 Subject: [PATCH] fix duplicate test collection --- .../management/commands/telemeta-create-boilerplate.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/telemeta/management/commands/telemeta-create-boilerplate.py b/telemeta/management/commands/telemeta-create-boilerplate.py index e06eeca3..cccb86fc 100644 --- a/telemeta/management/commands/telemeta-create-boilerplate.py +++ b/telemeta/management/commands/telemeta-create-boilerplate.py @@ -25,8 +25,13 @@ class Command(BaseCommand): result.delete() def handle(self, *args, **options): - collection, c = MediaCollection.objects.get_or_create(title=self.code, - code=self.code, public_access = 'full') + collections = MediaCollection.objects.filter(code=self.code) + if collections: + collection = collection[0] + else: + collection = MediaCollection(title=self.code, code=self.code, public_access='full') + collection.save() + selection, c = Selection.objects.get_or_create(title='Tests') if c: -- 2.39.5