示例#1
0
 def mark(self,
          id,
          duedate,
          description,
          completed,
          done=None,
          delete=None):
     username = logon.checkauth()
     taskdir = gettaskdir(username)
     try:
         int(
             id, 16
         )  # check whether id is plain hex integer without nastiness like .. or /
     except ValueError:
         raise cherrypy.InternalRedirect(self.logoffpath)
     filename = os.path.join(taskdir, id + '.task')
     if done == "Done":
         d = configparser()
         with open(filename, "r") as file:
             d.readfp(file)
         if completed == "" or completed == "None":
             completed = date.today().isoformat()
         d.set('task', 'completed', completed)
         with open(filename, "w") as file:
             d.write(file)
     elif delete == "Del":
         os.unlink(filename)
     raise cherrypy.InternalRedirect(".")
示例#2
0
	def index(self):
		username = logon.checkauth()
		taskdir = gettaskdir(username)
		tasklist = glob.glob(os.path.join(taskdir,'*.task'))
		tasks = ['<div class="header">Tasklist for user : <span class="highlight">%s</span><form class="logoff" action="%s" method="GET"><button type="submit" name="logoffurl" class="logoff-button" value="/">Log off</button></form></div>'%(username,self.logoffpath),
				'<div class="taskheader"><div class="left">Due date</div><div class="middle">Description</div><div class="right">Completed</div></div>',
				'<div id="items" class="ui-widget-content">']
		for filename in tasklist:
			d = configparser(defaults={'description':'','duedate':'','completed':None})
			id = os.path.splitext(os.path.basename(filename))[0]
			d.readfp(open(filename))
			description = d.get('task','description')
			duedate = d.get('task','duedate')
			completed = d.get('task','completed')
			tasks.append('''<form class="%s" action="mark" method="GET">
			<input type="text" class="duedate left" name="duedate" value="%s" readonly="readonly" />
			<input type="text" class="description middle" name="description" value="%s" readonly="readonly" />
			<input type="text" class="completed right editable-date tooltip" title="click to select a date, then click done" name="completed" value="%s" />
			<input type="hidden" name="id" value="%s" />
			<button type="submit" class="done-button" name="done" value="Done" >Done</button>
			<button type="submit" class="del-button" name="delete" value="Del" >Del</button>
			</form>
			'''%('notdone' if completed==None else 'done',duedate,description,completed,id))
		tasks.append('''<form class="add" action="add" method="GET">
			<input type="text" class="duedate left editable-date tooltip" name="duedate" title="click for a date" />
			<input type="text" class="description middle tooltip" title="click to enter a description" name="description"/>
			<button type="submit" class="add-button" name="add" value="Add" >Add</button>
			</form></div>
			''')
		return base_page%('itemlist',"".join(tasks))
示例#3
0
	def add(self,add,description,duedate):
		username = logon.checkauth()
		taskdir = gettaskdir(username)
		filename = os.path.join(taskdir,uuid().hex+'.task')
		d=configparser()
		d.add_section('task')
		d.set('task','description',description)
		d.set('task','duedate',duedate)
		with open(filename,"w") as file:
			d.write(file)
		raise cherrypy.InternalRedirect(".")
示例#4
0
	def mark(self,id,duedate,description,completed,done=None,delete=None):
		username = logon.checkauth()
		taskdir = gettaskdir(username)
		filename = os.path.join(taskdir,id+'.task')
		if done=="Done":
			print('####',id,duedate,description,completed,done,delete)
			d=configparser()
			with open(filename,"r") as file:
				d.readfp(file)
			if completed == ""  or completed == "None": completed = date.today().isoformat()
			d.set('task','completed',completed)
			with open(filename,"w") as file:
				d.write(file)
		elif delete=="Del":
			os.unlink(filename)
		raise cherrypy.InternalRedirect(".")
示例#5
0
	def mark(self,id,duedate,description,completed,done=None,delete=None):
		username = logon.checkauth()
		taskdir = gettaskdir(username)
		try:
			int(id,16) # check whether id is plain hex integer without nastiness like .. or /  
		except ValueError:
			raise cherrypy.InternalRedirect(self.logoffpath)
		filename = os.path.join(taskdir,id+'.task')
		if done=="Done":
			d=configparser()
			with open(filename,"r") as file:
				d.readfp(file)
			if completed == ""  or completed == "None": completed = date.today().isoformat()
			d.set('task','completed',completed)
			with open(filename,"w") as file:
				d.write(file)
		elif delete=="Del":
			os.unlink(filename)
		raise cherrypy.InternalRedirect(".")
示例#6
0
 def index(self):
     # CHANGED, before serving the sheet, we authenticate the user. No returnpage argument is needed
     # as the defautl one is /
     username = logon.checkauth('/logon')
     return Root.spreadsheet
示例#7
0
	def index(self):
		# CHANGED, before serving the sheet, we authenticate the user. No returnpage argument is needed
		# as the defautl one is / 
		username=logon.checkauth('/logon')
		return Root.spreadsheet
示例#8
0
	def index(self):
		username=logon.checkauth('/logon')
		return '<html><body><p>Hello user <b>%s</b></p></body></html>'%username
示例#9
0
	def somepage(self):
		username=logon.checkauth('/logon',returntopage=True)
		return '<html><body><h1>This is some page.</h1></body></html>'
示例#10
0
 def somepage(self):
     username = logon.checkauth('/logon', returntopage=True)
     return '<html><body><h1>This is some page.</h1></body></html>'
示例#11
0
 def index(self):
     username = logon.checkauth('/logon')
     return '<html><body><p>Hello user <b>%s</b></p></body></html>' % username