Commits

gao shuai committed 88c14ac

ADD quickPassword to add items quickly without signin.

  • Participants
  • Parent commits a758b85

Comments (0)

Files changed (3)

 	public=db.IntegerProperty(default=0)
 	utc=db.IntegerProperty(default=8)
 	nowterm=db.StringProperty()
+	quickPassword=db.StringProperty()
 
 class kcbterm(db.Model):
 	user= db.ReferenceProperty(kcbuser)
 		'USER':users.get_current_user(),
 		'URL':URL,
 		'NOTERM':NoTerm,
+		'user':db.get(user),
 		}
 		path = os.path.join(os.path.dirname(__file__), 'tpl','admin.html')
 		self.response.out.write(template.render(path, template_values))
 class AddItemHandler(webapp.RequestHandler):
 	def post(self):
-		user=str(users.get_current_user())
-		USER=db.GqlQuery('SELECT __key__ FROM kcbuser WHERE user = :1', user.lower())
-		user=USER[0]
+		Password=self.request.get('quickPassword')
+		if Password:
+			user=self.request.get('key')
+			USER=db.get(self.request.get('key'))
+			if USER.quickPassword==Password:
+				pass
+			else:
+				self.redirect('/admin')
+				return;
+		else:
+			user=str(users.get_current_user())
+			USER=db.GqlQuery('SELECT __key__ FROM kcbuser WHERE user = :1', user.lower())
+			user=USER[0]
 		NowTerm=db.get(db.get(user).nowterm)
 
 ############_______________________________写入数据库______________________
 		# path = os.path.join(os.path.dirname(__file__), 'bingo.html')
 		# self.response.out.write(template.render(path, template_values))
 
-		self.redirect('/admin')
+		if Password:
+			self.redirect('/%s'%USER.url)
+		else:
+			self.redirect('/admin')
 class DeleteHandler(webapp.RequestHandler):
 	def post(self):
 		delitem=self.request.get_all('delitem')
 			TERM.place=TERMNAME
 			TERM.put()
 			self.redirect('/admin')
+		if flag=='quickPassword':
+			Password=self.request.get('quickPassword')
+			USER=db.get(self.request.get('key'))
+			USER.quickPassword=Password
+			USER.put()
+			self.redirect('/admin')
 
 
 

File tpl/admin.html

         </div><input type="submit" value="提交" />
       </fieldset>
     </form><br />
+    </div>
+    <form action="/admin/change/quickPassword" method="post">
+      <fieldset>
+        <legend>↓修改你的quickPassword↓</legend>
+        <div>
+          <input type="text" name='quickPassword' value="" />
+          <input type="hidden" name='key' value="{{user.key}}" />
+        </div>
+        <input type="submit" value="提交" />
+      </fieldset>
+    </form>
+    <br />
     <br />
     <form action="/admin/public" method="post">
       <fieldset>

File tpl/bingo.html

 <a href='/{{user.url}}/day/5'>周5课程</a>
 <a href='/{{user.url}}/day/6'>周6课程</a>
 <a href='/{{user.url}}/day/7'>周7课程</a>
-<div style="float:right;">
+<!--<div style="float:right;">
 
  	 <form action="/query" method="post">
 	查询某一天的课程?格式:20100828<input type="text" name="querydate" />
  <input type="Submit" id="submit_btn" value="查询" />
  </form>
 </div>
-
+-->
   <div id='addnew'>
 
 <br />
 	<br />
 	<input type="text" name="kcbweek" />那些周<br />
 	<br />
+    
+    <input type="hidden" name='key' value="{{user.key}}" />
+	<input type="password" name="quickPassword" />quickPassword<br />
+	<br />
 <p><input type="Submit" id="submit_btn" value="提交" class="btn green" /></p>
 
     </form>