Exemple #1
0
 def POST (self):
     #logOutId=web.input().userId
     if model.Proving()==1:
         try:
             web.config._session.logIn=0
             web.config._session.Kill()
             conn.users.update({"userId":logOutId},{'$set':{"lastloginedTime":time.strftime('%Y%m%d%H%M%S')}})
         except:
             pass
         return model.returnJson(1)
     else:
         return model.returnJson(0)
Exemple #2
0
 def GET (self,urlId):
     #conn.articlePage
     if urlId is None:
         listArticle={}
         reArticle=[]
         try:
             for x in conn.article.find():
                 listArticle['articleId']=x['articleId']
                 listArticle['title']=x['title']
                 listArticle['creator']=x['creator']
                 listArticle['cover']=x['cover']
                 listArticle['isPublic']=x['isPublic']
                 listArticle['createdTime']=x['createdTime']
                 listArticle['lastUpdateTime']=x['lastUpdateTime']
                 listArticle['like']=x['like']
                 listArticle['disLike']=x['disLike']
                 listArticle['creator']=x['creator']
                 listArticle['type']=x['type']
                 reArticle.append(listArticle)
                 #reDate={"status":1,"date":reArticle}
                 #web.header('Content-Type','text/json; charset=utf-8', unique=True)
             return model.returnJson(1,reArticle)
         except:
             listArticle['articleId']=x['articleId']
             listArticle['title']=x['title']
             listArticle['creator']=x['creator']
             listArticle['cover']=x['cover']
             listArticle['isPublic']=x['isPublic']
             listArticle['createdTime']=x['createdTime']
             listArticle['lastUpdateTime']=x['lastUpdateTime']
             listArticle['like']=x['like']
             listArticle['disLike']=x['disLike']
             listArticle['creator']=x['creator']
             listArticle['type']=x['type']
             return model.returnJson(1,listArticle)
     else:
         reSignleArticle={}
         s=conn.article.find_one({'articleId':urlId})
         reSignleArticle['articleId']=s['articleId']
         reSignleArticle['title']=s['title']
         reSignleArticle['creator']=s['creator']
         reSignleArticle['cover']=s['cover']
         reSignleArticle['isPublic']=s['isPublic']
         reSignleArticle['createdTime']=s['createdTime']
         reSignleArticle['lastUpdateTime']=s['lastUpdateTime']
         reSignleArticle['like']=s['like']
         reSignleArticle['disLike']=s['disLike']
         reSignleArticle['creator']=s['creator']
         reSignleArticle['type']=s['type']
         #reDateS={"status":1,"date":reSignleArticle}
         #return reSignleArticle[2] 
         return model.returnJson(1,reSignleArticle)
Exemple #3
0
 def POST (self):
     strSignIn = web.input()
     userEmail=strSignIn.email
     dbUserDate=conn.users.find_one({"email":userEmail},{"_id":0})
     #userToken= str(random.randint(0,9))+str(random.randint(0,9))+str(random.randint(0,9))+str(random.randint(0,9))
     try:
         if dbUserDate["password"] == hashlib.new("md5",strSignIn.password).hexdigest():
             web.config._session.logIn=1
             web.config._session.userName=userEmail
             #web.setcookie('toKen',userToken)
             #web.ctx.session.Id=userId 
             #return dbUserDate["userID"]
             return model.returnJson(1,dbUserDate)
         else:
             return model.returnJson(0)
     except:
         return model.returnJson(0)
Exemple #4
0
 def POST (self):
     #conn.Article.save({'ArticleID':web.config._session.userName+time.strftime('%Y%m%d%H%M%S'),'Title':articleStr.Title,'Cover':articleStr.Cover,'Creator':web.config._session.userName,'isPubilc':articleStr.isPubilc,'Content':articleStr.Content,'createdTime':time.strftime('%Y%m%d%H%M%S'),'lastUpdateTime':time.strftime('%Y%m%d%H%M%S'),'Like':0,'disLike':0,'Type':'1'})
     #return '1'
     #return articleStr.Title
     if model.Proving()==1:
         articleStr=web.input(cover=None,section=None,title=None,content=None,isPublic=None)
         #conn.Article.save({'articleId':web.config._session.userName+time.strftime('%Y%m%d%H%M%S'),'title':articleStr.title,'content':articleStr.content,'section':articleStr.section,'cover':articleStr.cover,'creator':web.config._session.userName,'isPublic':articleStr.isPubilc,'createdTime':time.strftime('%Y%m%d%H%M%S'),'lastUpdateTime':time.strftime('%Y%m%d%H%M%S'),'like':0,'disLike':0,'type':None,'authors':None})
         #return model.returnJson(0)
         try:
             articleId=str(uuid.uuid1())
             conn.article.save({'articleId':articleId,'title':articleStr.title,'section':articleStr.section,'cover':articleStr.cover,'creator':web.config._session.userName,'isPublic':articleStr.isPublic,'createdTime':time.strftime('%Y%m%d%H%M%S'),'lastUpdateTime':time.strftime('%Y%m%d%H%M%S'),'like':0,'disLike':0,'type':None,'authors':None})
             conn.section.save({'sectionId':str(uuid.uuid1()),'creator':web.config._session.userName,'content':articleStr.content,'createdTime':time.strftime('%Y%m%d%H%M%S'),'lastUpdateTime':time.strftime('%Y%m%d%H%M%S'),'like':0,'dislike':0})
             return model.returnJson(1,{'articleId':articleId})
         except:
             return model.returnJson(0,"DatabaseErro")
     else:
         return model.returnJson(0,'Not Log')
Exemple #5
0
 def POST (self):
     strUserData = web.input(sex=None,mobile=None,name=None,avatar=None,description=None)
     edit={}
     if strUserData.sex !=None:
         edit['sex']=int(strUserData.sex)
     if strUserData.mobile !=None:
         edit['mobile']=strUserData.mobile 
     if strUserData.name !=None:
         edit['name']=strUserData.name
     if strUserData.description !=None:
         edit['description']=strUserData.description
     if strUserData.avatar !=None:
         edit['avatar']=strUserData.avatar
     #return edit
     try:
         conn.users.update({'email':web.config._session.userName},{'$set':edit})
         dbUserData=conn.users.find_one({"email":web.config._session.userName},{"_id":0})
         return model.returnJson(1,dbUserData)
     except:
         return model.returnJson(0)
Exemple #6
0
 def POST(self):
     strSignUp = web.input()
     #userMobile = str_singUp.Mobile
     userEmail = strSignUp.email
     userPassword=strSignUp.password
     userKeyMd5 = hashlib.new("md5",userPassword).hexdigest()
     #userToken = str_Reg_One.Token
     #Key_Reg1= userMobile + str(Token)
     ruleEmail="[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?"
     #ruleMobile="^[0-9]{11}$"
     rulePassword="******"
     #RegexToken="^[0-9]{4}$"
     userID=str(uuid.uuid1())
     if (re.match(ruleEmail,userEmail) and re.match(rulePassword,userPassword)):
         #userC=conn.users.find_one({"Email":userEmail},{"Email":1,"_id":0})
         if conn.users.find_one({"email":userEmail},{"email":1,"_id":0}) is None:
             conn.users.insert({'password':userKeyMd5,'email':userEmail,'userId':userID,'isActive':0,'createdTime':time.strftime('%Y%m%d%H%M%S'),'sex':None,'mobile':None,'lastLoginedTime':None,'name':None,'avatar':None,'description':None})
             return model.returnJson(1)
         else:
             return model.returnJson(0)
     else:
         return model.returnJson(0)
Exemple #7
0
 def GET (self):
     userName=web.config._session.userName
     dbUserDate=conn.users.find_one({"email":userName},{"_id":0})
     return model.returnJson(1,dbUserDate)