Browse Source

HUE-3287 [core] Django 1.11 upgrade
- Adding code review suggestion changes from Romain and Johan

Prakash Ranade 7 years ago
parent
commit
31b63accd3

+ 0 - 2
Makefile

@@ -205,8 +205,6 @@ install-env:
 	$(MAKE) -C $(INSTALL_DIR)/desktop env-install
 	$(MAKE) -C $(INSTALL_DIR)/desktop env-install
 	@echo --- Setting up Applications
 	@echo --- Setting up Applications
 	$(MAKE) -C $(INSTALL_DIR)/apps env-install
 	$(MAKE) -C $(INSTALL_DIR)/apps env-install
-	#@echo --- Setting up Desktop database
-	#$(MAKE) -C $(INSTALL_DIR)/desktop syncdb
 
 
 ###################################
 ###################################
 # Internationalization
 # Internationalization

+ 0 - 1
apps/beeswax/src/beeswax/models.py

@@ -53,7 +53,6 @@ class QueryHistory(models.Model):
   """
   """
   Holds metadata about all queries that have been executed.
   Holds metadata about all queries that have been executed.
   """
   """
-  #STATE = Enum('submitted', 'running', 'available', 'failed', 'expired')
   class STATE(Enum):
   class STATE(Enum):
     submitted = 0
     submitted = 0
     running = 1
     running = 1

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

@@ -492,6 +492,7 @@ for x in sys.stdin:
 
 
 
 
   def test_parameterization(self):
   def test_parameterization(self):
+    #@TODO@ Prakash fix this test
     raise SkipTest
     raise SkipTest
     response = _make_query(self.client, "SELECT foo FROM test WHERE foo='$x' and bar='$y'", is_parameterized=False, database=self.db_name)
     response = _make_query(self.client, "SELECT foo FROM test WHERE foo='$x' and bar='$y'", is_parameterized=False, database=self.db_name)
     content = json.loads(response.content)
     content = json.loads(response.content)
@@ -691,6 +692,7 @@ for x in sys.stdin:
 
 
 
 
   def test_multiple_statements_with_params(self):
   def test_multiple_statements_with_params(self):
+    #@TODO@ Prakash fix this test
     raise SkipTest
     raise SkipTest
     hql = """
     hql = """
       select ${x} from test;
       select ${x} from test;
@@ -871,6 +873,7 @@ for x in sys.stdin:
 
 
 
 
   def test_designs(self):
   def test_designs(self):
+    #@TODO@ Prakash fix this test
     raise SkipTest
     raise SkipTest
     if is_live_cluster():
     if is_live_cluster():
       raise SkipTest('HUE-2902: Skipping because test is not reentrant')
       raise SkipTest('HUE-2902: Skipping because test is not reentrant')

+ 1 - 1
apps/filebrowser/src/filebrowser/templates/display.mako

@@ -369,7 +369,7 @@ ${ fb_components.menubar() }
     }
     }
 
 
     self.downloadFile = function () {
     self.downloadFile = function () {
-      location.href = "${url('filebrowser.views.download', path=path_enc)}";
+      location.href = "${url('filebrowser_views_download', path=path_enc)}";
     };
     };
 
 
     self.pageChanged = function () {
     self.pageChanged = function () {

+ 2 - 2
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -1340,11 +1340,11 @@ from filebrowser.conf import ENABLE_EXTRACT_UPLOADED_ARCHIVE
       };
       };
 
 
       self.editFile = function () {
       self.editFile = function () {
-        window.location.href = "${url('filebrowser.views.edit', path='')}" + encodeURI(self.selectedFile().path);
+        window.location.href = "${url('filebrowser_views_edit', path='')}" + encodeURI(self.selectedFile().path);
       };
       };
 
 
       self.downloadFile = function () {
       self.downloadFile = function () {
-        window.location.href = "${url('filebrowser.views.download', path='')}" + encodeURI(self.selectedFile().path);
+        window.location.href = "${url('filebrowser_views_download', path='')}" + encodeURI(self.selectedFile().path);
       };
       };
 
 
       self.renameFile = function () {
       self.renameFile = function () {

+ 1 - 1
apps/filebrowser/src/filebrowser/urls.py

@@ -30,7 +30,7 @@ urlpatterns = [
   url(r'^display=(?P<path>.*)$', filebrowser_views.display, name='display'),
   url(r'^display=(?P<path>.*)$', filebrowser_views.display, name='display'),
   url(r'^stat=(?P<path>.*)$', filebrowser_views.stat, name='stat'),
   url(r'^stat=(?P<path>.*)$', filebrowser_views.stat, name='stat'),
   url(r'^content_summary=(?P<path>.*)$', filebrowser_views.content_summary, name='content_summary'),
   url(r'^content_summary=(?P<path>.*)$', filebrowser_views.content_summary, name='content_summary'),
-  url(r'^download=(?P<path>.*)$', filebrowser_views.download, name='filebrowser.views.download'),
+  url(r'^download=(?P<path>.*)$', filebrowser_views.download, name='filebrowser_views_download'),
   url(r'^status$', filebrowser_views.status, name='status'),
   url(r'^status$', filebrowser_views.status, name='status'),
   url(r'^home_relative_view=(?P<path>.*)$', filebrowser_views.home_relative_view, name='home_relative_view'),
   url(r'^home_relative_view=(?P<path>.*)$', filebrowser_views.home_relative_view, name='home_relative_view'),
   url(r'^edit=(?P<path>.*)$', filebrowser_views.edit, name='filebrowser_views_edit'),
   url(r'^edit=(?P<path>.*)$', filebrowser_views.edit, name='filebrowser_views_edit'),

+ 1 - 1
apps/filebrowser/src/filebrowser/views.py

@@ -608,7 +608,7 @@ def display(request, path):
     # display inline files just if it's not an ajax request
     # display inline files just if it's not an ajax request
     if not request.is_ajax():
     if not request.is_ajax():
       if _can_inline_display(path):
       if _can_inline_display(path):
-        return redirect(reverse('filebrowser.views.download', args=[path]) + '?disposition=inline')
+        return redirect(reverse('filebrowser_views_download', args=[path]) + '?disposition=inline')
 
 
     stats = request.fs.stats(path)
     stats = request.fs.stats(path)
     encoding = request.GET.get('encoding') or i18n.get_site_encoding()
     encoding = request.GET.get('encoding') or i18n.get_site_encoding()

+ 1 - 0
apps/jobsub/src/jobsub/tests.py

@@ -147,6 +147,7 @@ class TestJobsubWithHadoop(OozieServerProvider):
     assert_equal(n_trashed, Document.objects.trashed_docs(Workflow, self.user).count())
     assert_equal(n_trashed, Document.objects.trashed_docs(Workflow, self.user).count())
 
 
   def test_clone_design(self):
   def test_clone_design(self):
+    #@TODO@ Prakash fix this test
     raise SkipTest
     raise SkipTest
     n_available = Document.objects.available_docs(Workflow, self.user).count()
     n_available = Document.objects.available_docs(Workflow, self.user).count()
 
 

+ 2 - 0
apps/oozie/src/oozie/tests.py

@@ -1575,6 +1575,7 @@ class TestEditor(OozieMockBase):
 
 
 
 
   def test_clone_coordinator(self):
   def test_clone_coordinator(self):
+    #@TODO@ Prakash fix this test
     raise SkipTest
     raise SkipTest
     coord = create_coordinator(self.wf, self.c, self.user)
     coord = create_coordinator(self.wf, self.c, self.user)
     coordinator_count = Document.objects.available_docs(Coordinator, self.user).count()
     coordinator_count = Document.objects.available_docs(Coordinator, self.user).count()
@@ -2066,6 +2067,7 @@ class TestEditorBundle(OozieMockBase):
 
 
 
 
   def test_clone_bundle(self):
   def test_clone_bundle(self):
+    #@TODO@ Prakash fix this test
     raise SkipTest
     raise SkipTest
     bundle = create_bundle(self.c, self.user)
     bundle = create_bundle(self.c, self.user)
     bundle_count = Document.objects.available_docs(Bundle, self.user).count()
     bundle_count = Document.objects.available_docs(Bundle, self.user).count()

+ 5 - 0
apps/useradmin/src/useradmin/metrics.py

@@ -14,15 +14,20 @@
 # See the License for the specific language governing permissions and
 # See the License for the specific language governing permissions and
 # limitations under the License.
 # limitations under the License.
 
 
+import logging
+
 from datetime import datetime, timedelta
 from datetime import datetime, timedelta
 
 
 from desktop.lib.metrics import global_registry
 from desktop.lib.metrics import global_registry
 
 
+LOG = logging.getLogger(__name__)
+
 def active_users():
 def active_users():
   from useradmin.models import UserProfile
   from useradmin.models import UserProfile
   try:
   try:
     count = UserProfile.objects.filter(last_activity__gt=datetime.now() - timedelta(hours=1)).count()
     count = UserProfile.objects.filter(last_activity__gt=datetime.now() - timedelta(hours=1)).count()
   except:
   except:
+    LOG.exception('Could not get active_users')
     count = 0
     count = 0
   return count
   return count
 
 

+ 0 - 1
apps/useradmin/src/useradmin/tests.py

@@ -526,7 +526,6 @@ class TestUserAdmin(BaseUserAdminTests):
 
 
 
 
   def test_user_admin(self):
   def test_user_admin(self):
-    #FUNNY_NAME = '~`!@#$%^&*()_-+={}[]|\;"<>?/,.'
     FUNNY_NAME = 'أحمد@cloudera.com'
     FUNNY_NAME = 'أحمد@cloudera.com'
     FUNNY_NAME_QUOTED = urllib.quote(FUNNY_NAME)
     FUNNY_NAME_QUOTED = urllib.quote(FUNNY_NAME)
 
 

+ 1 - 0
desktop/core/ext-py/Django-1.11/django/template/context.py

@@ -262,6 +262,7 @@ class RequestContext(Context):
         self._processors_index = len(self.dicts)
         self._processors_index = len(self.dicts)
 
 
         updates = dict()
         updates = dict()
+        #@TODO@ Prakash to Implement context processor
         for processor in get_standard_processors():
         for processor in get_standard_processors():
             updates.update(processor(request))
             updates.update(processor(request))
         self.update(updates)
         self.update(updates)

+ 0 - 2
desktop/core/src/desktop/lib/django_util_test.py

@@ -106,8 +106,6 @@ class TestDjangoUtil(object):
         return "foo"
         return "foo"
     assert_equal('"foo"', django_util.encode_json(Foo()))
     assert_equal('"foo"', django_util.encode_json(Foo()))
     assert_equal('["foo", "foo"]', django_util.encode_json([Foo(), Foo()]))
     assert_equal('["foo", "foo"]', django_util.encode_json([Foo(), Foo()]))
-    #assert_equal('{"pk": null, "model": "TEST_APP.testmodel", "fields": {"last_modified": null, "my_str": "foo", "my_int": 3}}',
-    #    django_util.encode_json(TestModel(my_int=3, my_str="foo")))
     assert_equal('{"model": "TEST_APP.testmodel", "pk": null, "fields": {"my_int": 3, "my_str": "foo", "last_modified": null}}',
     assert_equal('{"model": "TEST_APP.testmodel", "pk": null, "fields": {"my_int": 3, "my_str": "foo", "last_modified": null}}',
         django_util.encode_json(TestModel(my_int=3, my_str="foo")))
         django_util.encode_json(TestModel(my_int=3, my_str="foo")))
 
 

+ 1 - 0
desktop/core/src/desktop/settings.py

@@ -162,6 +162,7 @@ MIDDLEWARE_CLASSES = [
     'django.middleware.csrf.CsrfViewMiddleware',
     'django.middleware.csrf.CsrfViewMiddleware',
 
 
     'django.middleware.http.ConditionalGetMiddleware',
     'django.middleware.http.ConditionalGetMiddleware',
+    #@TODO@ Prakash to check FailedLoginMiddleware working or not?
     #'axes.middleware.FailedLoginMiddleware',
     #'axes.middleware.FailedLoginMiddleware',
     'desktop.middleware.MimeTypeJSFileFixStreamingMiddleware',
     'desktop.middleware.MimeTypeJSFileFixStreamingMiddleware',
 ]
 ]

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

@@ -48,7 +48,7 @@
       </li>
       </li>
       <!-- /ko -->
       <!-- /ko -->
       %if showMore:
       %if showMore:
-      <!-- ko if: page().number != paginator().num_pages -->
+      <!-- ko if: page().number != page().num_pages() -->
       <li>
       <li>
         <a href="javascript: void(0)" data-bind="click: ${showMore}" style="padding-left: 8px">
         <a href="javascript: void(0)" data-bind="click: ${showMore}" style="padding-left: 8px">
           <i class="fa fa-plus"></i> ${_('Show more...')}
           <i class="fa fa-plus"></i> ${_('Show more...')}

+ 6 - 6
desktop/libs/kafka/src/kafka/urls.py

@@ -15,10 +15,10 @@
 # See the License for the specific language governing permissions and
 # See the License for the specific language governing permissions and
 # limitations under the License.
 # limitations under the License.
 
 
-from django.conf.urls import patterns, url
+from django.conf.urls import url
+from kafka import kafka_api as kafka_kafka_api
 
 
-
-urlpatterns = patterns('kafka.kafka_api',
-  url(r'^api/topics/list/$', 'list_topics', name='list_topics'),
-  url(r'^api/topic/list/$', 'list_topic', name='list_topic'),
-)
+urlpatterns = [
+  url(r'^api/topics/list/$', kafka_kafka_api.list_topics, name='list_topics'),
+  url(r'^api/topic/list/$', kafka_kafka_api.list_topic, name='list_topic'),
+]

+ 4 - 3
desktop/libs/metadata/src/metadata/urls.py

@@ -19,6 +19,7 @@ from django.conf.urls import url
 from metadata import navigator_api as metadata_navigator_api
 from metadata import navigator_api as metadata_navigator_api
 from metadata import optimizer_api as metadata_optimizer_api
 from metadata import optimizer_api as metadata_optimizer_api
 from metadata import workload_analytics_api as metadata_workload_analytics_api
 from metadata import workload_analytics_api as metadata_workload_analytics_api
+from metadata import manager_api as metadata_manager_api
 
 
 # Navigator API
 # Navigator API
 urlpatterns = [
 urlpatterns = [
@@ -61,9 +62,9 @@ urlpatterns += [
 
 
 
 
 # Manager API
 # Manager API
-urlpatterns += patterns('metadata.manager_api',
-  url(r'^api/manager/hello/?$', 'hello', name='hello'),
-)
+urlpatterns += [
+  url(r'^api/manager/hello/?$', metadata_manager_api.hello, name='hello'),
+]
 
 
 # Workload Analytics API
 # Workload Analytics API
 urlpatterns += [
 urlpatterns += [

+ 0 - 2
tools/jenkins/jenkins.sh

@@ -18,8 +18,6 @@
 set -e
 set -e
 set -x
 set -x
 
 
-sudo yum install -y cyrus-sasl-devel cyrus-sasl cyrus-sasl-plain cyrus-sasl-lib
-
 # CDH3b3 requires tight umask setting.
 # CDH3b3 requires tight umask setting.
 umask 0022
 umask 0022
 
 

+ 6 - 6
tools/virtual-bootstrap/virtual-bootstrap.py

@@ -134,10 +134,10 @@ elif majver == 3:
     # Some extra modules are needed for Python 3, but different ones
     # Some extra modules are needed for Python 3, but different ones
     # for different versions.
     # for different versions.
     REQUIRED_MODULES.extend([
     REQUIRED_MODULES.extend([
-    	'_abcoll', 'warnings', 'linecache', 'abc', 'io', '_weakrefset',
-    	'copyreg', 'tempfile', 'random', '__future__', 'collections',
-    	'keyword', 'tarfile', 'shutil', 'struct', 'copy', 'tokenize',
-    	'token', 'functools', 'heapq', 'bisect', 'weakref', 'reprlib'
+        '_abcoll', 'warnings', 'linecache', 'abc', 'io', '_weakrefset',
+        'copyreg', 'tempfile', 'random', '__future__', 'collections',
+        'keyword', 'tarfile', 'shutil', 'struct', 'copy', 'tokenize',
+        'token', 'functools', 'heapq', 'bisect', 'weakref', 'reprlib'
     ])
     ])
     if minver >= 2:
     if minver >= 2:
         REQUIRED_FILES[-1] = 'config-%s' % majver
         REQUIRED_FILES[-1] = 'config-%s' % majver
@@ -146,8 +146,8 @@ elif majver == 3:
         platdir = sysconfig.get_config_var('PLATDIR')
         platdir = sysconfig.get_config_var('PLATDIR')
         REQUIRED_FILES.append(platdir)
         REQUIRED_FILES.append(platdir)
         REQUIRED_MODULES.extend([
         REQUIRED_MODULES.extend([
-        	'base64', '_dummy_thread', 'hashlib', 'hmac',
-        	'imp', 'importlib', 'rlcompleter'
+            'base64', '_dummy_thread', 'hashlib', 'hmac',
+            'imp', 'importlib', 'rlcompleter'
         ])
         ])
     if minver >= 4:
     if minver >= 4:
         REQUIRED_MODULES.extend([
         REQUIRED_MODULES.extend([