def get_keys(self):
     collection_name = self.request.GET["collection_name"]
     col_obj = CollectionMapping("mongo_content")
     data_obj = col_obj.find_one({"collection_name": collection_name})
     keys_name = (data_obj["key_names"]).keys()
     search_set = list(SEARCH_SET)
     return render_to_response("search/key_list.html", locals(), context_instance=RequestContext(self.request))
Ejemplo n.º 2
0
 def get_keys( self ):
     collection_name = self.request.GET['collection_name']
     col_obj = CollectionMapping( 'mongo_content' )
     data_obj = col_obj.find_one( { "collection_name":collection_name} )
     keys_name = ( data_obj['key_names'] ).keys()
     search_set = list( SEARCH_SET )
     return render_to_response( 'search/key_list.html', locals(), context_instance = RequestContext( self.request ) )
Ejemplo n.º 3
0
 def create_db( self ):
     self.collection_name = self.request.POST['id_collection']
     file = self.request.FILES['id_json']
     f = file.read()
     json_dump = json.loads( str( f ) )
     self.create_content( json_dump )
     col_obj = CollectionMapping( self.collection_name )
     col_obj.load_json( json_dump )
     return HttpResponse( 'File Uploaded' )
Ejemplo n.º 4
0
 def create_db(self):
     self.collection_name = self.request.POST['id_collection']
     file = self.request.FILES['id_json']
     f = file.read()
     json_dump = json.loads(str(f))
     self.create_content(json_dump)
     col_obj = CollectionMapping(self.collection_name)
     col_obj.load_json(json_dump)
     return HttpResponse('File Uploaded')
Ejemplo n.º 5
0
 def upload_json( self, json_dump, unique_dict=None ):
     print "uploading"
     for key,value_list in json_dump.items():
         self.collection_name=key
         self.create_content( value_list )
         col_obj = CollectionMapping( key)
         load_all=True
         for value in value_list:
             if unique_dict:
                 res=col_obj.find_one(unique_dict)
                 if res:
                     col_obj.objects.update(unique_dict,value)
                     load_all=False
             if load_all:
                 col_obj.load_json( value )
     print "file uploaded"
     return HttpResponse( 'File Uploaded' )
Ejemplo n.º 6
0
 def upload_json(self, json_dump, unique_dict=None):
     print "uploading"
     for key, value_list in json_dump.items():
         self.collection_name = key
         self.create_content(value_list)
         col_obj = CollectionMapping(key)
         load_all = True
         for value in value_list:
             if unique_dict:
                 res = col_obj.find_one(unique_dict)
                 if res:
                     col_obj.objects.update(unique_dict, value)
                     load_all = False
             if load_all:
                 col_obj.load_json(value)
     print "file uploaded"
     return HttpResponse('File Uploaded')
Ejemplo n.º 7
0
    def build_query(self):
        """ prepares query for searching """

        collection_id = self.request.POST.get('models')
        ct_obj = CollectionContentType()
        collection_name = ct_obj.find_one({'_id': ObjectId(collection_id)
                                           })['collection_name']
        collection_obj = CollectionMapping(collection_name)
        self.data_list = collection_obj.objects.filter(self.constraint_dict)
Ejemplo n.º 8
0
 def get_context_data(self, **kwargs):
     form = EditForm()
     collection_name = self.kwargs.get('model_name')
     collection_obj = CollectionMapping(collection_name)
     return {'form': form}
Ejemplo n.º 9
0
 def update_db(self, json_dump):
     for key, value_dict in json_dump.items():
         obj = CollectionMapping(key)
         obj.objects.update(value_dict['where'], value_dict['set'])