Esempio n. 1
0
    def find_files_by_query(cls, query):
        mongodbmanager.connect()
        files =  File.objects(name__icontains = query)

        #do manual distinct
        returning_files = []
        returning_files_hashes = []
        for f in files:
            if f.hash not in returning_files_hashes:
                returning_files.append(f)
                returning_files_hashes.append(f.hash)

        return returning_files
Esempio n. 2
0
    def add(cls, id='', kootaj='', desc=''):


        if id != '':
            obj = Model.objects(Kootaj=id).first()

        else:
            obj = Model()

        if obj != None:
            obj.kootaj = kootaj
            obj.desc = desc

            obj.save()
Esempio n. 3
0
    def find(cls, _filter={}, page=-1, per_page=15, sort='personnel_id', order=1):
        try:
            obj = Model.objects(__raw__=_filter)

            result = []
            for item in obj:
                result.append({
                    'id': obj.id,
                    'kootaj': obj.kootaj,
                    'desc': obj.desc,

                               })
            return result
        except Exception, err:
            return err.message
Esempio n. 4
0
 def find_file(cls, name, hash, user):
     mongodbmanager.connect()
     return  File.objects(name = name, hash = hash, session_id = user.session_id).first()
Esempio n. 5
0
 def find_files_for_user(cls, user):
     mongodbmanager.connect()
     return File.objects(session_id = user.session_id)
Esempio n. 6
0
 def count_files_by_hash(cls, hash):
     mongodbmanager.connect()
     return File.objects(hash = hash).count()
Esempio n. 7
0
 def find_files_by_hash(cls, hash):
     mongodbmanager.connect()
     return File.objects(hash = hash).all()
Esempio n. 8
0
 def find_file_by_hash_and_sessionid(cls, hash, session_id):
     mongodbmanager.connect()
     return File.objects(hash = hash, session_id = session_id).first()