def delete_scenes(self, client, params = None): if params == None: dialog = render_to_string("opensim/delete_scene_confirmation.html") return {'data':{'dom':{'dialog':dialog}}} else: deleted = Scenes.delete_scenes(params) main = render_to_string("opensim/read_regions.html", {'region_services': Regions().get_region_services(),'scenes':Scenes.get_scenes()}) if deleted: response = { 'status':{ 'code':'SCENES_DELETE_OK', 'i18n':_('Deleted: %(deleted)s scene(s)') % {'deleted':deleted}, 'type': HWIOS.ws_realm._t['notify-info'] } } else: response = { 'status':{ 'code':'SCENES_DELETE_FAIL', 'i18n':_('Failed to delete scenes. Invalid characters!'), 'type': HWIOS.ws_realm._t['notify-error'] } } response.update({'data':{'dom':{'main':main}}}) return response
def delete_scenes(self, client, params = None): """Either renders the template to confirm deleting a scene, or handle the scene deletion process ifself :param Client client: The requesting client :param dict params: Optional; contains the form parameters :return: dict - Status and Html-layout data response """ if params == None: dialog = render_to_string("opensim/delete_scene_confirmation.html") return {'data':{'dom':{'dialog':dialog}}} else: deleted = Scenes.delete_scenes(params) response = self.view_regions(client) if deleted: response.update({ 'status':{ 'code':'SCENES_DELETE_OK', 'i18n':_('Deleted: %(deleted)s scene(s)') % {'deleted':deleted}, 'type': HWIOS.ws_realm._t['notify-info'] } }) else: response.update({ 'status':{ 'code':'SCENES_DELETE_FAIL', 'i18n':_('Failed to delete scenes. Invalid characters!'), 'type': HWIOS.ws_realm._t['notify-error'] } }) return response
def _get_regions(self, client): scenes = Scenes.get_scenes() regions = Regions.get_regions() tpl_params = {'regions': regions,'scenes':scenes} main = render_to_string("opensim/read_regions.html", tpl_params) return [ {'data':{'dom':{'main':main}}}, {'main':{'tpl':'opensim/read_regions.html','params':tpl_params}} ]
def _get_regions(self, client): """Notify_others helper that gets the template-info and rendering of the regions view""" scenes = Scenes.get_scenes() regions = Regions.get_regions() tpl_params = {'regions': regions,'scenes':scenes} main = render_to_string("opensim/read_regions.html", tpl_params) return [ {'data':{'dom':{'main':main}}}, {'main':{'tpl':'opensim/read_regions.html','params':tpl_params}} ]
def view_regions(self, client): scenes = Scenes.get_scenes() regions = Regions.get_regions() region_services = Regions().get_region_services() for count1,region_service in enumerate(region_services): for count2,region in enumerate(region_service['regions']): try: if 'MasterAvatarUUID' in region: profile = Profile.objects.get(uuid = region['MasterAvatarUUID']) region_services[count1]['regions'][count2]['profile'] = {'first_name':profile.first_name,'last_name':profile.last_name} else: region_services[count1]['regions'][count2]['profile'] = {'first_name':'Invalid','last_name':'Invalid'} except ObjectDoesNotExist,KeyError: region_services[count1]['regions'][count2]['profile'] = {'first_name':'Invalid','last_name':'Invalid'}
def upload_scenes(request): if request.method == "POST": file_size = request.META['HTTP_X_FILE_SIZE'] file_name = request.META['HTTP_X_FILE_NAME'] location = HWIOS.services['web_ui'].config.location content = request.raw_post_data f = open(os.path.join(location,'dav_store','oar',file_name), 'w') f.write(content) scenes = Scenes.get_scenes() main = render_to_string("opensim/read_regions.html", {'region_services': Regions().get_region_services(),'scenes':scenes}, context_instance=RequestContext(request)) return JSONResponse({ 'status':{ 'code':'FILE_UPLOADED', 'i18n':_('File(s) succesfully uploaded'), 'type': HWIOS.ws_realm._t['notify-warning'] }, 'data':{'dom':{'main':main}} })
def view_regions(self, client): """Renders the current available regions view :param Client client: The requesting client :return: dict - Html-layout data response """ #check if grid db exists first. scenes = Scenes.get_scenes() regions = Regions.get_regions() region_services = Regions().get_region_services() for count1,region_service in enumerate(region_services): for count2,region in enumerate(region_service['regions']): try: if 'MasterAvatarUUID' in region: profile = Profile.objects.get(uuid = region['MasterAvatarUUID']) region_services[count1]['regions'][count2]['profile'] = {'first_name':profile.first_name,'last_name':profile.last_name} else: region_services[count1]['regions'][count2]['profile'] = {'first_name':'Invalid','last_name':'Invalid'} except ObjectDoesNotExist,KeyError: region_services[count1]['regions'][count2]['profile'] = {'first_name':'Invalid','last_name':'Invalid'}
def load_scene(self, client, scene_name, params = None): if params == None: regions = Regions.get_regions() selection = [] for region in regions: selection.append((region['RegionUUID'],region['name'])) form = LoadSceneForm(choices=selection,initial={'scene_name':scene_name}) dialog = render_to_string("opensim/load_scene_confirmation.html", {'form':form}) defer.returnValue({'data':{'dom':{'dialog':dialog}}}) else: response = {'status':{}} region = Regions.get_region(params['region_uuid']) service_client = HWIOS.pb_server.search_service(region['service_uuid']) result = yield service_client['client'].load_scene(region['service_uuid'],params['region_uuid'], params['scene_name']) if 'loaded' in result: if result['loaded']: response = { 'status':{ 'code':'RESTORE_MADE', 'i18n':_('Succesfully restored scene %(scene)s in region %(region)s...') % {'scene':params['scene_name'],'region':region['name']}, 'type': HWIOS.ws_realm._t['notify-info'] } } else: if 'RADMIN_FAILED' in result['status']['code']: response = { 'status':{ 'code':'RADMIN_FAILED', 'i18n':_(result['status']['feedback']), 'type': HWIOS.ws_realm._t['notify-error'] } } elif 'error' in result: if result['error'] == 'SIM_OFFLINE': response = { 'status':{ 'code':'RESTORE_FAILED', 'i18n':_('Restore failed! Region must be online when loading a scene...'), 'type': HWIOS.ws_realm._t['notify-error'] } } elif result['error'] == 'radmin response timed out': response = { 'status':{ 'code':'RESTORE_RUNNING', 'i18n':_('Loading this OAR may take a while. Check the console for the current progress...'), 'type': HWIOS.ws_realm._t['notify-info'] } } main = render_to_string("opensim/read_regions.html", {'region_services': Regions().get_region_services(),'scenes':Scenes.get_scenes()}) response.update({'data':{'dom':{'main':main}}}) defer.returnValue(response)
def backup_region(self, client, region_uuid, params = None): if params == None: region = Regions().get_region(region_uuid) current_time = time.strftime('%Y-%m-%d-%H.%M') proposed_name = '%s-%s' % (region['name'],current_time) form = BackupRegionForm(initial={'name':proposed_name,'region_uuid':region['RegionUUID'],'service_uuid':region['service_uuid']}) dialog = render_to_string("opensim/backup_region_confirmation.html", {'form':form}) defer.returnValue({'data':{'dom':{'dialog':dialog}}}) else: response = {'status':{}} region = Regions().get_region(region_uuid) service_client = HWIOS.pb_server.search_service(region['service_uuid']) result = yield service_client['client'].backup_region(region['service_uuid'],region_uuid,params['name']) print result if 'saved' in result: if result['saved']: response['status'] = { 'code':'BACKUP_MADE', 'i18n':_('Backup of region %(name)s finished...') % {'name':region['name']}, 'type': HWIOS.ws_realm._t['notify-info'] } else: if result['status']['code'] == 'RADMIN_FAILED': response['status']['i18n'] = _('Backup failed! Region must be online when creating a backup...') response['status']['type'] = HWIOS.ws_realm._t['notify-error'] else: response['status']['i18n'] = _('This may take a while...') response['status']['type'] = HWIOS.ws_realm._t['notify-info'] main = render_to_string("opensim/read_regions.html", {'region_services': Regions().get_region_services(),'scenes':Scenes.get_scenes()}) response.update({'data':{'dom':{'main':main}}}) defer.returnValue(response)