Commit 59d99fd1 authored by Kedar Aitawdekar's avatar Kedar Aitawdekar 💻

Updated API V1 to support datetime queries

parent 7f783184
......@@ -21,7 +21,7 @@ from django.contrib.auth.admin import User
from gnowsys_ndf.ndf.models import GSystemType, GSystem , Group #, Node, GSystem #, Triple
from gnowsys_ndf.ndf.models import NodeJSONEncoder
from gnowsys_ndf.ndf.models import node_collection,triple_collection
from gnowsys_ndf.ndf.views.methods import get_group_name_id
from gnowsys_ndf.ndf.views.methods import get_group_name_id, cast_to_data_type
gst_api_fields_dict = { "_id": 1, "name": 1, "altnames": 1, "language": 1, "content": 1, "if_file": 1, "tags": 1, "location": 1, "created_by": 1, "modified_by": 1, "contributors": 1, "legal": 1, "rating": 1, "created_at": 1, "last_update": 1, "collection_set": 1, "post_node": 1, "prior_node": 1, "access_policy": 1, "status": 1, "group_set": 1, "member_of": 1, "type_of": 1,
......@@ -35,7 +35,6 @@ api_name_model_name_dict = {
def api_get_gs_nodes(request):
get_parameters_dict = request.GET.dict()
if not get_parameters_dict:
aggregated_dict = gst_api_fields_dict.copy()
......@@ -110,7 +109,7 @@ def api_get_gs_nodes(request):
for key, val in get_parameters_dict.iteritems():
stripped_key = key.split('.')[0]
if stripped_key in gsystem_keys:
query_dict.update({ key: ({'$regex': val, '$options': 'i'} if isinstance(gsystem_structure_dict[stripped_key], basestring or unicode) else val) })
query_dict.update({ key: ({'$regex': val, '$options': 'i'} if isinstance(gsystem_structure_dict[stripped_key], basestring or unicode) else cast_to_data_type(val, gsystem_structure_dict[stripped_key])) })
elif stripped_key in gst_attributes(gst_id):
query_dict.update({('attribute_set.' + stripped_key): {'$regex': val, '$options': 'i'}})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment