Explorar o código

HUE-3293 [core] Move new editor flag to desktop

Romain Rigaux %!s(int64=9) %!d(string=hai) anos
pai
achega
c0f63a7

+ 0 - 7
apps/beeswax/src/beeswax/conf.py

@@ -124,13 +124,6 @@ THRIFT_VERSION = Config(
   default=7
 )
 
-USE_NEW_EDITOR = Config( # To remove in Hue 4
-  key='use_new_editor',
-  default=True,
-  type=coerce_bool,
-  help=_t('Choose whether to show the new SQL editor.')
-)
-
 CONFIG_WHITELIST = Config(
   key='config_whitelist',
   default='hive.map.aggr,hive.exec.compress.output,hive.exec.parallel,hive.execution.engine,mapreduce.job.queuename',

+ 2 - 1
apps/beeswax/src/beeswax/management/commands/beeswax_install_examples.py

@@ -25,6 +25,7 @@ from django.contrib.auth.models import User
 from django.utils.translation import ugettext as _
 
 from desktop.lib.exceptions_renderable import PopupException
+from desktop.conf import USE_NEW_EDITOR
 from desktop.models import Directory, Document, Document2, Document2Permission, import_saved_beeswax_query
 from hadoop import cluster
 from useradmin.models import get_default_user_group, install_sample_user
@@ -305,7 +306,7 @@ class SampleQuery(object):
       query.save()
       LOG.info('Successfully installed sample design: %s' % (self.name,))
 
-    if beeswax.conf.USE_NEW_EDITOR.get():
+    if USE_NEW_EDITOR.get():
       try:
         # Don't overwrite
         doc2 = Document2.objects.get(owner=django_user, name=self.name, type=self._document_type(self.type))

+ 3 - 2
apps/beeswax/src/beeswax/tests.py

@@ -44,7 +44,8 @@ from desktop.conf import \
     AUTH_PASSWORD as DEFAULT_AUTH_PASSWORD, \
     AUTH_PASSWORD_SCRIPT as DEFAULT_AUTH_PASSWORD_SCRIPT, \
     LDAP_USERNAME, \
-    LDAP_PASSWORD
+    LDAP_PASSWORD, \
+    USE_NEW_EDITOR
 from desktop import redaction
 from desktop.redaction import logfilter
 from desktop.redaction.engine import RedactionPolicy, RedactionRule
@@ -1219,7 +1220,7 @@ for x in sys.stdin:
     assert_true(data['rows'], data)
     resp = self.client.get(reverse('beeswax:get_sample_data', kwargs={'database': 'default', 'table': 'customers'}))
 
-    if conf.USE_NEW_EDITOR.get():
+    if USE_NEW_EDITOR.get():
       # New queries exist
       resp = self.client.get('/desktop/api2/docs/')
       data = json.loads(resp.content)

+ 1 - 2
apps/metastore/src/metastore/templates/metastore.mako

@@ -18,10 +18,9 @@ from django.utils.html import escape
 from django.utils.translation import ugettext as _
 
 from desktop import conf
+from desktop.conf import USE_NEW_EDITOR
 from desktop.lib.i18n import smart_unicode
 from desktop.views import commonheader, commonfooter, _ko
-
-from beeswax.conf import USE_NEW_EDITOR
 %>
 
 <%namespace name="actionbar" file="actionbar.mako" />

+ 2 - 1
desktop/core/src/desktop/api_tests.py

@@ -22,11 +22,12 @@ from nose.tools import assert_true, assert_false, assert_equal, assert_not_equal
 
 from django.contrib.auth.models import User
 
-from beeswax.conf import USE_NEW_EDITOR
 from desktop.api import massaged_documents_for_json, _get_docs
+from desktop.conf import USE_NEW_EDITOR
 from desktop.lib.django_test_util import make_logged_in_client
 from desktop.lib.test_utils import grant_access
 from desktop.models import DocumentTag , Document
+
 from pig.models import PigScript
 from useradmin.models import get_default_user_group
 

+ 7 - 0
desktop/core/src/desktop/conf.py

@@ -1077,6 +1077,13 @@ DJANGO_EMAIL_BACKEND = Config(
   default="django.core.mail.backends.smtp.EmailBackend"
 )
 
+USE_NEW_EDITOR = Config( # To remove in Hue 4
+  key='use_new_editor',
+  default=True,
+  type=coerce_bool,
+  help=_('Choose whether to show the new SQL editor.')
+)
+
 def validate_ldap(user, config):
   res = []
 

+ 1 - 1
desktop/core/src/desktop/templates/assist.mako

@@ -1070,7 +1070,7 @@ from desktop.views import _ko
             visible: params.visibleAssistPanels && params.visibleAssistPanels.indexOf('hdfs') !== -1
           }));
           <%
-            from beeswax.conf import USE_NEW_EDITOR
+            from desktop.conf import USE_NEW_EDITOR
           %>
           % if USE_NEW_EDITOR.get():
           self.availablePanels.push(new AssistInnerPanel({

+ 5 - 8
desktop/core/src/desktop/templates/common_header.mako

@@ -20,12 +20,9 @@ from desktop.lib.i18n import smart_unicode
 from django.utils.translation import ugettext as _
 
 home_url = url('desktop.views.home')
-try:
-  from beeswax.conf import USE_NEW_EDITOR
-  if USE_NEW_EDITOR.get():
-    home_url = url('desktop.views.home2')
-except:
-  pass
+from desktop.conf import USE_NEW_EDITOR
+if USE_NEW_EDITOR.get():
+  home_url = url('desktop.views.home2')
 %>
 
 <%def name="is_selected(selected)">
@@ -431,7 +428,7 @@ except:
          <ul role="menu" class="dropdown-menu">
            % if 'beeswax' in apps:
              <%
-               from beeswax.conf import USE_NEW_EDITOR
+               from desktop.conf import USE_NEW_EDITOR
              %>
              % if USE_NEW_EDITOR.get():
              <li><a href="${ url('notebook:editor') }?type=hive"><img src="${ static(apps['beeswax'].icon_path) }" class="app-icon"/> ${_('Hive')}</a></li>
@@ -470,7 +467,7 @@ except:
        % endif
        % if 'beeswax' in apps:
         <%
-          from beeswax.conf import USE_NEW_EDITOR
+          from desktop.conf import USE_NEW_EDITOR
         %>
         % if USE_NEW_EDITOR.get():
          <% from desktop.models import Document2, Document %>

+ 2 - 6
desktop/core/src/desktop/templates/home.mako

@@ -17,12 +17,8 @@
   from desktop.views import commonheader, commonfooter, commonshare, _ko
   from django.utils.translation import ugettext as _
 
-  use_new_home = False
-  try:
-    from beeswax.conf import USE_NEW_EDITOR
-    use_new_home = USE_NEW_EDITOR.get()
-  except:
-    pass
+  from desktop.conf import USE_NEW_EDITOR
+  use_new_home = USE_NEW_EDITOR.get()
 %>
 
 ${ commonheader(_('Welcome Home'), "home", user) | n,unicode }

+ 2 - 9
desktop/core/src/desktop/urls.py

@@ -38,7 +38,7 @@ from django.conf.urls.static import static
 from django.contrib import admin
 
 from desktop import appmanager
-from desktop.conf import METRICS
+from desktop.conf import METRICS, USE_NEW_EDITOR
 
 # Django expects handler404 and handler500 to be defined.
 # django.conf.urls provides them. But we want to override them.
@@ -60,14 +60,7 @@ dynamic_patterns = patterns('desktop.auth.views',
 )
 
 
-use_new_home = False
-try:
-  from beeswax.conf import USE_NEW_EDITOR
-  use_new_home = USE_NEW_EDITOR.get()
-except:
-  logging.debug('Beeswax is disabled, using old home')
-
-if use_new_home:
+if USE_NEW_EDITOR.get():
   dynamic_patterns += patterns('desktop.views',
     (r'^home$','home2'),
     (r'^home2$','home')