Exemplo n.º 1
0
    def __to_show_info__(self):
        '''
        show the user info
        '''
        rec = MUser.get_by_uid(self.userinfo.uid)

        MLog.insert_data(self.userinfo.uid, 'userinfo', 'userinfo')

        self.render(self.wrap_tmpl('user/{sig}user_info.html'),
                    userinfo=self.userinfo,
                    extinfo=rec.extinfo)
Exemplo n.º 2
0
 def view(self, view):
     '''
     View the wiki.
     '''
     kwd = {
         'pager': '',
         'editable': self.editable(),
     }
     if self.userinfo:
         MLog.insert_data(self.userinfo.uid, view.uid, 'wiki')
     self.render('wiki_page/wiki_view.html',
                 postinfo=view,
                 kwd=kwd,
                 userinfo=self.userinfo)
Exemplo n.º 3
0
    def view(self, rec):
        '''
        View the page.
        '''
        kwd = {
            'pager': '',
        }
        if self.userinfo:
            MLog.insert_data(self.userinfo.uid, rec.uid, 'page')

        self.render('wiki_page/page_view.html',
                    postinfo=rec,
                    kwd=kwd,
                    author=rec.user_name,
                    format_date=tools.format_date,
                    userinfo=self.userinfo,
                    cfg=CMS_CFG)
Exemplo n.º 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)
                MLog.insert_data(self.userinfo.uid, ment_id, 'download')
            return True
        else:
            return False
Exemplo n.º 5
0
    def viewinfo(self, postinfo):
        '''
        In infor.
        '''
        self.redirect_kind(postinfo)

        # ToDo: 原为下面代码。
        # ext_catid = postinfo.extinfo['def_cat_uid'] if 'def_cat_uid' in postinfo.extinfo else ''
        # ext_catid2 = postinfo.extinfo['def_cat_uid'] if 'def_cat_uid' in postinfo.extinfo else None

        ext_catid = postinfo.extinfo[
            'def_cat_uid'] if 'def_cat_uid' in postinfo.extinfo else ''

        cat_enum1 = MCategory.get_qian2(ext_catid[:2]) if ext_catid else []

        rand_recs, rel_recs = self.fetch_additional_posts(postinfo.uid)

        self._chuli_cookie_relation(postinfo.uid)

        catinfo = None
        p_catinfo = None

        post2catinfo = MPost2Catalog.get_first_category(postinfo.uid)
        if post2catinfo:
            catinfo = MCategory.get_by_uid(post2catinfo.tag_id)
            if catinfo:
                p_catinfo = MCategory.get_by_uid(catinfo.pid)

        kwd = self._the_view_kwd(postinfo)

        MPost.update_misc(postinfo.uid, count=True)
        if self.get_current_user() and self.userinfo:
            MUsage.add_or_update(self.userinfo.uid, postinfo.uid,
                                 postinfo.kind)
            MLog.insert_data(self.userinfo.uid, postinfo.uid, 'post')

        self.set_cookie('user_pass', kwd['cookie_str'])

        tmpl = self.ext_tmpl_view(postinfo)

        if self.userinfo:
            recent_apps = MUsage.query_recent(self.userinfo.uid, postinfo.kind,
                                              6).objects()[1:]
        else:
            recent_apps = []
        logger.info('The Info Template: {0}'.format(tmpl))
        self.render(
            tmpl,
            kwd=dict(kwd, **self.ext_view_kwd(postinfo)),
            postinfo=postinfo,
            userinfo=self.userinfo,
            author=postinfo.user_name,  # Todo: remove the key `author`.
            catinfo=catinfo,
            pcatinfo=p_catinfo,
            relations=rel_recs,
            rand_recs=rand_recs,
            subcats=MCategory.query_sub_cat(p_catinfo.uid),
            ad_switch=random.randint(1, 18),
            tag_info=filter(lambda x: not x.tag_name.startswith('_'),
                            MPost2Label.get_by_uid(postinfo.uid).objects()),
            recent_apps=recent_apps,
            cat_enum=cat_enum1)