Exemple #1
0
def home2(request):
  apps = appmanager.get_apps_dict(request.user)

  return render('home2.mako', request, {
    'apps': apps,
    'tours_and_tutorials': Settings.get_settings().tours_and_tutorials
  })
Exemple #2
0
def hue(request):
    apps = appmanager.get_apps_dict(request.user)

    return render(
        'hue.mako', request, {
            'apps':
            apps,
            'tours_and_tutorials':
            Settings.get_settings().tours_and_tutorials,
            'interpreters':
            get_ordered_interpreters(request.user),
            'is_s3_enabled':
            is_s3_enabled() and has_s3_access(request.user),
            'is_ldap_setup':
            'desktop.auth.backend.LdapBackend'
            in desktop.conf.AUTH.BACKEND.get(),
            'leaflet': {
                'layer': desktop.conf.LEAFLET_TILE_LAYER.get(),
                'attribution':
                desktop.conf.LEAFLET_TILE_LAYER_ATTRIBUTION.get()
            },
            'is_demo':
            desktop.conf.DEMO_ENABLED.get(),
            'banner_message':
            get_banner_message(request),
            'cluster_config':
            ClusterConfig(request.user)
        })
Exemple #3
0
def ko_metastore(request):
  apps = appmanager.get_apps_dict(request.user)

  return render('ko_metastore.mako', request, {
    'apps': apps,
    'tours_and_tutorials': Settings.get_settings().tours_and_tutorials
  })
Exemple #4
0
def admin_wizard(request):
  apps = appmanager.get_apps(request.user)
  app_names = [app.name for app in sorted(apps, key=lambda app: app.menu_index)]

  collect_usage = Settings.get_settings().collect_usage
  tours_and_tutorials = Settings.get_settings().tours_and_tutorials

  return render('admin_wizard.mako', request, {
      'version': settings.HUE_DESKTOP_VERSION,
      'check_config': check_config(request).content,
      'apps': dict([(app.name, app) for app in apps]),
      'app_names': app_names,
      'collect_usage': collect_usage,
      'tours_and_tutorials': tours_and_tutorials,
      'trash_enabled': get_trash_interval()
  })
Exemple #5
0
    def test_collect_usage(self):
        tours_and_tutorials = Settings.get_settings().tours_and_tutorials

        try:
            response = self.client.post(reverse("about:update_preferences"), {"tours_and_tutorials": False})
            data = json.loads(response.content)
            assert_equal(data["status"], 0)
            assert_false(data["tours_and_tutorials"] == True)  # Weird but works

            response = self.client.post(reverse("about:update_preferences"), {"tours_and_tutorials": True})
            data = json.loads(response.content)
            assert_equal(data["status"], 0)
            assert_true(data["tours_and_tutorials"])
        finally:
            settings = Settings.get_settings()
            settings.tours_and_tutorials = tours_and_tutorials
            settings.save()
Exemple #6
0
def home2(request, is_embeddable=False):
  apps = appmanager.get_apps_dict(request.user)

  return render('home2.mako', request, {
    'apps': apps,
    'tours_and_tutorials': Settings.get_settings().tours_and_tutorials,
    'is_embeddable': request.GET.get('is_embeddable', False)
  })
Exemple #7
0
  def test_collect_usage(self):
    collect_usage = Settings.get_settings().collect_usage

    try:
      response = self.client.post(reverse('about:update_preferences'), {'collect_usage': False})
      data = json.loads(response.content)
      assert_equal(data['status'], 0)
      assert_false(data['collect_usage'] == True) # Weird but works

      response = self.client.post(reverse('about:update_preferences'), {'collect_usage': True})
      data = json.loads(response.content)
      assert_equal(data['status'], 0)
      assert_true(data['collect_usage'])
    finally:
      settings = Settings.get_settings()
      settings.collect_usage = collect_usage
      settings.save()
Exemple #8
0
def home2(request):
  _convert_documents(request.user)

  apps = appmanager.get_apps_dict(request.user)

  return render('home2.mako', request, {
    'apps': apps,
    'tours_and_tutorials': Settings.get_settings().tours_and_tutorials
  })
Exemple #9
0
    def test_collect_usage(self):
        collect_usage = Settings.get_settings().collect_usage

        try:
            response = self.client_admin.post(
                reverse('about:update_preferences'), {'collect_usage': False})
            data = json.loads(response.content)
            assert_equal(data['status'], 0)
            assert_false(data['collect_usage'])

            response = self.client_admin.post(
                reverse('about:update_preferences'), {'collect_usage': True})
            data = json.loads(response.content)
            assert_equal(data['status'], 0)
            assert_true(data['collect_usage'])
        finally:
            settings = Settings.get_settings()
            settings.collect_usage = collect_usage
            settings.save()
Exemple #10
0
def responsive(request):
  apps = appmanager.get_apps_dict(request.user)

  return render('responsive.mako', request, {
    'apps': apps,
    'tours_and_tutorials': Settings.get_settings().tours_and_tutorials,
    'interpreters': get_ordered_interpreters(request.user),
    'is_s3_enabled': is_s3_enabled() and has_s3_access(request.user),
    'is_ldap_setup': 'desktop.auth.backend.LdapBackend' in desktop.conf.AUTH.BACKEND.get()
  })
Exemple #11
0
def home2(request):
  docs = Document2.objects.filter(owner=request.user)

  apps = appmanager.get_apps_dict(request.user)

  return render('home2.mako', request, {
    'apps': apps,
    'json_documents': json.dumps([doc.to_dict() for doc in docs]),
    'tours_and_tutorials': Settings.get_settings().tours_and_tutorials
  })
Exemple #12
0
def responsive(request):
    apps = appmanager.get_apps_dict(request.user)

    return render(
        'responsive.mako', request, {
            'apps': apps,
            'tours_and_tutorials': Settings.get_settings().tours_and_tutorials,
            'interpreters': get_interpreters(request.user),
            'is_s3_enabled': is_s3_enabled() and has_s3_access(request.user)
        })
Exemple #13
0
    def test_collect_usage(self):
        collect_usage = Settings.get_settings().collect_usage

        try:
            response = self.client.post(reverse('about:collect_usage'),
                                        {'collect_usage': False})
            data = json.loads(response.content)
            assert_equal(data['status'], 0)
            assert_false(data['collect_usage'] == True)  # Weird but works

            response = self.client.post(reverse('about:collect_usage'),
                                        {'collect_usage': True})
            data = json.loads(response.content)
            assert_equal(data['status'], 0)
            assert_true(data['collect_usage'])
        finally:
            settings = Settings.get_settings()
            settings.collect_usage = collect_usage
            settings.save()
Exemple #14
0
def test_collect_usage():
    client = make_logged_in_client(username="******", is_superuser=False)
    grant_access("about", "about", "about")

    collect_usage = Settings.get_settings().collect_usage

    try:
        response = client.post(reverse("about:collect_usage"), {"collect_usage": False})
        data = json.loads(response.content)
        assert_equal(data["status"], 0)
        assert_false(data["collect_usage"] == True)  # Weird but works

        response = client.post(reverse("about:collect_usage"), {"collect_usage": True})
        data = json.loads(response.content)
        assert_equal(data["status"], 0)
        assert_true(data["collect_usage"])
    finally:
        settings = Settings.get_settings()
        settings.collect_usage = collect_usage
        settings.save()
Exemple #15
0
    def test_collect_usage(self):
        tours_and_tutorials = Settings.get_settings().tours_and_tutorials

        try:
            response = self.client.post(reverse('about:update_preferences'),
                                        {'tours_and_tutorials': False})
            data = json.loads(response.content)
            assert_equal(data['status'], 0)
            assert_false(
                data['tours_and_tutorials'] == True)  # Weird but works

            response = self.client.post(reverse('about:update_preferences'),
                                        {'tours_and_tutorials': True})
            data = json.loads(response.content)
            assert_equal(data['status'], 0)
            assert_true(data['tours_and_tutorials'])
        finally:
            settings = Settings.get_settings()
            settings.tours_and_tutorials = tours_and_tutorials
            settings.save()
Exemple #16
0
def home(request):
  docs = _get_docs(request.user)

  apps = appmanager.get_apps_dict(request.user)

  return render('home.mako', request, {
    'apps': apps,
    'json_documents': json.dumps(massaged_documents_for_json(docs, request.user)),
    'json_tags': json.dumps(massaged_tags_for_json(docs, request.user)),
    'tours_and_tutorials': Settings.get_settings().tours_and_tutorials
  })
Exemple #17
0
def test_collect_usage():
  client = make_logged_in_client(username="******", is_superuser=False)
  grant_access("about", "about", "about")

  collect_usage = Settings.get_settings().collect_usage

  try:
    response = client.post(reverse('about:collect_usage'), {'collect_usage': False})
    data = json.loads(response.content)
    assert_equal(data['status'], 0)
    assert_false(data['collect_usage'] == True) # Weird but works

    response = client.post(reverse('about:collect_usage'), {'collect_usage': True})
    data = json.loads(response.content)
    assert_equal(data['status'], 0)
    assert_true(data['collect_usage'])
  finally:
    settings = Settings.get_settings()
    settings.collect_usage = collect_usage
    settings.save()
Exemple #18
0
def home(request):
  docs = _get_docs(request.user)

  apps = appmanager.get_apps_dict(request.user)

  return render('home.mako', request, {
    'apps': apps,
    'json_documents': json.dumps(massaged_documents_for_json(docs, request.user)),
    'json_tags': json.dumps(massaged_tags_for_json(docs, request.user)),
    'tours_and_tutorials': Settings.get_settings().tours_and_tutorials
  })
Exemple #19
0
def admin_wizard(request):
  apps = appmanager.get_apps(request.user)
  app_names = [app.name for app in sorted(apps, key=lambda app: app.menu_index)]

  tours_and_tutorials = Settings.get_settings().tours_and_tutorials

  return render('admin_wizard.mako', request, {
      'version': settings.HUE_DESKTOP_VERSION,
      'apps': dict([(app.name, app) for app in apps]),
      'app_names': app_names,
      'tours_and_tutorials': tours_and_tutorials,
  })
Exemple #20
0
def collect_usage(request):
  response = {'status': -1, 'data': ''}

  if request.method == 'POST':
    try:
      settings = Settings.get_settings()
      settings.collect_usage = request.POST.get('collect_usage', False)
      settings.save()
      response['status'] = 0
      response['collect_usage'] = settings.collect_usage
    except Exception, e:
      response['data'] = str(e)
Exemple #21
0
def update_preferences(request):
  response = {'status': -1, 'data': ''}

  if request.method == 'POST':
    try:
      settings = Settings.get_settings()
      settings.tours_and_tutorials = request.POST.get('tours_and_tutorials', False)
      settings.save()
      response['status'] = 0
      response['tours_and_tutorials'] = settings.tours_and_tutorials
    except Exception, e:
      response['data'] = str(e)
Exemple #22
0
def admin_wizard(request):
  apps = appmanager.get_apps(request.user)
  app_names = [app.name for app in sorted(apps, key=lambda app: app.menu_index)]

  collect_usage = Settings.get_settings().collect_usage

  return render('admin_wizard.mako', request, {
      'version': settings.HUE_DESKTOP_VERSION,
      'check_config': check_config(request),
      'apps': dict([(app.name, app) for app in apps]),
      'app_names': app_names,
      'collect_usage': collect_usage,
  })
Exemple #23
0
def update_preferences(request):
    response = {'status': -1, 'data': ''}

    if request.method == 'POST':
        try:
            settings = Settings.get_settings()
            settings.tours_and_tutorials = request.POST.get(
                'tours_and_tutorials', False)
            settings.save()
            response['status'] = 0
            response['tours_and_tutorials'] = settings.tours_and_tutorials
        except Exception, e:
            response['data'] = str(e)
Exemple #24
0
def commonfooter(messages=None):
  """
  Returns the rendered common footer
  """
  if messages is None:
    messages = {}

  hue_settings = Settings.get_settings()

  return render_to_string("common_footer.html", {
    'messages': messages,
    'version': settings.HUE_DESKTOP_VERSION,
    'collect_usage': hue_settings.collect_usage
  })
Exemple #25
0
def admin_wizard(request):
    apps = appmanager.get_apps(request.user)
    app_names = [
        app.name for app in sorted(apps, key=lambda app: app.menu_index)
    ]

    tours_and_tutorials = Settings.get_settings().tours_and_tutorials

    return render(
        'admin_wizard.mako', request, {
            'version': settings.HUE_DESKTOP_VERSION,
            'apps': dict([(app.name, app) for app in apps]),
            'app_names': app_names,
            'tours_and_tutorials': tours_and_tutorials,
        })
Exemple #26
0
def commonfooter(messages=None):
    """
  Returns the rendered common footer
  """
    if messages is None:
        messages = {}

    hue_settings = Settings.get_settings()

    return render_to_string(
        "common_footer.html", {
            'messages': messages,
            'version': settings.HUE_DESKTOP_VERSION,
            'collect_usage': hue_settings.collect_usage
        })
Exemple #27
0
def commonfooter(messages=None):
  """
  Returns the rendered common footer
  """
  if messages is None:
    messages = {}

  hue_settings = Settings.get_settings()

  return django_mako.render_to_string("common_footer.mako", {
    'messages': messages,
    'version': settings.HUE_DESKTOP_VERSION,
    'collect_usage': desktop.conf.COLLECT_USAGE.get(),
    'tours_and_tutorials': hue_settings.tours_and_tutorials
  })
Exemple #28
0
def commonfooter(messages=None):
  """
  Returns the rendered common footer
  """
  if messages is None:
    messages = {}

  hue_settings = Settings.get_settings()

  return django_mako.render_to_string("common_footer.mako", {
    'messages': messages,
    'version': settings.HUE_DESKTOP_VERSION,
    'collect_usage': collect_usage(),
    'tours_and_tutorials': hue_settings.tours_and_tutorials
  })
Exemple #29
0
def home(request):
    docs = _get_docs(request.user)

    apps = appmanager.get_apps_dict(request.user)

    return render(
        "home.mako",
        request,
        {
            "apps": apps,
            "json_documents": json.dumps(massaged_documents_for_json(docs, request.user)),
            "json_tags": json.dumps(massaged_tags_for_json(docs, request.user)),
            "tours_and_tutorials": Settings.get_settings().tours_and_tutorials,
        },
    )
Exemple #30
0
def commonfooter(request, messages=None):
  """
  Returns the rendered common footer
  """
  if messages is None:
    messages = {}

  hue_settings = Settings.get_settings()

  return django_mako.render_to_string("common_footer.mako", {
    'request': request,
    'messages': messages,
    'version': hue_version(),
    'collect_usage': collect_usage(),
    'tours_and_tutorials': hue_settings.tours_and_tutorials
  })
Exemple #31
0
def update_preferences(request):
    response = {'status': -1, 'data': ''}

    if request.method == 'POST':
        try:
            settings = Settings.get_settings()
            settings.collect_usage = request.POST.get('collect_usage', False)
            settings.save()
            response['status'] = 0
            response['collect_usage'] = settings.collect_usage
        except Exception as e:
            response['data'] = str(e)
    else:
        response['data'] = _('POST request required.')

    return JsonResponse(response)
Exemple #32
0
def admin_wizard(request):
  if request.user.is_superuser:
    apps = appmanager.get_apps(request.user)
  else:
    apps = []
  app_names = [app.name for app in sorted(apps, key=lambda app: app.menu_index)]

  tours_and_tutorials = Settings.get_settings().tours_and_tutorials

  return render('admin_wizard.mako', request, {
      'version': hue_version(),
      'apps': dict([(app.name, app) for app in apps]),
      'app_names': app_names,
      'tours_and_tutorials': tours_and_tutorials,
      'collect_usage': collect_usage(),
  })
Exemple #33
0
def commonfooter(request, messages=None):
  """
  Returns the rendered common footer
  """
  if messages is None:
    messages = {}

  hue_settings = Settings.get_settings()

  return django_mako.render_to_string("common_footer.mako", {
    'request': request,
    'messages': messages,
    'version': hue_version(),
    'collect_usage': collect_usage(),
    'tours_and_tutorials': hue_settings.tours_and_tutorials
  })
Exemple #34
0
def commonfooter(messages=None):
    """
  Returns the rendered common footer
  """
    if messages is None:
        messages = {}

    hue_settings = Settings.get_settings()

    return django_mako.render_to_string(
        "common_footer.mako",
        {
            "messages": messages,
            "version": settings.HUE_DESKTOP_VERSION,
            "collect_usage": collect_usage(),
            "tours_and_tutorials": hue_settings.tours_and_tutorials,
        },
    )
Exemple #35
0
def commonfooter(request, messages=None, is_mobile=False):
  """
  Returns the rendered common footer
  """
  if messages is None:
    messages = {}

  hue_settings = Settings.get_settings()

  template = 'common_footer.mako'
  if is_mobile:
    template = 'common_footer_m.mako'

  return django_mako.render_to_string(template, {
    'request': request,
    'messages': messages,
    'version': hue_version(),
    'collect_usage': collect_usage(),
  })
Exemple #36
0
def commonfooter(request, messages=None, is_mobile=False):
  """
  Returns the rendered common footer
  """
  if messages is None:
    messages = {}

  hue_settings = Settings.get_settings()

  template = 'common_footer.mako'
  if is_mobile:
    template = 'common_footer_m.mako'

  return django_mako.render_to_string(template, {
    'request': request,
    'messages': messages,
    'version': hue_version(),
    'collect_usage': collect_usage(),
    'tours_and_tutorials': hue_settings.tours_and_tutorials
  })
Exemple #37
0
def collect_usage():
    return desktop.conf.COLLECT_USAGE.get() and Settings.get_settings(
    ).collect_usage
Exemple #38
0
def collect_usage():
    return desktop.conf.COLLECT_USAGE.get() and Settings.get_settings().collect_usage
Exemple #39
0
    'tours_and_tutorials': Settings.get_settings().tours_and_tutorials
  })


def home2(request, is_embeddable=False):
  try:
    converter = DocumentConverter(request.user)
    converter.convert()
  except Exception, e:
    LOG.warning("Failed to convert and import documents: %s" % e)

  apps = appmanager.get_apps_dict(request.user)

  return render('home2.mako', request, {
    'apps': apps,
    'tours_and_tutorials': Settings.get_settings().tours_and_tutorials,
    'is_embeddable': request.GET.get('is_embeddable', False)
  })

def home_embeddable(request):
  return home2(request, True)

def not_found(request):
  return render('404.mako', request, {
    'is_embeddable': request.GET.get('is_embeddable', False)
  })

def server_error(request):
  return render('500.mako', request, {
    'is_embeddable': request.GET.get('is_embeddable', False)
  })
Exemple #40
0
    'tours_and_tutorials': Settings.get_settings().tours_and_tutorials
  })


def home2(request):
  try:
    converter = DocumentConverter(request.user)
    converter.convert()
  except Exception, e:
    LOG.warning("Failed to convert and import documents: %s" % e)

  apps = appmanager.get_apps_dict(request.user)

  return render('home2.mako', request, {
    'apps': apps,
    'tours_and_tutorials': Settings.get_settings().tours_and_tutorials
  })


@access_log_level(logging.WARN)
def log_view(request):
  """
  We have a log handler that retains the last X characters of log messages.
  If it is attached to the root logger, this view will display that history,
  otherwise it will report that it can't be found.
  """
  if not request.user.is_superuser:
    return HttpResponse(_("You must be a superuser."))

  hostname = socket.gethostname()
  l = logging.getLogger()