示例#1
0
class EvaluationHandler(BaseHandler):
    def initialize(self):
        self.init()
        self.mequa = MInfor()
        self.musage = MUsage()
        self.mrel = MInforRel()
        self.mcollect = MEvaluation()

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

        # 形如  /evalucate/0123/1
        if len(url_arr) == 2 and len(url_arr[0]) == 4 and (url_arr[1]
                                                           in ['0', '1']):
            if self.get_current_user():
                self.add_or_update(url_arr[0], url_arr[1])
            else:
                self.set_status('403')
                return False
        return None

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

        out_dic = {
            'eval0': self.mcollect.app_evaluation_count(app_id, 0),
            'eval1': self.mcollect.app_evaluation_count(app_id, 1)
        }

        json.dump(out_dic, self)
示例#2
0
    def add_or_update(self, app_id, value):
        MEvaluation.add_or_update(self.userinfo.uid, app_id, value)

        out_dic = {
            'eval0': MEvaluation.app_evaluation_count(app_id, 0),
            'eval1': MEvaluation.app_evaluation_count(app_id, 1)
        }

        return json.dump(out_dic, self)
    def add_or_update(self, app_id, value):
        '''
        Adding or updating the evalution.
        :param app_id:  the ID of the post.
        :param value: the evaluation
        :return:  in JSON format.
        '''
        MEvaluation.add_or_update(self.userinfo.uid, app_id, value)

        out_dic = {
            'eval0': MEvaluation.app_evaluation_count(app_id, 0),
            'eval1': MEvaluation.app_evaluation_count(app_id, 1)
        }

        return json.dump(out_dic, self)
示例#4
0
    def add_message(self, **kwargs):
        p_d = {
            'title': kwargs.get('title', 'iiiii'),
            'cnt_md': kwargs.get('cnt_md', 'grgr'),
            'time_create': kwargs.get('time_create', '1992'),
            'time_update': kwargs.get('time_update', '1996070600'),
            'user_name': kwargs.get('user_name', 'yuanyuan'),
            'view_count': kwargs.get('view_count', 1),
            'logo': kwargs.get('logo', 'prprprprpr'),
            'memo': kwargs.get('memo', ''),
            'order': kwargs.get('order', '1'),
            'keywords': kwargs.get('keywords', ''),
            'extinfo': kwargs.get('extinfo', {}),
            'kind': kwargs.get('kind2', '1'),
            'valid': kwargs.get('valid', 1),
        }
        post_id = kwargs.get('post_id', self.post_id)

        MPost.create_post(post_id, p_d)
        user_id = kwargs.get('user_id', self.user_id)
        MEvaluation.add_or_update(user_id, self.app_id, 1)
示例#5
0
 def test_add_or_update(self):
     value = 1
     MEvaluation.add_or_update(self.user_id, self.app_id, value)
     a=MEvaluation.get_by_signature(self.user_id, self.app_id)
     assert a
     self.tearDown()