def delete(self, cloud_id = None): # lookup user's auth info user_info = User.get_by_id(long(self.user_id)) # pull the entry from the db cloud = Cloud.get_by_id(long(cloud_id)) # check the number of instances count = Instance.get_count_by_cloud(cloud.key) # deny if it has instances if count > 0: self.add_message('You may not delete a cloud with instances!', 'info') # if we found it and own it, delete elif cloud and cloud.owner == user_info.key: cloud.key.delete() self.add_message('Cloud successfully deleted!', 'success') else: self.add_message('Cloud was not deleted. Something went horribly wrong somewhere!', 'warning') # hangout for a second time.sleep(1) # use the channel to tell the browser we are done and reload channel_token = self.request.get('channel_token') channel.send_message(channel_token, 'reload') return
def delete(self, cloud_id=None): # lookup user's auth info user_info = User.get_by_id(long(self.user_id)) # pull the entry from the db cloud = Cloud.get_by_id(long(cloud_id)) # check the number of instances count = Instance.get_count_by_cloud(cloud.key) # deny if it has instances if count > 0: self.add_message('You may not delete a cloud with instances!', 'info') # if we found it and own it, delete elif cloud and cloud.owner == user_info.key: cloud.key.delete() self.add_message('Cloud successfully deleted!', 'success') else: self.add_message( 'Cloud was not deleted. Something went horribly wrong somewhere!', 'warning') # hangout for a second time.sleep(1) # use the channel to tell the browser we are done and reload channel_token = self.request.get('channel_token') channel.send_message(channel_token, 'reload') return
def get(self): # lookup user's auth info user_info = User.get_by_id(long(self.user_id)) # look up appliances clouds = Cloud.get_by_user(user_info.key) # instance counts for cloud in clouds: count = Instance.get_count_by_cloud(cloud.key) cloud.instance_count = count # setup channel to do page refresh channel_token = user_info.key.urlsafe() refresh_channel = channel.create_channel(channel_token) # params build out params = { 'clouds': clouds, 'refresh_channel': refresh_channel, 'channel_token': channel_token } return self.render_template('cloud/list.html', **params)