فهرست منبع

[search] Remove deprecated chart attributes in the views

Romain Rigaux 10 سال پیش
والد
کامیت
e37f52380c
3فایلهای تغییر یافته به همراه17 افزوده شده و 92 حذف شده
  1. 13 88
      apps/search/src/search/models.py
  2. 3 3
      apps/search/src/search/static/search/js/search.ko.js
  3. 1 1
      apps/search/src/search/views.py

+ 13 - 88
apps/search/src/search/models.py

@@ -283,32 +283,7 @@ class Collection(models.Model):
       props['collection']['enabled'] = True
     if 'leafletmap' not in props['collection']['template']:
       props['collection']['template']['leafletmap'] = {'latitudeField': None, 'longitudeField': None, 'labelField': None}
-    if 'showGrid' not in props['collection']['template']:
-      props['collection']['template']['showGrid'] = True
-    if 'showChart' not in props['collection']['template']:
-      props['collection']['template']['showChart'] = False
-    if 'chartSettings' not in props['collection']['template']:
-      props['collection']['template']['chartSettings'] = {}
-    if 'chartType' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartType'] = 'bars'
-    if 'chartSorting' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartSorting'] = 'none'
-    if 'chartScatterGroup' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartScatterGroup'] = None
-    if 'chartScatterSize' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartScatterSize'] = None
-    if 'chartScope' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartScope'] = 'world'
-    if 'chartX' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartX'] = None
-    if 'chartYSingle' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartYSingle'] = None
-    if 'chartYMulti' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartYMulti'] = []
-    if 'chartData' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartData'] = []
-    if 'chartMapLabel' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartMapLabel'] = None
+
     for facet in props['collection']['facets']:
       properties = facet['properties']
       if 'gap' in properties and not 'initial_gap' in properties:
@@ -356,20 +331,6 @@ class Collection(models.Model):
       </div>""" % ' '.join(['{{%s}}' % field['name'] for field in fields]),
       "isGridLayout": True,
       "showFieldList": True,
-      "showGrid": True,
-      "showChart": False,
-      "chartSettings": {
-        'chartType': 'bars',
-        'chartSorting': 'none',
-        'chartScatterGroup': None,
-        'chartScatterSize': None,
-        'chartScope': 'world',
-        'chartX': None,
-        'chartYSingle': None,
-        'chartYMulti': [],
-        'chartData': [],
-        'chartMapLabel': None,
-      },
       "fieldsAttributes": [self._make_gridlayout_header_field(field) for field in fields],
       "fieldsSelected": [],
       "leafletmap": {'latitudeField': None, 'longitudeField': None, 'labelField': None},
@@ -395,7 +356,6 @@ class Collection(models.Model):
 
   @classmethod
   def _make_gridlayout_header_field(cls, field, isDynamic=False):
-    print field
     return {'name': field['name'], 'sort': {'direction': None}, 'isDynamic': isDynamic}
 
   def get_absolute_url(self):
@@ -422,32 +382,6 @@ class Collection(models.Model):
     if 'collection' in properties_python:
       if 'showFieldList' not in properties_python['collection']['template']:
         properties_python['collection']['template']['showFieldList'] = True
-      if 'showGrid' not in properties_python['collection']['template']:
-        properties_python['collection']['template']['showGrid'] = True
-      if 'showChart' not in properties_python['collection']['template']:
-        properties_python['collection']['template']['showChart'] = False
-      if 'chartSettings' not in properties_python['collection']['template']:
-        properties_python['collection']['template']['chartSettings'] = {}
-      if 'chartType' not in properties_python['collection']['template']['chartSettings']:
-        properties_python['collection']['template']['chartSettings']['chartType'] = 'bars'
-      if 'chartSorting' not in properties_python['collection']['template']['chartSettings']:
-        properties_python['collection']['template']['chartSettings']['chartSorting'] = 'none'
-      if 'chartScatterGroup' not in properties_python['collection']['template']['chartSettings']:
-        properties_python['collection']['template']['chartSettings']['chartScatterGroup'] = None
-      if 'chartScatterSize' not in properties_python['collection']['template']['chartSettings']:
-        properties_python['collection']['template']['chartSettings']['chartScatterSize'] = None
-      if 'chartScope' not in properties_python['collection']['template']['chartSettings']:
-        properties_python['collection']['template']['chartSettings']['chartScope'] = 'world'
-      if 'chartX' not in properties_python['collection']['template']['chartSettings']:
-        properties_python['collection']['template']['chartSettings']['chartX'] = None
-      if 'chartYSingle' not in properties_python['collection']['template']['chartSettings']:
-        properties_python['collection']['template']['chartSettings']['chartYSingle'] = None
-      if 'chartYMulti' not in properties_python['collection']['template']['chartSettings']:
-        properties_python['collection']['template']['chartSettings']['chartYMulti'] = []
-      if 'chartData' not in properties_python['collection']['template']['chartSettings']:
-        properties_python['collection']['template']['chartSettings']['chartData'] = []
-      if 'chartMapLabel' not in properties_python['collection']['template']['chartSettings']:
-        properties_python['collection']['template']['chartSettings']['chartMapLabel'] = None
 
     return properties_python
 
@@ -540,27 +474,18 @@ class Collection2(object):
     if 'showChart' not in props['collection']['template']:
       props['collection']['template']['showChart'] = False
     if 'chartSettings' not in props['collection']['template']:
-      props['collection']['template']['chartSettings'] = {}
-    if 'chartType' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartType'] = 'bars'
-    if 'chartSorting' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartSorting'] = 'none'
-    if 'chartScatterGroup' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartScatterGroup'] = None
-    if 'chartScatterSize' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartScatterSize'] = None
-    if 'chartScope' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartScope'] = 'world'
-    if 'chartX' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartX'] = None
-    if 'chartYSingle' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartYSingle'] = None
-    if 'chartYMulti' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartYMulti'] = []
-    if 'chartData' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartData'] = []
-    if 'chartMapLabel' not in props['collection']['template']['chartSettings']:
-      props['collection']['template']['chartSettings']['chartMapLabel'] = None
+      props['collection']['template']['chartSettings'] = {
+        'chartType': 'bars',
+        'chartSorting': 'none',
+        'chartScatterGroup': None,
+        'chartScatterSize': None,
+        'chartScope': 'world',
+        'chartX': None,
+        'chartYSingle': None,
+        'chartYMulti': [],
+        'chartData': [],
+        'chartMapLabel': None,
+      }
     if 'enabled' not in props['collection']:
       props['collection']['enabled'] = True
     if 'leafletmap' not in props['collection']['template']:

+ 3 - 3
apps/search/src/search/static/search/js/search.ko.js

@@ -848,11 +848,11 @@ var Collection = function (vm, collection) {
   }
 
   function isNumericColumn(type) {
-    return $.inArray(type, ['tfloat', 'tint', 'tlong', 'tdouble', 'plong', 'pint', 'pfloat', 'pdouble', 'currency', 'long', 'int', 'float', 'double']) > -1;
+    return $.inArray(type, NUMBER_TYPES.concat(FLOAT_TYPES)) > -1;
   }
 
   function isDateTimeColumn(type) {
-    return $.inArray(type, ['tdate', 'pdate', 'date']) > -1;
+    return $.inArray(type, DATE_TYPES) > -1;
   }
 
   function isStringColumn(type) {
@@ -1221,7 +1221,7 @@ var NewTemplate = function (vm, initial) {
 
 
 var DATE_TYPES = ['date', 'tdate'];
-var NUMBER_TYPES = ['int', 'tint', 'long', 'tlong', 'float', 'tfloat', 'double', 'tdouble'];
+var NUMBER_TYPES = ['int', 'tint', 'long', 'tlong', 'float', 'tfloat', 'double', 'tdouble', 'currency'];
 var FLOAT_TYPES = ['float', 'tfloat', 'double', 'tdouble'];
 var GEO_TYPES = ['SpatialRecursivePrefixTreeFieldType'];
 

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

@@ -201,7 +201,7 @@ def save(request):
 @allow_viewer_only
 def download(request):
   try:
-    file_format = 'csv' if 'csv' in request.POST.get('type') else 'xls' if 'xls' in request.POST.get('type') else 'json'
+    file_format = 'csv' if 'csv' == request.POST.get('type') else 'xls' if 'xls' == request.POST.get('type') else 'json'
     response = search(request)
 
     if file_format == 'json':