Skip to content

Commit

Permalink
create command to register a search component, use that command in th…
Browse files Browse the repository at this point in the history
…e migration, re #4771

add term-filter component
  • Loading branch information
apeters committed Apr 30, 2019
1 parent cb67348 commit ca3ae74
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 33 deletions.
17 changes: 16 additions & 1 deletion arches/app/models/migrations/4771_searchcomponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,24 @@
# Generated by Django 1.11.15 on 2019-04-17 19:51
from __future__ import unicode_literals

import os
import uuid
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import uuid
from django.core import management
from arches.app.models.system_settings import settings


def forwards_func(apps, schema_editor):
for root, dirs, files in os.walk(os.path.join(settings.ROOT_DIR, 'app', 'search', 'components')):
for file in files:
filename, file_extension = os.path.splitext(file)
if file_extension == '.py':
print filename
management.call_command('search', 'register', source=os.path.join(root, file))

def reverse_func(apps, schema_editor):
pass

class Migration(migrations.Migration):

Expand Down Expand Up @@ -34,4 +48,5 @@ class Migration(migrations.Migration):
'managed': True,
},
),
migrations.RunPython(forwards_func, reverse_func)
]
19 changes: 19 additions & 0 deletions arches/app/search/components/term_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
details = {
"searchcomponentid": "",
"name": "Term Filter",
"icon": "",
"modulename": "term_filter.py",
"classname": "TermFilter",
"componenttype": "text-input",
"componentpath": "views/components/search/term-filter",
"componentname": "term-filter",
"config": {},
"sortorder": "0",
"enabled": True
}


class TermFilter():

def append_dsl(self, dsl):
pass
32 changes: 0 additions & 32 deletions arches/management/commands/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,37 +61,6 @@ def register(self, source):
dt_source = imp.load_source('', source)
details = dt_source.details

# dt = models.DDataType(
# datatype=details['datatype'],
# iconclass=details['iconclass'],
# modulename=os.path.basename(source),
# classname=details['classname'],
# defaultwidget=details['defaultwidget'],
# defaultconfig=details['defaultconfig'],
# configcomponent=details['configcomponent'],
# configname=details['configname'],
# isgeometric=details['isgeometric']
# )


# if len(models.DDataType.objects.filter(datatype=dt.datatype)) == 0:
# dt.save()
# else:
# print "{0} already exists".format(dt.datatype)


# details = {}

# try:
# with open(source) as f:
# details = json.load(f)
# except IOError as err:
# details = json.loads(source)

import ipdb
ipdb.set_trace()


try:
uuid.UUID(details['searchcomponentid'])
except:
Expand All @@ -118,7 +87,6 @@ def update(self, source):
Updates an existing search component in the arches db
"""
import json

details = {}

Expand Down

0 comments on commit ca3ae74

Please sign in to comment.