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
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
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
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
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)