Esempio n. 1
0
def admin_wizard(request):
  if is_hue_admin(request.user):
    apps = appmanager.get_apps(request.user)
  else:
    apps = []
  app_names = [app.name for app in sorted(apps, key=lambda app: app.menu_index)]

  return render('admin_wizard.mako', request, {
      'version': hue_version(),
      'apps': dict([(app.name, app) for app in apps]),
      'app_names': app_names,
      'is_embeddable': request.GET.get('is_embeddable', False),
      'collect_usage': collect_usage(),
  })
Esempio n. 2
0
def _get_installed_connectors(category=None,
                              categories=None,
                              dialect=None,
                              interface=None,
                              user=None):
    from desktop.auth.backend import is_admin, is_hue_admin

    if not Connector.objects.exists() and user and is_hue_admin(user):
        _create_connector_examples()

    connectors_objects = Connector.objects.all()
    if user is not None and not is_admin(user):  # Apply Permissions
        connectors_objects = connectors_objects.filter(
            huepermission__in=user.get_permissions())

    connector_instances = [{
        'id': connector.id,
        'nice_name': connector.name,
        'description': connector.description,
        'dialect': connector.dialect,
        'interface': None,
        'settings': json.loads(connector.settings),
        'is_demo': False,
    } for connector in connectors_objects]
    connectors = []

    for connector in connector_instances:
        full_connector = _augment_connector_properties(connector)
        if full_connector:
            connectors.append(full_connector)
        else:
            LOG.warn(
                'Skipping connector %(id)s as connector dialect %(dialect)s or interface %(interface)s are not installed'
                % ({
                    'id': connector['id'],
                    'dialect': connector['dialect'],
                    'interface': connector['interface']
                }))

    if categories is not None:
        connectors = [
            connector for connector in connectors
            if connector['category'] in categories
        ]
    if category is not None:
        connectors = [
            connector for connector in connectors
            if connector['category'] == category
        ]
    if dialect is not None:
        connectors = [
            connector for connector in connectors
            if connector['dialect'] == dialect
        ]
    if interface is not None:
        connectors = [
            connector for connector in connectors
            if connector['interface'] == interface
        ]

    return connectors
Esempio n. 3
0
    def wrapper(request, *args, **kwargs):
        if not is_hue_admin(request.user):
            raise PopupException(_("You must be a Hue admin."), error_code=401)

        return f(request, *args, **kwargs)