예제 #1
0
파일: login.py 프로젝트: tbbrave/render
    def post(self, *args, **kwargs):
        result = {}
        id = self.get_argument('id')
        pwd = self.get_argument('pwd')
        email = self.get_argument('email')
        desc = self.get_argument('description')

        try:
            id = qn(id)
            pwd = qn(pwd)
            email = qn(email)
            desc = qndes(desc)
            if desc != '':
                desc = text2Html(desc)
            if not getUserById(id):
                try:
                    signUp(id, pwd, email, desc)
                    result['result'] = 'success'
                except IntegrityError:
                    result['result'] = 'email_existed'
            else:
                result['result'] = 'user_existed'
        except TypeError:
            result['result'] = 'special_marks'

        self.write(json_encode(result))
예제 #2
0
파일: login.py 프로젝트: tbbrave/render
    def post(self, *args, **kwargs):
        email = self.get_argument('email')
        description = self.get_argument('description')
        if not getUserById(self.id):
            self.redirect('/error/no_such_user')
        else:
            try:
                description = qndes(description)
                description = text2Html(description)  # 保存换行信息
                email = qn(email)

                userSetPortrait(email, description, self.id)
                self.redirect('/user')
            except TypeError:
                self.redirect('/error/special_marks/share')
예제 #3
0
파일: share.py 프로젝트: tbbrave/render
    def post(self):

        try:
            f = self.request.files['sharefile'][0].body
            fname = self.request.files['sharefile'][0].filename
            description = self.get_argument('description')
            picname = self.get_argument('name')
            id = self.get_argument('id')
            ext = fname.split('.')[-1]

            if not id:
                self.redirect('/login')
            else:
                if ext not in ['jpg', 'jpeg', 'png', 'gif', 'JPEG', 'tiff', 'tif', 'raw']:
                    self.redirect('/error/sharePicError/share')
                else:

                    if not getUserById(id):
                        self.redirect('/error/no_such_user/share')
                    else:
                        try:
                            description = qndes(description)
                            description = text2Html(description)  # 保存换行信息
                            picname = qndes(picname)

                            # 生成文件id
                            (fid, time) = generateFId()

                            # 保存文件
                            try:
                                path = os.path.dirname(__file__)[:-8] + '/static/imgshare'

                                filename = fid + '.' + ext
                                fpath = os.path.join(path, filename)
                                fi = open(fpath, 'w')
                                fi.write(f)
                                fi.close()
                                shareFileImg(fid, picname, description, '/static/imgshare/' + filename, time, id)

                                self.redirect('/user')
                            except Exception as e:
                                print e
                        except TypeError:
                            self.redirect('/error/special_marks/share')
        except KeyError as e:
            pass
예제 #4
0
파일: share.py 프로젝트: tbbrave/render
    def post(self, *args, **kwargs):
        """解析来自web端post请求"""
        # try:
        # 从form表单中读取数据
        platform = self.get_argument('platform')

        if not self.get_secure_cookie('id') and platform == '0':
            self.redirect('/login')
        else:
            # 生成模型id
            (fid, time) = generateFId()

            f = self.request.files['sharefile'][0].body
            fname = self.request.files['sharefile'][0].filename
            id = self.get_argument('id')

            if not getUserById(id):
                self.redirect('/error/no_such_user/share')
            else:
                if fname.split('.')[-1] != 'zunimax':
                    self.redirect('/error/shareModelError/share')
                else:

                    try:
                        # 保存文件
                        path = os.path.dirname(__file__)[:-8] + '/static/imgshare'
                        fpath = path + fname
                        fi = open(fpath, 'w')
                        fi.write(f)
                        fi.close()

                        # 解压并处理文件
                        (naming, description) = unzip(path, fname, fid)

                        # 增加分享的文件记录
                        shareFile(fid, naming, description, '/static/imgshare/' + fid + '.png', time, id)

                        if platform == '0':
                            self.redirect('/')
                        elif platform == '1':
                            pass
                    except:
                        pass
                    finally:
                        self.write(json_encode({'result': 'success'}))
예제 #5
0
파일: login.py 프로젝트: tbbrave/render
 def get(self, *args, **kwargs):
     if not self.id:
         self.redirect('/')
     else:
         user = getUserById(self.id)
         self.render('changeProfile.html', uid=self.id, user=user, descrip=html2Text(user['description']))