[fixes] [tests] web forms
This commit is contained in:
parent
19202375c9
commit
2716f4a613
4 changed files with 17 additions and 9 deletions
|
|
@ -11,6 +11,10 @@ from frappe.utils.user import get_enabled_system_users
|
|||
weekdays = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]
|
||||
|
||||
class Event(Document):
|
||||
def get_route(self):
|
||||
"""for test-case"""
|
||||
return "/Event/" + self.name
|
||||
|
||||
def validate(self):
|
||||
if self.starts_on and self.ends_on and self.starts_on > self.ends_on:
|
||||
frappe.msgprint(frappe._("Event end must be after start"), raise_exception=True)
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@
|
|||
</div>
|
||||
{% endfor %}
|
||||
</form>
|
||||
{% if allow_comments -%}
|
||||
{% if allow_comments and not params.new -%}
|
||||
<div class="comments">
|
||||
<br><br>
|
||||
<h3>{{ _("Comments") }}</h3>
|
||||
|
|
|
|||
|
|
@ -60,7 +60,9 @@ def get(doctype, txt=None, limit_start=0, **kwargs):
|
|||
row_template = list_context.row_template or "templates/includes/list/row_template.html"
|
||||
for doc in raw_result:
|
||||
doc.doctype = doctype
|
||||
new_context = { "doc": doc, "meta": meta, "pathname": frappe.local.request.path.strip("/ ") }
|
||||
new_context = { "doc": doc, "meta": meta }
|
||||
if not frappe.flags.in_test:
|
||||
new_context.pathname = frappe.local.request.path.strip("/ ")
|
||||
new_context.update(list_context)
|
||||
rendered_row = frappe.render_template(row_template, new_context, is_path=True)
|
||||
result.append(rendered_row)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class WebForm(WebsiteGenerator):
|
|||
if self.login_required and frappe.session.user != "Guest":
|
||||
if self.allow_edit:
|
||||
if self.allow_multiple:
|
||||
if not context.params.name:
|
||||
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
|
||||
|
|
@ -32,16 +32,18 @@ class WebForm(WebsiteGenerator):
|
|||
if name:
|
||||
frappe.form_dict.name = name
|
||||
|
||||
if frappe.form_dict.name:
|
||||
if frappe.form_dict.name or frappe.form_dict.new:
|
||||
context.layout = self.get_layout()
|
||||
context.doc = frappe.get_doc(self.doc_type, frappe.form_dict.name)
|
||||
context.title = context.doc.get(context.doc.meta.get_title_field())
|
||||
context.parents = [{"name": self.get_route(), "title": self.title }]
|
||||
|
||||
context.comment_doctype = context.doc.doctype
|
||||
context.comment_docname = context.doc.name
|
||||
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())
|
||||
|
||||
if self.allow_comments:
|
||||
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]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue