From: Guillaume Pellerin Date: Tue, 28 Jun 2016 10:29:53 +0000 (+0200) Subject: fix duplicate test collection X-Git-Tag: search~2^2~29 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=f6e55addd9bcfe2a851abd2a432ace10144f9734;p=telemeta.git fix duplicate test collection --- 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: