1313import re
1414import time
1515import json
16+ import uuid
1617from threading import Thread
1718
1819from django .conf import settings
2829import requests
2930from rest_framework .authtoken .models import Token
3031
31- from api import fields , utils , exceptions
32+ from api import utils , exceptions
3233from registry import publish_release
3334from utils import dict_diff , dict_merge , fingerprint
3435
@@ -129,7 +130,12 @@ class Meta:
129130class UuidAuditedModel (AuditedModel ):
130131 """Add a UUID primary key to an :class:`AuditedModel`."""
131132
132- uuid = fields .UuidField ('UUID' , primary_key = True )
133+ uuid = models .UUIDField ('UUID' ,
134+ default = uuid .uuid4 ,
135+ primary_key = True ,
136+ editable = False ,
137+ auto_created = True ,
138+ unique = True )
133139
134140 class Meta :
135141 """Mark :class:`UuidAuditedModel` as abstract."""
@@ -155,7 +161,6 @@ class Meta:
155161 def select_app_name (self ):
156162 """Select a unique randomly generated app name"""
157163 name = utils .generate_app_name ()
158-
159164 while App .objects .filter (id = name ).exists ():
160165 name = utils .generate_app_name ()
161166
@@ -767,7 +772,7 @@ def save(self, **kwargs):
767772 return super (Build , self ).save (** kwargs )
768773
769774 def __str__ (self ):
770- return "{0}-{1}" .format (self .app .id , self .uuid [:7 ])
775+ return "{0}-{1}" .format (self .app .id , str ( self .uuid ) [:7 ])
771776
772777
773778@python_2_unicode_compatible
@@ -790,7 +795,7 @@ class Meta:
790795 unique_together = (('app' , 'uuid' ),)
791796
792797 def __str__ (self ):
793- return "{}-{}" .format (self .app .id , self .uuid [:7 ])
798+ return "{}-{}" .format (self .app .id , str ( self .uuid ) [:7 ])
794799
795800 def save (self , ** kwargs ):
796801 """merge the old config with the new"""
0 commit comments