Example #1
0
 def GET(self, id):
     board_list = ['education', 'remotworking', 'intelligence', 'beauty', 'emotion', 'health_management',
                   'entertainment', 'Domestic_counseling', 'shopping', 'career', 'community_services',
                   'public_information']
     board_id = int(id) - 1
     board_name = board_list[board_id]
     res = requests.get(conf.locate('/user/%s/profile' % web.cookies().get('key')))
     present_user = simplejson.loads(res.text)
     res = requests.get(conf.locate('/pin/list/%s' % id))
     json = simplejson.loads(res.text)
     pins = [[], [], [], []]
     for i, p in enumerate(json['pins']):
         if p['type'] == 'movie':
             res = requests.get(conf.locate('/user/%s/profile' % p['author_id']))
             profile = simplejson.loads(res.text)
             i %= 4
             pin_obj = Pin(p, profile, present_user)
             pins[i].append(pin_obj.render_video())
         elif p['type'] == 'picture':
             res = requests.get(conf.locate('/user/%s/profile' % p['author_id']))
             if res.status_code == 200:
                 profile = simplejson.loads(str(res.text))
                 i %= 4
                 pin_obj = Pin(p, profile, present_user)
                 pins[i].append(pin_obj.render())
     return render.showboard(pins, present_user, board_name)
Example #2
0
    def POST(self):
        i = web.input()
        
        board_list = [u'校外教育', u'远程办公', u'智慧之门', u'美容美体', u'情感天地',
                      u'健康管理', u'娱乐人生', u'家政辅导', u'购物天堂', u'职业生涯',
                      u'社区服务',u'公共信息']
        
        board_id = board_list.index(i.board_id) + 1
        x = web.input(upload_pic={})
        f = None
        if 'upload_pic' in x:
            f = x['upload_pic'].value
            # upload a file
        headers2 = {
            'X-Token': web.cookies().get('token')
        }
        upload_res = requests.post(conf.locate('/attachments/upload'),
                                   data=f,
                                   headers=headers2)
        uuid = simplejson.loads(upload_res.text)
        uuid = uuid['id']
        payload = {
            'introduction': i.introduction
        }
        headers = {
            'X-Token': web.cookies().get('token'),
            'Content-Type': 'application/json'
        }
        res = requests.post(conf.locate('/pin/create/%s/%s' % (board_id, uuid)),
                            data=simplejson.dumps(payload),
                            headers=headers)

        return web.seeother('/controlskip/%s' % board_id)
Example #3
0
    def POST(self):
        i = web.input()
        print "1111111."
        print i.board_id
        boardlist = ['education', 'remotworking', 'intelligence', 'beauty', 'emotion', 'health_management',
                     'entertainment', 'Domestic_counseling', 'shopping', 'career', 'community_services',
                     'public_information']

        board_id = boardlist.index(i.board_id) + 1
        # buffer
        x = web.input(upload_pic={})
        f = None
        if 'upload_pic' in x:
            f = x['upload_pic'].value
            # upload a file
        headers2 = {
            'X-Token': web.cookies().get('token')
        }
        upload_res = requests.post(conf.locate('/attachments/upload'),
                                   data=f,
                                   headers=headers2)
        uuid = simplejson.loads(upload_res.text)
        uuid = uuid['id']
        payload = {
            'introduction': i.introduction
        }
        headers = {
            'X-Token': web.cookies().get('token'),
            'Content-Type': 'application/json'
        }
        res = requests.post(conf.locate('/pin/create/%s/%s' % (board_id, uuid)),
                            data=simplejson.dumps(payload),
                            headers=headers)

        return web.seeother('/controlskip/%s' % board_id)
Example #4
0
    def GET(self, id):
        board_list = ['校外教育', '远程办公', '智慧之门', '美容美体', '情感天地',
                      '健康管理', '娱乐人生', '家政辅导', '购物天堂', '职业生涯',
                      '社区服务','公共信息']
        board_id = int(id) - 1
        board_name = board_list[board_id]
        res = requests.get(conf.locate('/user/%s/profile' % web.cookies().get('key')))
        present_user = simplejson.loads(res.text)
        res = requests.get(conf.locate('/pin/list/%s' % id))
        json = simplejson.loads(res.text)
        global pins
        pins = [[], [], [], []]
        profile = {}
        pin_threads = []
        for i, p in enumerate(json['pins']):
            profile['user'] = p['author']
            pin_thread = PinRender(profile, i, p, present_user)
            pin_threads.append(pin_thread)

        for thread in pin_threads:
            thread.start()

        while alive_count(pin_threads) > 0:
            time.sleep(UPDATE_INTERVAL)

        return render.showboard(pins, present_user, board_name)
Example #5
0
    def GET(self):
        res = requests.get(conf.locate('/user/%s/profile' % web.cookies().get('key')))
        present_user = simplejson.loads(res.text)
        res = requests.get(conf.locate('/pin/user/%s' % web.cookies().get('key')))
        present_user_pin = simplejson.loads(res.text)
        pins = [[], [], [], []]
        for i, p in enumerate(present_user_pin['pins']):
            print "111111111222222"
            print p
            if p['type'] == 'movie':
                res = requests.get(conf.locate('/user/%s/profile' % p['author_id']))
                profile = simplejson.loads(res.text)
                i %= 4
                pin_obj = Pin(p, profile, present_user)
                pins[i].append(pin_obj.render_video())
            elif p['type'] == 'picture':
                res = requests.get(conf.locate('/user/%s/profile' % p['author_id']))
                profile = simplejson.loads(res.text)
                print profile
                i %= 4
                pin_obj = Pin(p, profile, present_user)
                pins[i].append(pin_obj.render())

        headers = {
            'X-Token': web.cookies().get('token')
        }

        res = requests.get(conf.locate('/following/%s' % web.cookies().get('key')), headers=headers)
        result = simplejson.loads(res.text)
        attentions = []
        for attention in result:
            attentions.append(str(pure_render.attention_list(attention)))
        attentions_len=len(attentions)
        
        return render.usermessage(pins, present_user, attentions,attentions_len)
Example #6
0
    def GET(self):
        i = web.input()
        res = requests.get(conf.locate('/comment/%s' % i.img_key_id))
        json = simplejson.loads(res.text)
        res = requests.get(conf.locate('/user/%s/profile' % web.cookies().get('key')))
        present_user = simplejson.loads(res.text)
        comments = []
        for c in (json['comments']):
            comments.append(str(pure_render.comment(c, present_user)))

        return simplejson.dumps({
            "comments": comments
        })
Example #7
0
    def GET(self, id):
        res = requests.get(conf.locate('/pin/list?%s' % id))
        json = simplejson.loads(res.text)
        pin = []
        for p in json['pins']:
            res = requests.get(conf.locate('/user/%s/profile' % p['author_id']))
            profile = simplejson.loads(res.text)
            pin_obj = Pin(p, profile)
            pin.append(str(pin_obj.render()))

        return simplejson.dumps({
            "pins": pin
        })
Example #8
0
 def GET(self):
     input = web.input()
     results = requests.get(conf.locate("/user/check_username/%s" % input.name))
     result = simplejson.loads(results.text)
     return simplejson.dumps({
         "status": result['status']
     })
Example #9
0
    def POST(self):
        i = web.input()
        x = web.input(upload_video={})
        upload_res = None
        media = x.get('upload_video', None)
        if media is not None:
            if media.type == 'video/mp4' or media.type == 'video/x-flv':
                files = {'file': media.value}
                data = {'type': media.type}
                upload_res = requests.post(conf.media_server('/file_upload/'), files=files, data=data)
                upload_res = simplejson.loads(upload_res.text)

        key = upload_res['file_name']
        board_list = ['education', 'remotworking', 'intelligence', 'beauty', 'emotion', 'health_management',
                      'entertainment', 'Domestic_counseling', 'shopping', 'career', 'community_services',
                      'public_information']
        board_id = board_list.index(i.board_id) + 1
        payload = {
            'introduction': i.introduction,
            'movie_id': key
        }
        headers = {
            'X-Token': web.cookies().get('token'),
            'Content-Type': 'application/json'
        }
        res = requests.post(conf.locate('/pin/create/%s' % board_id),
                            data=simplejson.dumps(payload),
                            headers=headers)

        return web.seeother('/controlskip/%s' % board_id)
Example #10
0
 def POST(self):
     i = web.input()
     if hasattr(i, 'remember'):
         if (i.remember == "keep"):
             web.setcookie('email', i.email, expires=3600 * 24 * 30)
             web.setcookie('password', i.password, expires=3600 * 24 * 30)
         else:
             web.setcookie('email', '', expires=-1)
             web.setcookie('password', '', expires=-1)
             # Get the data
     payload = {
         'email': i.email,
         'password': i.password
     }
     headers = {
         'Content-Type': 'application/json'
     }
     res = requests.post(
         conf.locate("/user/token"),
         data=simplejson.dumps(payload),
         headers=headers
     )
     response = simplejson.loads(res.text)
     # Process the cookie
     if response.has_key('error'):
         return simplejson.dumps({
             "status": 'error'
         })
     else:
         web.setcookie('token', response['token'], expires=3600 * 24 * 30)
         web.setcookie('key', response['user']['key'], expires=3600 * 24 * 30)
         return simplejson.dumps({
             "status": 'ok'
         })
Example #11
0
 def GET(self):
     i = web.input()
     headers = {
         'X-Token': web.cookies().get('token')
     }
     res = requests.get(conf.locate('/fo/%s' % i.user_id), headers=headers)
     res = simplejson.loads(res.text)
Example #12
0
 def POST(self):
     i = web.input()
     x = web.input(upload_video={})
     upload_res = None
     media = x.get('upload_video', None)
     if media is not None:
         if media.type == 'video/mp4' or media.type == 'video/x-flv':
             files = {'file': media.value}
             data = {'type': media.type}
             upload_res = requests.post(conf.media_server('/file_upload/'), files=files, data=data)
             upload_res = simplejson.loads(upload_res.text)
    
     key = upload_res['file_name']
     board_list = [u'校外教育', u'远程办公', u'智慧之门', u'美容美体', u'情感天地',
                   u'健康管理', u'娱乐人生', u'家政辅导', u'购物天堂', u'职业生涯',
                   u'社区服务',u'公共信息']
     board_id = board_list.index(i.board_id) + 1
     payload = {
         'introduction': i.introduction,
         'movie_id': key
     }
     headers = {
         'X-Token': web.cookies().get('token'),
         'Content-Type': 'application/json'
     }
     res = requests.post(conf.locate('/pin/create/%s' % board_id),
                         data=simplejson.dumps(payload),
                         headers=headers)
   
     return web.seeother('/controlskip/%s' % board_id)
Example #13
0
 def GET(self):
     headers = {"X-Token": web.cookies().get("token")}
     res = requests.get(conf.locate("/following/%s" % web.cookies().get("key")), headers=headers)
     re = simplejson.loads(res.text)
     attentions = []
     for attention in re:
         attentions.append(str(pure_render.attention_list(attention)))
     return simplejson.dumps({"attentions": attentions})
Example #14
0
    def GET(self, code):

        r = requests.get(conf.locate("/user/validate/%s" % code))
        re = simplejson.loads(r.text)
        if re['status'] == 'successfully validated.':
            return render.checkemail_success()
        else:
            return render.checkemail_fail()
Example #15
0
 def GET(self):
     i = web.input()
     headers = {"X-Token": web.cookies().get("token")}
     res = requests.get(conf.locate("/fo/%s" % i.user_id), headers=headers)
     res = simplejson.loads(res.text)
     if res.has_key("id"):
         return simplejson.dumps({"relationship_id": res["id"]})
     elif res.has_key("status"):
         return simplejson.dumps({"relationship_id": res["status"]})
Example #16
0
 def GET(self,boardid):
     i=web.input()
     payload = {
         'board_id':boardid
     }
     headers = {
         'X-Token': web.cookies().get('token'),
         'Content-Type': 'application/json'
     }
     res = requests.put(conf.locate("/pin/%s/update" % i.img_key_id),
                        data=simplejson.dumps(payload),
                        headers=headers)
Example #17
0
    def GET(self):
        res = requests.get(conf.locate('/user/%s/profile' % web.cookies().get('key')))
        present_user = simplejson.loads(res.text)
        res = requests.get(conf.locate('/pin/user/%s' % web.cookies().get('key')))
        present_user_pin = simplejson.loads(res.text)
        pin = []
        for p in present_user_pin['pins']:
            if p['type'] == 'movie':
                res = requests.get(conf.locate('/user/%s/profile' % p['author_id']))
                profile = simplejson.loads(res.text)
                pin_obj = Pin(p, profile, present_user)
                pin.append(str(pin_obj.render_video()))
            elif p['type'] == 'picture':
                res = requests.get(conf.locate('/user/%s/profile' % p['author_id']))
                profile = simplejson.loads(res.text)
                pin_obj = Pin(p, profile, present_user)
                pin.append(str(pin_obj.render()))

        return simplejson.dumps({
            "pins": pin
        })
Example #18
0
 def POST(self):
     i = web.input()
     payload = {
         'content': i.content,
     }
     headers = {
         'X-Token': web.cookies().get('token'),
         'Content-Type': 'application/json'
     }
     res = requests.post(conf.locate('/comment/%s/create' % i.img_key_id),
                         data=simplejson.dumps(payload),
                         headers=headers)
Example #19
0
 def POST(self):
     i=web.input()
     payload = {
         'introduction':i.description,
     }
     headers = {
         'X-Token': web.cookies().get('token'),
         'Content-Type': 'application/json'
     }
     res = requests.put(conf.locate("/pin/%s/update" % i.img_key_id),
                        data=simplejson.dumps(payload),
                        headers=headers)
Example #20
0
 def POST(self):
     i=web.input()
     payload = {
         'email':i.email,
         'password':i.oldpwd,
         'new_password':i.newpwd
     }
     headers = {
         'X-Token': web.cookies().get('token'),
         'Content-Type': 'application/json'
     }
     res = requests.post(conf.locate("/user/password"),
                        data=simplejson.dumps(payload),
                        headers=headers)
Example #21
0
    def POST(self):
        i = web.input()
        # Get the data
        payload = {
            'email': i.email,
            'password': i.register_pwd,
            'birthday': '',
            'username': i.register_username,
            'gender': '',
            'introduction': ''
        }
        headers = {
            'Content-Type': 'application/json'
        }
        res = requests.post(conf.locate("/user/create"),
                            data=simplejson.dumps(payload),
                            headers=headers)
        resp = simplejson.loads(res.text)

        return web.seeother('/login')
Example #22
0
 def POST(self):
     input = web.input()
     # Get the data
     payload = {
         'email': input.email,
         'password': input.register_pwd,
         'birthday': '',
         'username': input.register_username,
         'gender': '',
         'introduction': ''
     }
     headers = {
         'Content-Type': 'application/json'
     }
     results = requests.post(conf.locate("/user/create"),
                             data=simplejson.dumps(payload),
                             headers=headers)
     result = simplejson.loads(results.text)
     if result.has_key('validation_code'):
         return web.seeother('/check/code/%s' % result['validation_code'])
Example #23
0
    def GET(self):
        i = web.input()
        headers = {
            'X-Token': web.cookies().get('token')
        }
        res = requests.get(conf.locate('/following/%s' % web.cookies().get('key')), headers=headers)
        result = simplejson.loads(res.text)
        if len(result):
            for attention in result:

                if attention['key'] == i.user_id:
                    return simplejson.dumps({
                        "attentions": 'followd'
                    })

            return simplejson.dumps({
                "attentions": 'unfollowd'
            })
        else:
            return simplejson.dumps({
                "attentions": 'unfollowd'
            })
Example #24
0
 def POST(self):
     i = web.input()
     pin_id = i.pin_id
     r = requests.delete(conf.locate('/pin/%s/delete' % pin_id))
Example #25
0
 def GET(self):
     i = web.input()
     print "*************************************8"
     print i.user_id
     headers = {"X-Token": web.cookies().get("token")}
     requests.get(conf.locate("/unfo/%s" % i.user_id), headers=headers)
Example #26
0
 def GET(self):
     i = web.input()
     headers = {
         'X-Token': web.cookies().get('token')
     }
     r = requests.get(conf.locate('/unfo/%s' % i.user_id), headers=headers)
Example #27
0
 def GET(self,ownkey):
     res = requests.get(conf.locate('/user/%s/profile' % ownkey))
     present_user = simplejson.loads(res.text)
     return render.setaccount(present_user)
Example #28
0
 def GET(self):
     res = requests.get(conf.locate('/user/%s/profile' % web.cookies().get('key')))
     json = simplejson.loads(res.text)
     username = json['user']['username']
     return render.mainpage(username)
Example #29
0
 def GET(self, id):
     res = requests.get(conf.locate('/attachments/thumbnail/%s' % id))
     return res.content