Example #1
0
def get_context():
	post_name = webnotes.request.path[1:].split("/")[1]
	post = webnotes.bean("Post", post_name).doc
	
	access = get_access(post.unit)
	if not access.get("read"):
		return {
			"name": "Not Permitted",
			"title": "Not Permitted",
			"post_list_html": "<div class='text-muted'>You are not permitted to view this page</div>",
			"not_permitted": True
		}
	
	fullname = get_fullname(post.owner)
	title = "{post} by {fullname}".format(unit=post.unit, post="Post", fullname=fullname)
	unit = webnotes.bean("Unit", post.unit).doc
	parents = webnotes.conn.sql("""select name, unit_title from tabUnit 
		where lft <= %s and rgt >= %s order by lft asc""", (unit.lft, unit.rgt), as_dict=1)
	
	return {
		"name": post.unit,
		"title": title,
		"parent_post_html": get_parent_post_html(post, access),
		"post_list_html": get_child_posts_html(post),
		"parents": parents,
		"parent_post": post.name
	}
Example #2
0
def get_context():
	unit = webnotes.request.path[1:]
	try:
		if not unit or unit.lower().split(".")[0]=="index":
			unit = "India"
		
		if not is_public(unit):
			if not get_access(unit).get("read"):
				raise webnotes.PermissionError
		
		return {
			"title": "Aam Aadmi Party: " + get_unit_title(unit),
			"content": get_unit_html(unit) 
		}
	except webnotes.DoesNotExistError:
		return {"content": '<div class="alert alert-danger full-page">The page you are looking for does not exist.</div>'}
	except webnotes.PermissionError:
		return {"content": '<div class="alert alert-danger full-page">You are not permitted to view this page.</div>'}
Example #3
0
def get_child_posts_html(post, limit_start=0, limit_length=20):
	if isinstance(post, basestring):
		post = webnotes.bean("Post", post).doc
	
	access = get_access(post.unit)
	if webnotes.local.form_dict.cmd=="get_child_posts_html":
		# for paging
		if not access.get("read"):
			raise webnotes.PermissionError
	
	posts = webnotes.conn.sql("""select p.name, p.unit, p.status, p.is_task,
		p.assigned_to, p.event_datetime, p.assigned_to_fullname, p.picture_url,
		p.creation, p.content, p.parent_post, pr.fb_username, pr.first_name, pr.last_name
		from tabPost p, tabProfile pr
		where p.parent_post=%s and pr.name = p.owner
		order by p.creation desc limit %s, %s""", 
			(post.name, limit_start, limit_length), as_dict=True)
			
	return webnotes.get_template("templates/includes/post_list.html", filters={"scrub_url": scrub_url})\
		.render({"posts": posts, "limit_start":limit_start, "write": access.get("write")})
Example #4
0
def get_context():
	post_name = webnotes.request.path[1:].split("/")[1]
	post = webnotes.bean("Post", post_name).doc
	
	access = get_access(post.unit)
	if not access.get("read"):
		raise webnotes.PermissionError
	
	fullname = get_fullname(post.owner)
	title = "{post} by {fullname}".format(unit=post.unit, post="Post", fullname=fullname)
	unit = webnotes.bean("Unit", post.unit).doc
	parents = webnotes.conn.sql("""select name, unit_title from tabUnit 
		where lft <= %s and rgt >= %s order by lft asc""", (unit.lft, unit.rgt), as_dict=1)
	
	return {
		"name": post.unit,
		"title": title,
		"parent_post_html": get_parent_post_html(post, access),
		"post_list_html": get_child_posts_html(post),
		"public": 1,
		"parents": parents,
		"parent_post": post.name
	}