示例#1
0
    def test_insert_2(self):
        '''Wiki insert: Test invalid title'''
        post_data = {
            'path': '',
        }
        uu = MEntity.get_id_by_impath(post_data['path'])
        assert uu == False

        post_data = {
            'path': self.path,
        }
        uu = MEntity.get_id_by_impath(post_data['path'])
        assert uu == False
示例#2
0
    def test_create_entity_2(self):
        '''Wiki insert: Test invalid title'''
        post_data = {
            'path': '',
        }
        uu = MEntity.get_id_by_impath(post_data['path'])
        assert uu is None

        post_data = {
            'path': self.path,
        }
        uu = MEntity.get_id_by_impath(post_data['path'])
        assert uu is None
示例#3
0
 def tearDown(self):
     print("function teardown")
     tt = MEntity.get_id_by_impath(self.path)
     if tt:
         print('x' * 20)
         print(tt)
         MEntity.delete(tt)
示例#4
0
 def _add_download_entity(self, ext_dic):
     download_url = ext_dic['tag_file_download'].strip().lower() if (
         'tag_file_download' in ext_dic) else ''
     the_entity = MEntity.get_id_by_impath(download_url)
     if the_entity:
         return True
     if download_url:
         MEntity.create_entity(path=download_url, desc=download_url, kind=4)
示例#5
0
    def down(self, down_uid):
        '''
        Download the entity by UID.
        '''

        post_data = {}
        for key in self.request.arguments:
            post_data[key] = self.get_arguments(key)[0]

        down_url = MPost.get_by_uid(down_uid).extinfo.get(
            'tag__file_download', '')
        if down_url:

            if allowed_file(down_url):
                kind = '1'
            elif allowed_file_pdf(down_url):
                kind = '2'
            else:
                kind = '3'
            if str(down_url)[:17] == '/static/datasets/':
                str_down_url = str(down_url)[8:]
            else:
                str_down_url = str(down_url)[15:]
            if kind == '3':
                str_down_url = down_url

            ment_id = MEntity.get_id_by_impath(str_down_url)
            if ment_id:

                MEntity2User.create_entity2user(ment_id, self.userinfo.uid,
                                                post_data['userip'])

                return True
            else:

                MEntity.create_entity(uid='',
                                      path=str_down_url,
                                      desc='',
                                      kind=kind)
                ment_id = MEntity.get_id_by_impath(str_down_url)
                if ment_id:
                    MEntity2User.create_entity2user(ment_id, self.userinfo.uid,
                                                    post_data['userip'])
                    return True
        else:
            return False
示例#6
0
    def down(self, down_uid):
        '''
        Download the entity by UID.
        '''
        post_data = {}
        for key in self.request.arguments:
            post_data[key] = self.get_arguments(key)[0]

        down_url = MPost.get_by_uid(down_uid).extinfo.get(
            'tag__file_download', '')
        if down_url:

            if allowed_file(down_url):
                kind = '1'
            elif allowed_file_pdf(down_url):
                kind = '2'
            else:
                kind = '3'

            ment_id = MEntity.get_id_by_impath(down_url)

            userip = self.get_host_ip()

            if ment_id:

                MEntity2User.create_entity2user(ment_id, self.userinfo.uid,
                                                userip)

            else:

                MEntity.create_entity(uid='',
                                      path=down_url,
                                      desc='',
                                      kind=kind)
                ment_id = MEntity.get_id_by_impath(down_url)
                if ment_id:
                    MEntity2User.create_entity2user(ment_id, self.userinfo.uid,
                                                    userip)

            output = {'down_code': 1, 'down_url': down_url}

        else:
            output = {'down_code': 0}
        return json.dump(output, self)
示例#7
0
 def down(self, down_uid):
     mpost = MPost.get_by_uid(down_uid)
     down_url = mpost.extinfo[
         'tag_file_download'] if 'tag_file_download' in mpost.extinfo else ''
     if down_url:
         url = mpost.extinfo['tag_file_download']
         ment_id = MEntity.get_id_by_impath(url)
         MEntity2User.create_entity2user(ment_id, self.userinfo.uid)
     else:
         return False
示例#8
0
 def down(self, down_uid):
     '''
     Download the entity by UID.
     '''
     down_url = MPost.get_by_uid(down_uid).extinfo.get(
         'tag_file_download', '')
     if down_url:
         ment_id = MEntity.get_id_by_impath(down_url)
         MEntity2User.create_entity2user(ment_id, self.userinfo.uid)
     else:
         return False
示例#9
0
    def down(self, down_uid):
        '''
        Download the entity by UID.
        '''
        down_url = MPost.get_by_uid(down_uid).extinfo.get(
            'tag__file_download', '')
        print('=' * 40)
        print(down_url)
        str_down_url = str(down_url)[15:]

        if down_url:
            ment_id = MEntity.get_id_by_impath(str_down_url)
            if ment_id:
                MEntity2User.create_entity2user(ment_id, self.userinfo.uid)
            return True
        else:
            return False
示例#10
0
 def test_get_id_by_impath(self):
     MEntity.get_id_by_impath(self.path)
     assert True
示例#11
0
 def test_get_id_by_impath(self):
     self.add_message()
     path = self.path
     a = MEntity.get_id_by_impath(path)
     assert a.uid == self.uid
     self.tearDown()