Exemple #1
0
class CollectHandler(BaseHandler, ):
    def initialize(self):
        self.init()
        self.mequa = MApp()
        self.musage = MUsage()
        self.mrel = MAppRel()
        self.mcollect = MCollect()

    def get(self, url_str=''):
        if len(url_str) > 0:
            url_arr = url_str.split('/')
        else:
            return False
        if url_str == 'list':
            self.list()
        elif len(url_arr) == 1 and len(url_str) == 4 :
            if self.get_current_user():
                self.add_or_update(url_str)
            else:
                self.set_status('403')
                return False

    @tornado.web.authenticated
    def add_or_update(self, app_id):
        self.mcollect.add_or_update(self.userinfo.uid, app_id)

    @tornado.web.authenticated
    def list(self):
        self.render('tmpl_applite/collect/list.html',
                    recs_collect = self.mcollect.query_recent(self.userinfo.uid, 20),
                    userinfo = self.userinfo,
                    )
Exemple #2
0
    def test_query_recent(self):
        self.add_mess()
        user_id = self.user_id
        a = MCollect.query_recent(user_id)

        assert a[0].post_id == self.post_id
        self.tearDown()
Exemple #3
0
class CollectHandler(
        BaseHandler, ):
    def initialize(self):
        self.init()
        self.mequa = MApp()
        self.musage = MUsage()
        self.mrel = MAppRel()
        self.mcollect = MCollect()

    def get(self, url_str=''):
        if len(url_str) > 0:
            url_arr = self.parse_url(url_str)
        else:
            return False

        if url_str == 'list':
            self.list()
        elif len(url_arr) == 1 and len(url_str) == 4:
            if self.get_current_user():
                self.add_or_update(url_str)
            else:
                self.set_status('403')
                return False

    @tornado.web.authenticated
    def add_or_update(self, app_id):
        self.mcollect.add_or_update(self.userinfo.uid, app_id)

    @tornado.web.authenticated
    def list(self):
        self.render(
            'user/collect/list.html',
            recs_collect=self.mcollect.query_recent(self.userinfo.uid, 20),
            userinfo=self.userinfo,
        )
Exemple #4
0
 def test_query_recent(self):
     user_id = self.user_id
     MCollect.query_recent(user_id)
     assert True
Exemple #5
0
 def list(self):
     self.render('misc/collect/list.html',
                 recs_collect=MCollect.query_recent(self.userinfo.uid, 20),
                 userinfo=self.userinfo)