Exemplo n.º 1
0
def ajaxDeletePost(postId):
	try:
		if not postId:
			return httpservice.badRequest(response=response)

		postservice.deletePost(postId=postId)

	except Exception as e:
		return httpservice.error(response=response, message=e.message)

	return { "message": "Post deleted successfully!" }
Exemplo n.º 2
0
def ajaxArchivePost(postId):
	try:
		if not postId:
			return httpservice.badRequest(response=response)

		numAffected = postservice.archivePost(postId=postId)
		if numAffected <= 0:
			return httpservice.noFound(response=response)

	except Exception as e:
		return httpservice.error(response=response, message=e.message)

	return { "message": "Post archived successfully!" }
Exemplo n.º 3
0
def ajaxGetBucket():
	try:
		awsSettings = awsservice.getSettings()
		connection = s3service.connect(accessKeyId=awsSettings["accessKeyId"], secretAccessKey=awsSettings["secretAccessKey"])
		items = s3service.getBucketItems(connection=connection, bucketName=awsSettings["s3Bucket"])

		data = []

		for i in items:
			_, ext = os.path.splitext(i.name)
			if ext in [".png", ".jpg", ".jpeg", ".gif"]:
				fullUrl = i.generate_url(expires_in=300, force_http=True)
				sanitizedUrl = urlservice.removeQueryString(url=fullUrl)
				data.append({ "url": sanitizedUrl, "name": i.name })

		return {
			"success": True,
			"data": data
		}

	except Exception as e:
		return httpservice.error(response=response, message=e.message)