Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
  2. # MIT License. See license.txt
  3. from __future__ import unicode_literals
  4. import webnotes
  5. from webnotes.utils import get_fullname
  6. def get_post_context(group_context):
  7. post = webnotes.doc("Post", webnotes.form_dict.name)
  8. if post.parent_post:
  9. raise webnotes.PermissionError
  10. fullname = get_fullname(post.owner)
  11. return {
  12. "title": "{} by {}".format(post.title, fullname),
  13. # "group_title": group_context.get("unit_title") + " by {}".format(fullname),
  14. "parent_post_html": get_parent_post_html(post, group_context.get("view")),
  15. "post_list_html": get_child_posts_html(post, group_context.get("view")),
  16. "parent_post": post.name
  17. }
  18. def get_parent_post_html(post, view):
  19. profile = webnotes.bean("Profile", post.owner).doc
  20. for fieldname in ("first_name", "last_name", "user_image", "fb_hometown", "fb_location"):
  21. post.fields[fieldname] = profile.fields[fieldname]
  22. return webnotes.get_template("templates/includes/inline_post.html")\
  23. .render({"post": post.fields, "view": view})
  24. def get_child_posts_html(post, view):
  25. posts = webnotes.conn.sql("""select p.*, pr.user_image, pr.first_name, pr.last_name
  26. from tabPost p, tabProfile pr
  27. where p.parent_post=%s and pr.name = p.owner
  28. order by p.creation asc""", (post.name,), as_dict=True)
  29. return webnotes.get_template("templates/includes/post_list.html")\
  30. .render({
  31. "posts": posts,
  32. "parent_post": post.name,
  33. "view": view
  34. })