def products_download(request, domain_id): if not request.user.is_authenticated(): return logout(request) allow_download = True billing_enable = getattr(settings, 'ENABLE_BILLING', False) if not billing_enable or \ not keystone.is_default_domain_admin(request)[1]: allow_download = False if allow_download: produncts = _get_products(request, domain_id) produncts.sort(key=_product_comp_fun, reverse=True) xls_datas = [_filter_fields(product) for product in produncts] response = HttpResponse(mimetype='application/vnd.ms-excel') response['Content-Disposition'] = 'attachment;filename="{0}"'.format('bills.xls') xls_writer = XLSWriter(response) xls_writer.add_sheet(xls_header, 'bills') xls_writer.add_rows(xls_datas, 'bills') xls_writer.save() return response else: dashboard = horizon.get_default_dashboard() response = shortcuts.redirect(dashboard.get_absolute_url()) return response
def get_user_home(user): #LOG.info("xxx enter get_user_home of openstack_dashboard/views.py") #LOG.info("xxx user is") #LOG.info(user) try: token = user.token except AttributeError: raise exceptions.NotAuthenticated() # Domain Admin, Project Admin will default to identity dashboard = None if token.project.get('id') is None or user.is_superuser: try: dashboard = horizon.get_dashboard('identity') except base.NotRegistered: pass if dashboard is None: dashboard = horizon.get_default_dashboard() #LOG.info("dashboard = horizon.get_default_dashboard() is") #LOG.info(dashboard) #LOG.info("dashboard.get_absolute_url() is") #LOG.info(dashboard.get_absolute_url()) return dashboard.get_absolute_url()
def get_user_home(user): dashboard = None if user.is_superuser: try: dashboard = horizon.get_dashboard('admin') except base.NotRegistered: pass if dashboard is None: dashboard = horizon.get_default_dashboard() return dashboard.get_absolute_url()
def get_context_data(self, **kwargs): context = super(AngularDetailsView, self).get_context_data(**kwargs) # some parameters are needed for navigation side bar and breadcrumb. title = _("Horizon") context["title"] = title context["page_title"] = title # set default dashboard and panel dashboard = horizon.get_default_dashboard() self.request.horizon['dashboard'] = dashboard self.request.horizon['panel'] = dashboard.get_panels()[0] # set flag that means routed by django context['routed_by_django'] = True return context
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) # some parameters are needed for navigation side bar and breadcrumb. title = _("Horizon") context["title"] = title context["page_title"] = title context["csrf_http"] = settings.CSRF_COOKIE_HTTPONLY # set default dashboard and panel dashboard = horizon.get_default_dashboard() self.request.horizon['dashboard'] = dashboard self.request.horizon['panel'] = dashboard.get_panels()[0] # set flag that means routed by django context['routed_by_django'] = True return context
def get_user_home(user): try: token = user.token except AttributeError: raise exceptions.NotAuthenticated() # Domain Admin, Project Admin will default to identity if token.project.get('id') is None or user.is_superuser: try: dashboard = horizon.get_dashboard('identity') except base.NotRegistered: pass else: dashboard = horizon.get_default_dashboard() return dashboard.get_absolute_url()
def get_user_home(user): try: token = user.token except AttributeError: raise exceptions.NotAuthenticated() # mj - we don't actually want this override # Domain Admin, Project Admin will default to identity #if token.project.get('id') is None or user.is_superuser: # try: # dashboard = horizon.get_dashboard('identity') # except base.NotRegistered: # pass #else: dashboard = horizon.get_default_dashboard() return dashboard.get_absolute_url()
def get_user_home(user): dashboard = None if user.is_superuser: try: dashboard = horizon.get_dashboard('admin') except base.NotRegistered: pass if dashboard is None: dashboard = horizon.get_default_dashboard() # Domain Admin, Project Admin will default to identity if (user.token.project.get('id') is None or (user.is_superuser and user.token.project.get('id'))): dashboard = horizon.get_dashboard('project') return dashboard.get_absolute_url()
def get_user_home(user): dashboard = None if user.is_superuser: try: dashboard = horizon.get_dashboard('virtual') except base.NotRegistered: pass if dashboard is None: dashboard = horizon.get_default_dashboard() # Domain Admin, Project Admin will default to identity if (user.token.project.get('id') is None or (user.is_superuser and user.token.project.get('id'))): dashboard = horizon.get_dashboard('virtual') return dashboard.get_absolute_url()
def ticket_download(request): v3, is_default_admin = api.keystone.is_default_domain_admin(request) if request.user.is_authenticated() and is_default_admin: tickets = _get_tickets(request) xls_data = [_filter_fields(ticket) for ticket in tickets] response = HttpResponse(mimetype='application/vnd.ms-excel') response['Content-Disposition'] = 'attachment;filename="{0}"'.format( 'tickets.xls') xls_writer = XLSWriter(response) xls_writer.add_sheet(xls_header, 'tickets') xls_writer.add_rows(xls_data, 'tickets') xls_writer.save() return response else: dashboard = horizon.get_default_dashboard() response = shortcuts.redirect(dashboard.get_absolute_url()) return response
def get_user_home(user): try: if user.is_superuser: return get_dashboard('admin').get_absolute_url() if user.has_perms(('openstack.roles.' + TENANTADMIN_ROLE,)): q_args = { 'project__projectname' : user.tenant_name, 'flowstatus__in' : [ PSTATUS_PENDING, PSTATUS_RENEW_MEMB ] } if PrjRequest.objects.filter(**q_args).count() > 0: idmanager_url = get_dashboard('idmanager').get_absolute_url() return idmanager_url + 'subscription_manager/' except NotRegistered: LOG.error("Cannot retrieve user home", exc_info=True) return get_default_dashboard().get_absolute_url()
def get_user_home(user): try: if user.is_superuser: return horizon.get_dashboard('admin').get_absolute_url() if user.has_perms(('openstack.roles.' + TENANTADMIN_ROLE,)): q_args = { 'project__projectname' : user.tenant_name, 'flowstatus__in' : [ PSTATUS_PENDING, PSTATUS_RENEW_MEMB ] } if PrjRequest.objects.filter(**q_args).count() > 0: idmanager_url = horizon.get_dashboard('idmanager').get_absolute_url() return idmanager_url + 'subscription_manager/' except horizon.base.NotRegistered: LOG.error("Cannot retrieve user home", exc_info=True) return horizon.get_default_dashboard().get_absolute_url()
def get_user_home(user): dashboard = horizon.get_default_dashboard() dc_mode = getattr(settings, 'DC_MODE', False) if user.is_superuser: if getattr(user, 'services_region', None) == 'SystemController': try: dashboard = horizon.get_dashboard('dc_admin') except base.NotRegistered: pass if getattr(user, 'services_region', None) == 'RegionOne' and dc_mode: try: if user.is_superuser: dashboard = horizon.get_dashboard('admin'). \ get_panel("inventory") else: dashboard = horizon.get_dashboard('project'). \ get_panel("api_access") except base.NotRegistered: pass return dashboard.get_absolute_url()
def get_user_home(user): try: token = user.token except AttributeError: raise exceptions.NotAuthenticated() # Domain Admin, Project Admin will default to identity dashboard = None if token.project.get('id') is None or user.is_superuser: try: dashboard = horizon.get_dashboard('admin') #dashboard = horizon.get_dashboard('identity') except base.NotRegistered: pass if dashboard is None: roles = [r['name'] for r in user.roles] if settings.EXPERTCONSTANT['expert_certified_role'] in roles: dashboard = horizon.get_default_dashboard() elif settings.EXPERTCONSTANT['expert_uncertified_role'] in roles: dashboard = horizon.get_dashboard('settings') else: dashboard = horizon.get_dashboard('admin') return dashboard.get_absolute_url()
def get_user_home(user): dashboard = horizon.get_default_dashboard() return dashboard.get_absolute_url()