def get_context(self, context): context.show_sidebar=True from frappe.templates.pages.list import get_context as get_list_context frappe.local.form_dict.is_web_form = 1 context.params = frappe.form_dict logged_in = frappe.session.user != "Guest" # check permissions if not logged_in and frappe.form_dict.name: frappe.throw(_("You need to be logged in to access this {0}.").format(self.doc_type), frappe.PermissionError) if frappe.form_dict.name and not has_web_form_permission(self.doc_type, frappe.form_dict.name): frappe.throw(_("You don't have the permissions to access this document"), frappe.PermissionError) if self.is_standard: self.use_meta_fields() if self.login_required and logged_in: if self.allow_edit: if self.allow_multiple: if not context.params.name and not context.params.new: frappe.form_dict.doctype = self.doc_type get_list_context(context) context.is_list = True else: name = frappe.db.get_value(self.doc_type, {"owner": frappe.session.user}, "name") if name: frappe.form_dict.name = name else: # only a single doc allowed and no existing doc, hence new frappe.form_dict.new = 1 # always render new form if login is not required or doesn't allow editing existing ones if not self.login_required or not self.allow_edit: frappe.form_dict.new = 1 if frappe.form_dict.name or frappe.form_dict.new: context.layout = self.get_layout() context.parents = [{"name": self.get_route(), "title": self.title }] if frappe.form_dict.name: context.doc = frappe.get_doc(self.doc_type, frappe.form_dict.name) context.title = context.doc.get(context.doc.meta.get_title_field()) context.doc.add_seen() context.reference_doctype = context.doc.doctype context.reference_name = context.doc.name if self.allow_comments and frappe.form_dict.name: context.comment_list = get_comment_list(context.doc.doctype, context.doc.name) context.parents = self.get_parents(context) context.types = [f.fieldtype for f in self.web_form_fields] if context.success_message: context.success_message = context.success_message.replace("\n", "<br>").replace("'", "\'") self.set_back_to_link(context)
def get_context(self, context): # this is for double precaution. usually it wont reach this code if not published if not cint(self.published): raise Exception, "This blog has not been published yet!" # temp fields context.full_name = get_fullname(self.owner) context.updated = global_date_format(self.published_on) if self.blogger: context.blogger_info = frappe.get_doc("Blogger", self.blogger).as_dict() context.description = self.blog_intro or self.content[:140] context.metatags = { "name": self.title, "description": context.description, } image = find_first_image(self.content) if image: context.metatags["image"] = image context.categories = frappe.db.sql_list("""select name from `tabBlog Category` order by name""") context.comment_list = get_comment_list(self.doctype, self.name) return context
def load_document(self, context): '''Load document `doc` and `layout` properties for template''' if frappe.form_dict.name or frappe.form_dict.new: context.layout = self.get_layout() context.parents = [{"route": self.route, "label": _(self.title)}] if frappe.form_dict.name: context.doc = frappe.get_doc(self.doc_type, frappe.form_dict.name) context.title = context.doc.get(context.doc.meta.get_title_field()) context.doc.add_seen() context.reference_doctype = context.doc.doctype context.reference_name = context.doc.name if self.show_attachments: context.attachments = frappe.get_all( 'File', filters={ "attached_to_name": context.reference_name, "attached_to_doctype": context.reference_doctype, "is_private": 0 }, fields=['file_name', 'file_url', 'file_size']) if self.allow_comments: context.comment_list = get_comment_list( context.doc.doctype, context.doc.name)
def get_context(self, context): if context.main_section == None: context.main_section = '' # if static page, get static content if context.slideshow: context.update(get_slideshow(self)) if self.enable_comments: context.comment_list = get_comment_list(self.doctype, self.name) context.update({ "style": self.css or "", "script": self.javascript or "", "header": self.header, "title": self.title, "text_align": self.text_align, }) if self.description: context.setdefault("metatags", {})["description"] = self.description if not self.show_title: context["no_header"] = 1 if self.show_sidebar and self.website_sidebar: context.sidebar_items = frappe.get_all('Website Sidebar Item', filters=dict(parent=self.website_sidebar), fields=['title', 'route', '`group`'], order_by='idx asc') self.set_metatags(context) self.set_breadcrumbs(context) self.set_title_and_header(context) return context
def get_context(self, context): context.update(get_fullname_and_avatar(self.owner)) context.comment_list = get_comment_list(self.doctype, self.name) if frappe.session.user == self.owner: context.bids = frappe.get_all("Frappe Job Bid", fields=[ "status, " "name", "frappe_partner", "creation", "frappe_partner_title" ], filters={"frappe_job": self.name}, order_by="creation asc") if self.status == "Assigned": context.bid = [ b for b in context.bids if b.status == 'Accepted' ][0].name elif frappe.session.user != "Guest": context.bid = frappe.db.get_value("Frappe Job Bid", { "owner": frappe.session.user, "frappe_job": self.name }) if self.frappe_partner: context.frappe_partner_name, context.frappe_partner_route = \ frappe.db.get_value("Frappe Partner", self.frappe_partner, ["partner_name", "page_name"])
def get_context(self, context): paid_backers = get_paid_backers(self.bounty_backer) no_of_backers = len(paid_backers) if no_of_backers == 0: no_of_backers = 'Be the first to back this bounty' elif no_of_backers == 1: no_of_backers = str(no_of_backers) + ' backer' else: no_of_backers = str(no_of_backers) + ' backers' bounty_left = self.goal - self.bounty_collected if bounty_left > (self.goal * 0.1) or bounty_left < 0: bounty_left = self.goal * 0.1 # edit permission can_edit = self.owner == frappe.session.user context.no_cache = True context.no_breadcrumbs = False context.days_to_go = date_diff(self.end_date, nowdate()) context.paid_backers = ", ".join([backer.full_name or backer.user for backer in paid_backers]) context.no_of_backers = no_of_backers context.fmt_money = fmt_money context.bounty_left = bounty_left context.comment_list = get_comment_list(self.doctype, self.name) context.can_edit = can_edit
def get_context(self, context): # this is for double precaution. usually it wont reach this code if not published if not cint(self.published): raise Exception, "This blog has not been published yet!" # temp fields context.full_name = get_fullname(self.owner) context.updated = global_date_format(self.published_on) if self.blogger: context.blogger_info = frappe.get_doc("Blogger", self.blogger).as_dict() context.description = self.blog_intro or self.content[:140] context.metatags = { "name": self.title, "description": context.description, } image = find_first_image(self.content) if image: context.metatags["image"] = image context.categories = frappe.db.sql_list("""select name from `tabBlog Category` order by name""") context.comment_list = get_comment_list(self.doctype, self.name) context.children = get_children() return context
def get_context(self, context): # this is for double precaution. usually it wont reach this code if not published if not cint(self.published): raise Exception, "This blog has not been published yet!" # temp fields context.full_name = get_fullname(self.owner) context.updated = global_date_format(self.published_on) if self.blogger: context.blogger_info = frappe.get_doc("Blogger", self.blogger).as_dict() context.description = self.blog_intro or self.content[:140] context.metatags = { "name": self.title, "description": context.description, } if "<!-- markdown -->" in context.content: context.content = markdown(context.content) image = find_first_image(self.content) if image: context.metatags["image"] = image context.comment_list = get_comment_list(self.doctype, self.name) context.children = get_children() category = frappe.db.get_value("Blog Category", context.doc.blog_category, ["title", "page_name"], as_dict=1) context.parents = [{"title": category.title, "name": "blog/{0}".format(category.page_name)}]
def get_context(self, context): # if static page, get static content if context.slideshow: context.update(get_slideshow(self)) if self.enable_comments: context.comment_list = get_comment_list(self.doctype, self.name) if self.template_path: # render dynamic context (if .py file exists) context = self.get_dynamic_context(frappe._dict(context)) # load content from template get_static_content(self, context) else: context.update({ "style": self.css or "", "script": self.javascript or "" }) self.set_metatags(context) if not context.header: context.header = self.title # for sidebar context.children = self.get_children() return context
def get_context(self, context): if context.slideshow: context.update(get_slideshow(self)) if self.enable_comments: context.comment_list = get_comment_list(self.doctype, self.name) context.update({ "style": self.css or "", "script": self.javascript or "" }) if "<!-- render-jinja -->" in self.main_section: context["main_section"] = frappe.render_template( self.main_section, { "doc": self, "frappe": frappe }) context["no_cache"] = 1 context.metatags = { "name": self.title, "description": self.description or (self.main_section or "")[:150] } image = find_first_image(self.main_section or "") if image: context.metatags["image"] = image if not context.header: context.header = self.title return context
def get_context(self, context): if context.main_section == None: context.main_section = '' # if static page, get static content if context.slideshow: context.update(get_slideshow(self)) if self.enable_comments: context.comment_list = get_comment_list(self.doctype, self.name) context.update({ "style": self.css or "", "script": self.javascript or "", "header": self.header, "title": self.title, "text_align": self.text_align, }) if self.description: context.setdefault("metatags", {})["description"] = self.description if not self.show_title: context["no_header"] = 1 self.set_metatags(context) self.set_breadcrumbs(context) self.set_title_and_header(context) return context
def get_context(self, context): # if static page, get static content if context.slideshow: context.update(get_slideshow(self)) if self.enable_comments: context.comment_list = get_comment_list(self.doctype, self.name) context.update({ "style": self.css or "", "script": self.javascript or "", "header": self.header, "title": self.title, "text_align": self.text_align, }) if self.description: context.setdefault("metatags", {})["description"] = self.description if not self.show_title: context["no_header"] = 1 self.set_metatags(context) self.set_breadcrumbs(context) self.set_title_and_header(context) return context
def get_context(self, context): context.params = frappe.form_dict if self.login_required and frappe.session.user != "Guest": if self.allow_edit: if self.allow_multiple: if not context.params.name and not context.params.new: frappe.form_dict.doctype = self.doc_type get_list_context(context) context.is_list = True else: name = frappe.db.get_value(self.doc_type, {"owner": frappe.session.user}, "name") if name: frappe.form_dict.name = name if frappe.form_dict.name or frappe.form_dict.new: context.layout = self.get_layout() context.parents = [{"name": self.get_route(), "title": self.title }] if frappe.form_dict.name: context.doc = frappe.get_doc(self.doc_type, frappe.form_dict.name) context.title = context.doc.get(context.doc.meta.get_title_field()) context.comment_doctype = context.doc.doctype context.comment_docname = context.doc.name if self.allow_comments and frappe.form_dict.name: context.comment_list = get_comment_list(context.doc.doctype, context.doc.name) context.types = [f.fieldtype for f in self.web_form_fields] return context
def get_context(self, context): context.main_section = get_html_content_based_on_type( self, 'main_section', self.content_type) context.source_content_type = self.content_type self.render_dynamic(context) # if static page, get static content if context.slideshow: context.update(get_slideshow(self)) if self.enable_comments: context.comment_list = get_comment_list(self.doctype, self.name) context.update({ "style": self.css or "", "script": self.javascript or "", "header": self.header, "title": self.title, "text_align": self.text_align, }) if not self.show_title: context["no_header"] = 1 self.set_metatags(context) self.set_breadcrumbs(context) self.set_title_and_header(context) self.set_page_blocks(context) return context
def get_context(self, context): from frappe.templates.pages.list import get_context as get_list_context frappe.local.form_dict.is_web_form = 1 context.params = frappe.form_dict logged_in = frappe.session.user != "Guest" # check permissions if not logged_in and frappe.form_dict.name: frappe.throw( _("You need to be logged in to access this {0}.").format( self.doc_type), frappe.PermissionError) if frappe.form_dict.name and not has_web_form_permission( self.doc_type, frappe.form_dict.name): frappe.throw( _("You don't have the permissions to access this document"), frappe.PermissionError) if self.login_required and logged_in: if self.allow_edit: if self.allow_multiple: if not context.params.name and not context.params.new: frappe.form_dict.doctype = self.doc_type get_list_context(context) context.is_list = True else: name = frappe.db.get_value(self.doc_type, {"owner": frappe.session.user}, "name") if name: frappe.form_dict.name = name else: # only a single doc allowed and no existing doc, hence new frappe.form_dict.new = 1 # always render new form if login is not required or doesn't allow editing existing ones if not self.login_required or not self.allow_edit: frappe.form_dict.new = 1 if frappe.form_dict.name or frappe.form_dict.new: context.layout = self.get_layout() context.parents = [{"name": self.get_route(), "title": self.title}] if frappe.form_dict.name: context.doc = frappe.get_doc(self.doc_type, frappe.form_dict.name) context.title = context.doc.get(context.doc.meta.get_title_field()) context.comment_doctype = context.doc.doctype context.comment_docname = context.doc.name if self.allow_comments and frappe.form_dict.name: context.comment_list = get_comment_list(context.doc.doctype, context.doc.name) context.parents = self.get_parents(context) context.types = [f.fieldtype for f in self.web_form_fields] return context
def get_context(self, context): if is_markdown(context.content): context.content = markdown(context.content) context.login_required = True context.level_class = get_level_class(self.level) context.comment_list = get_comment_list(self.doctype, self.name) context.children = get_category_sidebar() context.parents = self.get_parents(context)
def get_context(self, context): if is_markdown(context.content): context.content = markdown2.markdown(context.content) context.login_required = True context.level_class = get_level_class(self.level) context.comment_list = get_comment_list(self.doctype, self.name) context.children = get_category_sidebar() context.parents = self.get_parents(context)
def get_context(context): context.accounts = frappe.get_all("Account", filters={"company": frappe.form_dict.company}, fields=["account_name", "name", "is_group", "parent_account", "account_type", "company", "root_type", "tax_rate"], order_by="lft asc") context.stars = frappe.db.get_value("Company", frappe.form_dict.company, "stars") context.comment_list = get_comment_list("Company", frappe.form_dict.company) context.reference_doctype = "Company" context.reference_name = frappe.form_dict.company
def get_context(self, context): # this is for double precaution. usually it wont reach this code if not published if not cint(self.published): raise Exception("This blog has not been published yet!") # temp fields context.full_name = get_fullname(self.owner) context.updated = global_date_format(self.published_on) if self.blogger: context.blogger_info = frappe.get_doc("Blogger", self.blogger).as_dict() context.description = self.blog_intro or self.content[:140] context.metatags = { "name": self.title, "description": context.description, } if "<!-- markdown -->" in context.content: context.content = markdown(context.content) blog_settings = frappe.get_doc('Blog Settings', 'Blog Settings') context.enable_comments = blog_settings.enable_comments context.enable_blogger_info = blog_settings.enable_blogger_info image = find_first_image(self.content) if image: context.metatags["image"] = image context.comment_list = get_comment_list(self.doctype, self.name) if not context.comment_list: context.comment_text = _('No comments yet') else: if (len(context.comment_list)) == 1: context.comment_text = _('1 comment') else: context.comment_text = _('{0} comments').format( len(context.comment_list)) context.category = frappe.db.get_value("Blog Category", context.doc.blog_category, ["title", "route"], as_dict=1) context.parents = [{ "name": _("Home"), "route": "/" }, { "name": "Blog", "route": "/blog" }, { "label": context.category.title, "route": context.category.route }]
def get_context(self, context): if is_markdown(context.content): context.content = markdown(context.content) context.login_required = True context.category = frappe.get_doc("Help Category", self.category) context.level_class = get_level_class(self.level) context.comment_list = get_comment_list(self.doctype, self.name) context.show_sidebar = True context.sidebar_items = get_sidebar_items() context.parents = self.get_parents(context)
def get_context(context): context.accounts = frappe.get_all("Account", filters={"company": frappe.form_dict.company}, fields=["account_name", "name", "is_group", "parent_account", "account_type", "company", "root_type", "tax_rate"], order_by="lft asc") context.stars = frappe.db.get_value("Company", frappe.form_dict.company, "stars") context.comment_list = get_comment_list("Company", frappe.form_dict.company) context.reference_doctype = "Company" context.reference_name = frappe.form_dict.company context.no_cache = True
def get_context(self, context): if is_markdown(context.content): context.content = markdown(context.content) context.login_required = True context.category = frappe.get_doc('Help Category', self.category) context.level_class = get_level_class(self.level) context.comment_list = get_comment_list(self.doctype, self.name) context.show_sidebar = True context.sidebar_items = get_sidebar_items() context.parents = self.get_parents(context)
def load_comments(self, context): context.comment_list = get_comment_list(self.doctype, self.name) if not context.comment_list: context.comment_text = _('No comments yet') else: if(len(context.comment_list)) == 1: context.comment_text = _('1 comment') else: context.comment_text = _('{0} comments').format(len(context.comment_list))
def get_context(self, context): # if static page, get static content if context.slideshow: context.update(get_slideshow(self)) if self.enable_comments: context.comment_list = get_comment_list(self.doctype, self.name) # for sidebar and breadcrumbs context.children = self.get_children() context.parents = self.get_parents(context) if self.template_path: # render dynamic context (if .py file exists) # get absolute template path considering first fragment as app name split_path = self.template_path.split(os.sep) self.template_path = os.path.join( frappe.get_app_path(split_path[0]), *split_path[1:]) context = self.get_dynamic_context(frappe._dict(context)) # load content from template self.get_static_content(context) else: context.update({ "style": self.css or "", "script": self.javascript or "", "header": self.header, "title": self.title, "text_align": self.text_align, }) if self.description: context.setdefault("metatags", {})["description"] = self.description if not self.show_title: context["no_header"] = 1 self.set_metatags(context) self.set_breadcrumbs(context) self.set_title_and_header(context) self.add_index(context) return context
def get_context(self, context): # if static page, get static content if context.slideshow: context.update(get_slideshow(self)) if self.enable_comments: context.comment_list = get_comment_list(self.doctype, self.name) # for sidebar and breadcrumbs context.children = self.get_children() context.parents = self.get_parents(context) if self.template_path: # render dynamic context (if .py file exists) # get absolute template path considering first fragment as app name if not self.template_path.startswith(os.sep): split_path = self.template_path.split(os.sep) self.template_path = os.path.join(frappe.get_app_path(split_path[0]), *split_path[1:]) context = self.get_dynamic_context(frappe._dict(context)) # load content from template self.get_static_content(context) else: context.update({ "style": self.css or "", "script": self.javascript or "", "header": self.header, "title": self.title, "text_align": self.text_align, }) if self.description: context.setdefault("metatags", {})["description"] = self.description if not self.show_title: context["no_header"] = 1 self.set_metatags(context) self.set_breadcrumbs(context) self.set_title_and_header(context) self.add_index(context) return context
def get_context(self, context): from frappe.templates.pages.list import get_context as get_list_context frappe.local.form_dict.is_web_form = 1 context.params = frappe.form_dict logged_in = frappe.session.user != "Guest" # check permissions if not logged_in and frappe.form_dict.name: frappe.throw(_("You need to be logged in to access this {0}.").format(self.doc_type), frappe.PermissionError) if frappe.form_dict.name and not has_web_form_permission(self.doc_type, frappe.form_dict.name): frappe.throw(_("You don't have the permissions to access this document"), frappe.PermissionError) if self.login_required and logged_in: if self.allow_edit: if self.allow_multiple: if not context.params.name and not context.params.new: frappe.form_dict.doctype = self.doc_type get_list_context(context) context.is_list = True else: name = frappe.db.get_value(self.doc_type, {"owner": frappe.session.user}, "name") if name: frappe.form_dict.name = name # always render new form if login is not required or doesn't allow editing existing ones if not self.login_required or not self.allow_edit: frappe.form_dict.new = 1 if frappe.form_dict.name or frappe.form_dict.new: context.layout = self.get_layout() context.parents = [{"name": self.get_route(), "title": self.title }] if frappe.form_dict.name: context.doc = frappe.get_doc(self.doc_type, frappe.form_dict.name) context.title = context.doc.get(context.doc.meta.get_title_field()) context.comment_doctype = context.doc.doctype context.comment_docname = context.doc.name if self.allow_comments and frappe.form_dict.name: context.comment_list = get_comment_list(context.doc.doctype, context.doc.name) context.types = [f.fieldtype for f in self.web_form_fields] return context
def load_document(self, context): '''Load document `doc` and `layout` properties for template''' if frappe.form_dict.name or frappe.form_dict.new: context.layout = self.get_layout() context.parents = [{"route": self.route, "title": self.title}] if frappe.form_dict.name: context.doc = frappe.get_doc(self.doc_type, frappe.form_dict.name) context.title = context.doc.get(context.doc.meta.get_title_field()) context.doc.add_seen() context.reference_doctype = context.doc.doctype context.reference_name = context.doc.name if self.allow_comments: context.comment_list = get_comment_list( context.doc.doctype, context.doc.name)
def load_document(self, context): '''Load document `doc` and `layout` properties for template''' if frappe.form_dict.name or frappe.form_dict.new: context.layout = self.get_layout() context.parents = [{"route": self.route, "label": _(self.title) }] if frappe.form_dict.name: context.doc = frappe.get_doc(self.doc_type, frappe.form_dict.name) context.title = context.doc.get(context.doc.meta.get_title_field()) context.doc.add_seen() context.reference_doctype = context.doc.doctype context.reference_name = context.doc.name if self.allow_comments: context.comment_list = get_comment_list(context.doc.doctype, context.doc.name)
def get_context(self, context): context.update(get_fullname_and_avatar(self.owner)) context.comment_list = get_comment_list(self.doctype, self.name) if frappe.session.user == self.owner: context.bids = frappe.get_all("Frappe Job Bid", fields=["status, ""name", "frappe_partner", "creation", "frappe_partner_title"], filters={"frappe_job": self.name}, order_by="creation asc") if self.status == "Assigned": context.bid = [b for b in context.bids if b.status=='Accepted'][0].name elif frappe.session.user != "Guest": context.bid = frappe.db.get_value("Frappe Job Bid", {"owner": frappe.session.user, "frappe_job": self.name}) if self.frappe_partner: context.frappe_partner_name, context.frappe_partner_route = \ frappe.db.get_value("Frappe Partner", self.frappe_partner, ["partner_name", "page_name"])
def get_context(self, context): # this is for double precaution. usually it wont reach this code if not published if not cint(self.published): raise Exception("This blog has not been published yet!") # temp fields context.full_name = get_fullname(self.owner) context.updated = global_date_format(self.published_on) if self.blogger: context.blogger_info = frappe.get_doc("Blogger", self.blogger).as_dict() context.description = self.blog_intro or self.content[:140] context.metatags = { "name": self.title, "description": context.description, } if "<!-- markdown -->" in context.content: context.content = markdown(context.content) image = find_first_image(self.content) if image: context.metatags["image"] = image context.comment_list = get_comment_list(self.doctype, self.name) if not context.comment_list: context.comment_text = _('No comments yet') else: if(len(context.comment_list)) == 1: context.comment_text = _('1 comment') else: context.comment_text = _('{0} comments').format(len(context.comment_list)) context.category = frappe.db.get_value("Blog Category", context.doc.blog_category, ["title", "route"], as_dict=1) context.parents = [{"name": _("Home"), "route":"/"}, {"name": "Blog", "route": "/blog"}, {"label": context.category.title, "route":context.category.route}]
def get_context(self, context): # if static page, get static content if context.slideshow: context.update(get_slideshow(self)) if self.enable_comments: context.comment_list = get_comment_list(self.doctype, self.name) # for sidebar and breadcrumbs context.children = self.get_children() context.parents = self.get_parents(context) if self.template_path: # render dynamic context (if .py file exists) context = self.get_dynamic_context(frappe._dict(context)) # load content from template self.get_static_content(context) else: context.update({ "style": self.css or "", "script": self.javascript or "", "header": self.header, "title": self.title, "text_align": self.text_align, }) if self.description: context.setdefault("metatags", {})["description"] = self.description if not self.show_title: context["no_header"] = 1 self.set_metatags(context) return context
def get_context(self, context): context.main_section = get_html_content_based_on_type( self, 'main_section', self.content_type) context.source_content_type = self.content_type context.title = self.title if self.context_script: _locals = dict(context=frappe._dict()) safe_exec(self.context_script, None, _locals) context.update(_locals['context']) self.render_dynamic(context) # if static page, get static content if context.slideshow: context.update(get_slideshow(self)) if self.enable_comments: context.comment_list = get_comment_list(self.doctype, self.name) context.guest_allowed = True context.update({ "style": self.css or "", "script": self.javascript or "", "header": self.header, "text_align": self.text_align, }) if not self.show_title: context["no_header"] = 1 self.set_metatags(context) self.set_breadcrumbs(context) self.set_title_and_header(context) self.set_page_blocks(context) return context
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals import frappe from frappe.website.utils import get_comment_list def get_context(context): context.doc = frappe.get_doc('Discussion', frappe.form_dict.discussion) portal_items = [{'reference_doctype': u'Topic', 'route': u"/topic?course=" + str(context.doc.course), 'show_always': 0L, 'title': u'Topics'}, {'reference_doctype': u'Discussion', 'route': u"/discussion?course=" + str(context.doc.course), 'show_always': 0L, 'title': u'Discussions'}, ] context.show_sidebar = True context.sidebar_items = portal_items context.no_cache = 1 context.doc.has_permission('read') context.sidebar_title = context.doc.course context.reference_doctype = "Discussion" context.reference_name = context.doc.name context.comment_list = get_comment_list(context.doc.doctype,context.doc.name)
def get_context(self, context): context.job = frappe.get_doc("Frappe Job", self.frappe_job) context.partner = frappe.get_doc("Frappe Partner", self.frappe_partner) context.comment_list = get_comment_list(self.doctype, self.name)
def get_context(self, context): context.comment_list = get_comment_list(self.doctype, self.name) if not context.comment_list: context.comment_text = _('No comments yet') else: if(len(context.comment_list)) == 1: context.comment_text = _('1 comment') else: context.comment_text = _('{0} comments').format(len(context.comment_list)) context.user = frappe.session.user #meta #--------------- context.head_title = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'head_title' AND doctype = 'Head Settings'", as_dict=True)[0].value context.head_favicon = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'head_favicon' AND doctype = 'Head Settings'", as_dict=True)[0].value context.meta_keywords = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'meta_keywords' AND doctype = 'Head Settings'", as_dict=True)[0].value context.meta_description = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'meta_description' AND doctype = 'Head Settings'", as_dict=True)[0].value context.meta_page_topic = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'meta_page_topic' AND doctype = 'Head Settings'", as_dict=True)[0].value context.meta_robots = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'meta_robots' AND doctype = 'Head Settings'", as_dict=True)[0].value context.meta_revisit_after = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'meta_revisit_after' AND doctype = 'Head Settings'", as_dict=True)[0].value context.meta_author = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'meta_author' AND doctype = 'Head Settings'", as_dict=True)[0].value context.meta_publisher = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'meta_publisher' AND doctype = 'Head Settings'", as_dict=True)[0].value context.meta_copyright = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'meta_copyright' AND doctype = 'Head Settings'", as_dict=True)[0].value context.meta_company = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'meta_company' AND doctype = 'Head Settings'", as_dict=True)[0].value #body #--------------- # -->Background-Image context.bg_img = False if frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'bg_select' AND doctype = 'Body Settings'", as_dict=True)[0].value == "Image": context.bg_img = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'bg_img' AND doctype = 'Body Settings'", as_dict=True)[0].value # -->Background-Color context.bodycolor = False if frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'bg_select' AND doctype = 'Body Settings'", as_dict=True)[0].value == "Color": context.bodycolor = True context.bodycolorcode = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'bg_color' AND doctype = 'Body Settings'", as_dict=True) #google analytics #------------------------- if frappe.db.sql("SELECT value FROM `tabSingles` WHERE field = 'enable' AND doctype = 'Google Analytics'", as_dict=True)[0].value: context.google_enable = int(frappe.db.sql("SELECT value FROM `tabSingles` WHERE field = 'enable' AND doctype = 'Google Analytics'", as_dict=True)[0].value) context.google_id = frappe.db.sql("SELECT value FROM `tabSingles` WHERE field = 'id' AND doctype = 'Google Analytics'", as_dict=True)[0].value #navbar #--------------------- context.navbar = True context.nav_bg_color = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'nav_bg_color' AND doctype = 'Navbar'", as_dict=True)[0].value context.nav_txt_color = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'nav_txt_color' AND doctype = 'Navbar'", as_dict=True)[0].value context.navlinks = frappe.db.sql("SELECT title, link FROM `tabNavbar Item` WHERE parent = 'Navbar' ORDER BY idx ASC", as_dict=True) context.nav_logo = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'nav_logo' AND doctype = 'Navbar'", as_dict=True)[0].value #footer #------------------- context.footer = True context.footer_bg_color = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'footer_bg_color' AND doctype = 'PageMaster Footer'", as_dict=True)[0].value context.footer_txt_color = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'footer_txt_color' AND doctype = 'PageMaster Footer'", as_dict=True)[0].value context.txt = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'txt' AND doctype = 'PageMaster Footer'", as_dict=True)[0].value context.link_title = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'link_title' AND doctype = 'PageMaster Footer'", as_dict=True)[0].value context.link = frappe.db.sql("SELECT value FROM tabSingles WHERE field = 'link' AND doctype = 'PageMaster Footer'", as_dict=True)[0].value
def get_context(self, context): context.show_sidebar = True from frappe.www.list import get_context as get_list_context frappe.form_dict.is_web_form = 1 logged_in = frappe.session.user != "Guest" args, delimeter = make_route_string(frappe.form_dict) context.args = args context.delimeter = delimeter # check permissions if not logged_in and frappe.form_dict.name: frappe.throw( _("You need to be logged in to access this {0}.").format( self.doc_type), frappe.PermissionError) if frappe.form_dict.name and not has_web_form_permission( self.doc_type, frappe.form_dict.name): frappe.throw( _("You don't have the permissions to access this document"), frappe.PermissionError) if self.is_standard: self.use_meta_fields() if self.login_required and logged_in: if self.allow_edit: if self.allow_multiple: if not frappe.form_dict.name and not frappe.form_dict.new: frappe.form_dict.doctype = self.doc_type get_list_context(context) context.is_list = True else: name = frappe.db.get_value(self.doc_type, {"owner": frappe.session.user}, "name") if name: frappe.form_dict.name = name else: # only a single doc allowed and no existing doc, hence new frappe.form_dict.new = 1 # always render new form if login is not required or doesn't allow editing existing ones if not self.login_required or not self.allow_edit: frappe.form_dict.new = 1 if frappe.form_dict.name or frappe.form_dict.new: context.layout = self.get_layout() context.parents = [{"route": self.route, "title": self.title}] if frappe.form_dict.name: context.doc = frappe.get_doc(self.doc_type, frappe.form_dict.name) context.title = context.doc.get(context.doc.meta.get_title_field()) context.doc.add_seen() context.reference_doctype = context.doc.doctype context.reference_name = context.doc.name if self.allow_comments and frappe.form_dict.name: context.comment_list = get_comment_list(context.doc.doctype, context.doc.name) context.parents = self.get_parents(context) context.types = [f.fieldtype for f in self.web_form_fields] if context.success_message: context.success_message = context.success_message.replace( "\n", "<br>").replace("'", "\'") self.add_custom_context_and_script(context)