Example #1
0
def api_note_create(username):
	if request.method == 'POST':
		obj = request.form	
		if username and obj and 'content' in obj and 'context' in obj and 'kind' in obj:
			content = obj['content']
			context = obj['context']			
			kind = obj['kind']			
			a = Account.query.filter_by(username=username).first()
			c = Context.query.filter_by(name=context).first()
			if a and c:
				note = Note(a.id, c.id, kind, content)
				if 'longitude' in obj and 'latitude' in obj:
					note.longitude = obj['longitude']
					note.latitude = obj['latitude']
				db.session.add(note)
				db.session.commit()
				return success(note.to_hash())
		return error("some parameters are missing")
	else:
		return error("the request must be a post")
Example #2
0
		created_at = note_sheet.cell('K' + str(i)).value

		if not created_at:
			created_at = 1396325280
			det1 = 1.0 + float(randint(1,100) - 50)/5000000
			det2 = 1.0 + float(randint(1,100) - 50)/5000000				
		else:
			created_at = int(created_at)
			det1 = 1.0
			det2 = 1.0

		date = datetime.datetime.fromtimestamp(created_at)	
		if id:
			a = Account.query.filter_by(username=username).first()
			c = Context.query.filter_by(name=context).first()
			note = Note(a.id, c.id, kind, content)

			note.latitude = float(latitude) * det1
			note.longitude = float(longitude) * det2		
			note.created_at =  date
			note.modified_at =  date
			# created_at += datetime.timedelta(seconds=100)		
			print "create note: %s" % note
			db.session.add(note)
			db.session.commit()
			
			if media_kind:
				media = Media(note.id, media_kind, media_title, media_url) 
				media.created_at = date
				# created_at += datetime.timedelta(seconds=60)		
				print "create media: %s" % media