Beispiel #1
0
 def post(self):
     sid = self.get_argument('sid')
     root = self.get_secure_cookie('root')
     if root != 'suiyue':
         return self.redirect('/rootlogin')
     stories = Story.get_by_sid(sid)
     ext_allowed = ['gif', 'jpg', 'jpeg', 'png']
     spic = stories[0].pic
     max_size = 2621440
     save_dir = os.path.join(os.path.dirname(__file__), "../public/pic/story/")
     if len(stories)>0:
         file_name = str(stories[0].sid)
         error = ""
         if 'image' in self.request.files:
             pic = self.request.files['image'][0]
             ext = pic['filename'].split('.').pop()
             if ext not in ext_allowed:
                 error="图片格式不支持"
                 self.redirect('/control')
             if len(pic['body'])>max_size:
                 error="图片太大"
                 self.redirect('/control')
             spic = file_name+"."+ext
             with open(save_dir+spic,'wb') as up:
                 up.write(pic['body'])
         Story.change_pic(sid, spic)
         self.redirect("/control")
     else:
         self.redirect('/control')
Beispiel #2
0
 def get(self):
     uname = self.get_current_user()
     user = User.get_user_by_name(uname)
     order = get_order()
     story = Story.get_by_porder(order)
     sid = self.get_argument("sid",None)
     if sid is not None:
         story=Story.get_by_sid(sid)
     article = Article.get_all_Astory(200)
     usedStory = Story.get_all_story()
     temp = []
     for one in usedStory:
         if one.porder > 0 and one.porder <= order:
             temp.append(one)
     usedStory = temp
     reArticles = Article.get_all(200)
     Rarticle = sorted(reArticles,BaseHandler.rank)
     Ruser = User.get_all_user(100)
     if len(Rarticle) > 6:
         Rarticle=Rarticle[:6]
     if len(usedStory)>3:
         usedStory=usedStory[:3]
     if len(Ruser)>9:
         Ruser=Ruser[:9]
     self.render("story.html",user=user,Rarticle=Rarticle,Article=article,usedStory=usedStory,Ruser=Ruser,story=story)
Beispiel #3
0
 def get(self):
     uname=self.get_current_user()
     user=User.get_user_by_name(uname)
     if len(user) > 0:
         cid = self.get_argument("cid", None)
         sid = self.get_argument("sid", None)
         Class = "free"
         if cid is not None:
             Class="card"
         elif sid is not None:
             Class="story"
         card=Card.get_by_cid(cid)
         story=Story.get_by_sid(sid)
         self.render("write.html",user=user,card=card,story=story,Class=Class)
     else:
         self.redirect("/login")