File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -572,15 +572,10 @@ def apps_open(self, args):
572572 # TODO: replace with a single API call to apps endpoint
573573 response = self ._dispatch ('get' , "/api/apps/{}" .format (app ))
574574 if response .status_code == requests .codes .ok : # @UndefinedVariable
575- cluster = response .json ()['cluster' ]
576- else :
577- raise ResponseError (response )
578- response = self ._dispatch ('get' , "/api/clusters/{}" .format (cluster ))
579- if response .status_code == requests .codes .ok : # @UndefinedVariable
580- domain = response .json ()['domain' ]
575+ url = response .json ()['url' ]
581576 # use the OS's default handler to open this URL
582- webbrowser .open ('http://{}.{}/' .format (app , domain ))
583- return domain
577+ webbrowser .open ('http://{}.{}/' .format (app , url ))
578+ return url
584579 else :
585580 raise ResponseError (response )
586581
Original file line number Diff line number Diff line change @@ -131,6 +131,10 @@ class Meta:
131131 def __str__ (self ):
132132 return self .id
133133
134+ @property
135+ def url (self ):
136+ return self .id + '.' + self .cluster .domain
137+
134138 def create (self , * args , ** kwargs ):
135139 config = Config .objects .create (owner = self .owner , app = self , values = {})
136140 build = Build .objects .create (owner = self .owner , app = self , image = settings .DEFAULT_BUILD )
Original file line number Diff line number Diff line change @@ -172,6 +172,7 @@ class AppSerializer(serializers.ModelSerializer):
172172 owner = serializers .Field (source = 'owner.username' )
173173 id = serializers .SlugField (default = utils .generate_app_name )
174174 cluster = serializers .SlugRelatedField (slug_field = 'id' )
175+ url = serializers .Field (source = 'url' )
175176
176177 class Meta :
177178 """Metadata options for a :class:`AppSerializer`."""
Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ def test_app(self):
4242 app_id = response .data ['id' ] # noqa
4343 self .assertIn ('cluster' , response .data )
4444 self .assertIn ('id' , response .data )
45+ self .assertIn ('url' , response .data )
46+ self .assertEqual (response .data ['url' ], '{app_id}.autotest.local' .format (** locals ()))
4547 response = self .client .get ('/api/apps' )
4648 self .assertEqual (response .status_code , 200 )
4749 self .assertEqual (len (response .data ['results' ]), 1 )
You can’t perform that action at this time.
0 commit comments