Ejemplo n.º 1
0
 def initialize(self):
     self.mequa = MApp()
     self.musage = MUsage()
     self.muser = MUser()
     self.mrel = MAppRel()
     self.mcollect = MCollect()
     if self.get_current_user():
         self.userinfo = self.muser.get_by_id(self.get_current_user())
     else:
         self.userinfo = None
     self.tmpl_sig = app_template_name
Ejemplo n.º 2
0
 def initialize(self):
     self.mequa = MApp()
     self.musage = MUsage()
     self.muser = MUser()
     self.mrel = MAppRel()
     self.mcollect = MCollect()
     if self.get_current_user():
         self.userinfo = self.muser.get_by_id(self.get_current_user())
     else:
         self.userinfo = None
     self.tmpl_sig = app_template_name
Ejemplo n.º 3
0
class CollectHandler(
        BaseHandler, ):
    def initialize(self):
        self.mequa = MApp()
        self.musage = MUsage()
        self.muser = MUser()
        self.mrel = MAppRel()
        self.mcollect = MCollect()
        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None
        self.tmpl_sig = app_template_name

    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(
            '{0}/collect/list.html'.format(self.tmpl_sig),
            recs_collect=self.mcollect.query_recent(self.userinfo.uid, 20),
            userinfo=self.userinfo,
        )
Ejemplo n.º 4
0
class CollectHandler(BaseHandler, ):
    def initialize(self):
        self.mequa = MApp()
        self.musage = MUsage()
        self.muser = MUser()
        self.mrel = MAppRel()
        self.mcollect = MCollect()
        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None
        self.tmpl_sig = app_template_name


    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('{0}/collect/list.html'.format(self.tmpl_sig),
                    recs_collect = self.mcollect.query_recent(self.userinfo.uid, 20),
                    userinfo = self.userinfo,
                    )