コード例 #1
0
ファイル: entity_handler.py プロジェクト: lyzhanghai/TorCMS
 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
コード例 #2
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
コード例 #3
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
コード例 #4
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
コード例 #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'

            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)
コード例 #6
0
    def render(self, *args, **kwargs):
        current = int(args[0])

        pager_count = int(MEntity2User.total_number() /
                          config.CMS_CFG['list_num'])
        page_num = (pager_count if
                    abs(pager_count - MEntity2User.total_number() /
                        config.CMS_CFG['list_num']) < 0.1 else pager_count + 1)
        kwd = {
            'page_home': False if current <= 1 else True,
            'page_end': False if current >= page_num else True,
            'page_pre': False if current <= 1 else True,
            'page_next': False if current >= page_num else True,
        }

        return self.render_string('modules/post/entity_download_pager.html',
                                  kwd=kwd,
                                  pager_num=page_num,
                                  page_current=current)
コード例 #7
0
 def setup(self):
     print('setup 方法执行于本类中每条用例之前')
     self.M2U = MEntity2User()
     self.username = '******'
     self.uu = MUser()
     self.user_uid = ''
     self.e_uid = 'q112'
     self.path = '/static/123123'
     self.userip = '10.6.0.177'
     self.ee = MEntity()
     self.uid = ''
コード例 #8
0
    def list(self, cur_p=''):
        '''
        List the entities of the user.
        '''
        current_page_number = int(cur_p) if cur_p else 1
        current_page_number = 1 if current_page_number < 1 else current_page_number

        kwd = {'current_page': current_page_number}
        recs = MEntity2User.get_all_pager(
            current_page_num=current_page_number).naive()
        self.render('misc/entity/entity_download.html',
                    imgs=recs,
                    cfg=config.CMS_CFG,
                    kwd=kwd,
                    userinfo=self.userinfo)
コード例 #9
0
    def user_list(self, userid, cur_p=''):
        '''
        List the entities of the user.
        '''
        current_page_number = int(cur_p) if cur_p else 1
        current_page_number = 1 if current_page_number < 1 else current_page_number

        kwd = {'current_page': current_page_number}
        print("-" * 50)
        print(userid)
        print("-" * 50)
        recs = MEntity2User.get_all_pager_by_username(
            userid, current_page_num=current_page_number).objects()

        self.render('misc/entity/entity_user_download.html',
                    imgs=recs,
                    cfg=config.CMS_CFG,
                    kwd=kwd,
                    userinfo=self.userinfo)