Example #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,
                    )
Example #2
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,
        )
 def add_or_update(self, app_id):
     '''
     Add or update the category.
     '''
     logger.info('Collect info: user-{0}, uid-{1}'.format(
         self.userinfo.uid, app_id))
     MCollect.add_or_update(self.userinfo.uid, app_id)
     out_dic = {'success': True}
     return json.dump(out_dic, self)
Example #4
0
 def add_mess(self):
     self.add_message()
     MCollect.add_or_update(self.user_id, self.post_id)
     a = MCollect.query_pager_by_all(self.user_id)
     tf = False
     for i in a:
         if i.post_id == self.post_id:
             tf = True
     assert tf
Example #5
0
    def test_add_or_update(self):
        self.add_message()
        user_id = self.user_id
        app_id = self.post_id
        MCollect.add_or_update(user_id, app_id)
        a = MCollect.get_by_signature(user_id, app_id)

        assert a != None
        self.tearDown()
Example #6
0
 def test_add_or_update(self):
     user_id = self.user_id
     app_id = '11111'
     MCollect.add_or_update(user_id, app_id)
     assert True