frappe/frappe#478, removed instances of .fields
This commit is contained in:
parent
2aefa2e135
commit
081739b10a
18 changed files with 29 additions and 31 deletions
|
|
@ -3,7 +3,6 @@ include requirements.txt
|
|||
include *.json
|
||||
include *.md
|
||||
include *.py
|
||||
include *.txt
|
||||
recursive-include frappe *.css
|
||||
recursive-include frappe *.dat
|
||||
recursive-include frappe *.eot
|
||||
|
|
@ -22,5 +21,4 @@ recursive-include frappe *.swf
|
|||
recursive-include frappe *.ttf
|
||||
recursive-include frappe *.woff
|
||||
recursive-include frappe *.xml
|
||||
recursive-include frappe *.txt
|
||||
recursive-exclude * *.pyc
|
||||
|
|
@ -21,10 +21,10 @@ def get_bootinfo():
|
|||
get_user(bootinfo)
|
||||
|
||||
# control panel
|
||||
cp = frappe.model.getsingle('Control Panel')
|
||||
cp = frappe.get_doc('Control Panel')
|
||||
|
||||
# system info
|
||||
bootinfo['control_panel'] = frappe._dict(cp.copy())
|
||||
bootinfo['control_panel'] = frappe._dict(cp.as_dict())
|
||||
bootinfo['sysdefaults'] = frappe.defaults.get_defaults()
|
||||
bootinfo['server_date'] = frappe.utils.nowdate()
|
||||
bootinfo["send_print_in_body_and_attachment"] = frappe.db.get_value("Outgoing Email Settings",
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ def get(doctype, name=None, filters=None):
|
|||
name = frappe.db.get_value(doctype, json.loads(filters))
|
||||
if not name:
|
||||
raise Exception, "No document found for given filters"
|
||||
return [d.fields for d in frappe.get_doc(doctype, name).doclist]
|
||||
return frappe.get_doc(doctype, name).as_dict()
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_value(doctype, fieldname, filters=None, as_dict=True, debug=False):
|
||||
|
|
@ -41,7 +41,7 @@ def set_value(doctype, name, fieldname, value):
|
|||
|
||||
bean.save()
|
||||
|
||||
return [d.fields for d in bean.doclist]
|
||||
return bean.as_dict()
|
||||
|
||||
@frappe.whitelist()
|
||||
def insert(doclist):
|
||||
|
|
@ -60,7 +60,7 @@ def insert(doclist):
|
|||
return [d]
|
||||
else:
|
||||
bean = frappe.get_doc(doclist).insert()
|
||||
return [d.fields for d in bean.doclist]
|
||||
return bean.as_dict()
|
||||
|
||||
@frappe.whitelist()
|
||||
def save(doclist):
|
||||
|
|
@ -68,7 +68,7 @@ def save(doclist):
|
|||
doclist = json.loads(doclist)
|
||||
|
||||
bean = frappe.get_doc(doclist).save()
|
||||
return [d.fields for d in bean.doclist]
|
||||
return bean.as_dict()
|
||||
|
||||
@frappe.whitelist()
|
||||
def rename_doc(doctype, old_name, new_name, merge=False):
|
||||
|
|
@ -83,14 +83,14 @@ def submit(doclist):
|
|||
doclistobj = frappe.get_doc(doclist)
|
||||
doclistobj.submit()
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
return doclist.as_dict()
|
||||
|
||||
@frappe.whitelist()
|
||||
def cancel(doctype, name):
|
||||
wrapper = frappe.get_doc(doctype, name)
|
||||
wrapper.cancel()
|
||||
|
||||
return [d.fields for d in wrapper.doclist]
|
||||
return wrapper.as_dict()
|
||||
|
||||
@frappe.whitelist()
|
||||
def delete(doctype, name):
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ class CustomizeForm(Document):
|
|||
"""
|
||||
# Check if property has changed compared to when it was loaded
|
||||
if self.has_property_changed(ref_d, new_d, prop):
|
||||
#frappe.msgprint("new: " + str(new_d.fields[prop]) + " | old: " + str(ref_d.fields[prop]))
|
||||
#frappe.msgprint("new: " + str(new_d.get(prop)) + " | old: " + str(ref_d.get(prop)))
|
||||
# Check if the new property is same as that in original doctype
|
||||
# If yes, we need to delete the property setter entry
|
||||
for dt_d in dt_doclist:
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class NotificationCount(Document):
|
|||
|
||||
@frappe.whitelist()
|
||||
def get_notifications():
|
||||
if frappe.in_install_app:
|
||||
if frappe.flags.in_install_app:
|
||||
return
|
||||
config = get_notification_config()
|
||||
can_read = frappe.user.get_can_read()
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class PropertySetter(Document):
|
|||
|
||||
def validate(self):
|
||||
"""delete other property setters on this, if this is new"""
|
||||
if self.fields['__islocal']:
|
||||
if self.get('__islocal'):
|
||||
frappe.db.sql("""delete from `tabProperty Setter` where
|
||||
doctype_or_field = %(doctype_or_field)s
|
||||
and doc_type = %(doc_type)s
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ def upload(rows = None, submit_after_import=None, ignore_encoding_errors=False,
|
|||
if parenttype:
|
||||
# child doc
|
||||
doc = frappe.get_doc(doctype)
|
||||
doc.fields.update(doclist[0])
|
||||
doc.update(doclist[0])
|
||||
if parenttype:
|
||||
doc.parenttype = parenttype
|
||||
doc.parentfield = parentfield
|
||||
|
|
@ -498,7 +498,7 @@ def export_json(doctype, name, path):
|
|||
if not name or name=="-":
|
||||
name = doctype
|
||||
with open(path, "w") as outfile:
|
||||
doclist = [d.fields for d in frappe.get_doc(doctype, name).doclist]
|
||||
doclist = frappe.get_doc(doctype, name).as_dict()
|
||||
for d in doclist:
|
||||
if d.get("parent"):
|
||||
del d["parent"]
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ def copytables(srctype, src, srcfield, tartype, tar, tarfield, srcfields, tarfie
|
|||
newrow.idx = d.idx
|
||||
|
||||
for i in range(len(srcfields)):
|
||||
newrow.set(tarfields[i], d.fields[srcfields[i]])
|
||||
newrow.set(tarfields[i], d.get(srcfields[i]))
|
||||
|
||||
l.append(newrow)
|
||||
return l
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ def get_context(context):
|
|||
blog_post.updated = global_date_format(blog_post.published_on)
|
||||
|
||||
if blog_post.blogger:
|
||||
blog_post.blogger_info = frappe.get_doc("Blogger", blog_post.blogger).fields
|
||||
blog_post.blogger_info = frappe.get_doc("Blogger", blog_post.blogger).as_dict()
|
||||
|
||||
blog_post.description = blog_post.blog_intro or blog_post.content[:140]
|
||||
blog_post.meta_description = blog_post.description
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ def build_view_context(context):
|
|||
context.post_list_html = get_post_list_html(context.group.name, context.view.name)
|
||||
|
||||
elif context.view.name == "edit":
|
||||
context.post = frappe.get_doc("Post", frappe.form_dict.name).fields
|
||||
context.post = frappe.get_doc("Post", frappe.form_dict.name).as_dict()
|
||||
|
||||
if context.post.assigned_to:
|
||||
context.user = frappe.get_doc("User", context.post.assigned_to)
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@ from __future__ import unicode_literals
|
|||
import frappe
|
||||
|
||||
def get_context(context):
|
||||
return frappe.get_doc("Blog Settings", "Blog Settings").fields
|
||||
return frappe.get_doc("Blog Settings", "Blog Settings").as_dict()
|
||||
|
|
|
|||
|
|
@ -17,6 +17,6 @@ def get_context(context):
|
|||
"categories": frappe.db.sql_list("select name from `tabBlog Category` order by name")
|
||||
}
|
||||
|
||||
writers_context.update(frappe.get_doc("Blog Settings", "Blog Settings").fields)
|
||||
writers_context.update(frappe.get_doc("Blog Settings", "Blog Settings").as_dict())
|
||||
|
||||
return writers_context
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ def get_post_context(context):
|
|||
def get_parent_post_html(post, context):
|
||||
user = frappe.get_doc("User", post.owner).doc
|
||||
for fieldname in ("first_name", "last_name", "user_image", "location"):
|
||||
post.set(fieldname, user.fields[fieldname])
|
||||
post.set(fieldname, user.get(fieldname))
|
||||
|
||||
return frappe.get_template("templates/includes/inline_post.html")\
|
||||
.render({"post": post.fields, "view": context.view})
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ def import_doc(d, doctype, overwrite, row_idx, submit=False, ignore_links=False)
|
|||
bean.submit()
|
||||
|
||||
return 'Inserted row (#%d) %s' % (row_idx + 1, getlink(doctype,
|
||||
bean.fields['name']))
|
||||
bean.get('name')))
|
||||
|
||||
def getlink(doctype, name):
|
||||
return '<a href="#Form/%(doctype)s/%(name)s">%(name)s</a>' % locals()
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ class DocTypeNestedSet(Document):
|
|||
if not self.nsm_parent_field:
|
||||
self.nsm_parent_field = frappe.scrub(self.doctype) + "_parent"
|
||||
|
||||
parent = self.fields[self.nsm_parent_field]
|
||||
parent = self.get(self.nsm_parent_field)
|
||||
if not parent:
|
||||
msgprint(_("Root ") + self.doctype + _(" cannot be deleted."), raise_exception=1)
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ class DocTypeNestedSet(Document):
|
|||
def before_rename(self, olddn, newdn, merge=False, group_fname="is_group"):
|
||||
if merge:
|
||||
is_group = frappe.db.get_value(self.doctype, newdn, group_fname)
|
||||
if self.fields[group_fname] != is_group:
|
||||
if self.get(group_fname) != is_group:
|
||||
frappe.throw(_("""Merging is only possible between Group-to-Group or
|
||||
Ledger-to-Ledger"""), NestedSetInvalidMergeError)
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ class DocTypeNestedSet(Document):
|
|||
rebuild_tree(self.doctype, parent_field)
|
||||
|
||||
def validate_one_root(self):
|
||||
if not self.fields[self.nsm_parent_field]:
|
||||
if not self.get(self.nsm_parent_field):
|
||||
if frappe.db.sql("""select count(*) from `tab%s` where
|
||||
ifnull(%s, '')=''""" % (self.doctype, self.nsm_parent_field))[0][0] > 1:
|
||||
frappe.throw(_("""Multiple root nodes not allowed."""), NestedSetMultipleRootsError)
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ def get_website_settings():
|
|||
for k in ["banner_html", "brand_html", "copyright", "twitter_share_via",
|
||||
"favicon", "facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
|
||||
"disable_signup"]:
|
||||
if k in settings.fields:
|
||||
if getattr(settings, k, None):
|
||||
context[k] = settings.get(k)
|
||||
|
||||
if not context.get("favicon"):
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ def get_sitemap_options(path):
|
|||
return frappe._dict(sitemap_options)
|
||||
|
||||
def build_sitemap_options(path):
|
||||
sitemap_options = frappe._dict(frappe.get_doc("Website Route", path).fields)
|
||||
sitemap_options = frappe._dict(frappe.get_doc("Website Route", path).as_dict())
|
||||
home_page = get_home_page()
|
||||
|
||||
sitemap_config = frappe.get_doc("Website Template",
|
||||
sitemap_options.get("website_template")).fields
|
||||
sitemap_options.get("website_template"))
|
||||
|
||||
# get sitemap config fields too
|
||||
for fieldname in ("base_template_path", "template_path", "controller",
|
||||
|
|
@ -72,8 +72,8 @@ def set_sidebar_items(sitemap_options, pathname, home_page):
|
|||
where ifnull(t1.parent_website_route,'')=%s
|
||||
and t1.public_read=1
|
||||
and t1.docname = t2.name
|
||||
order by t2.{sort_by} {sort_order}""".format(**website_template.fields),
|
||||
order by t2.{sort_by} {sort_order}""".format(**website_template.as_dict()),
|
||||
pathname, as_dict=True)
|
||||
|
||||
sitemap_options.children = [frappe.get_doc("Website Route", pathname).fields] + sitemap_options.children
|
||||
sitemap_options.children = [frappe.get_doc("Website Route", pathname)] + sitemap_options.children
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ def add_comment(doclist):
|
|||
doclistobj.ignore_permissions = True
|
||||
doclistobj.save()
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
return doclist.as_dict()
|
||||
|
||||
return save(doclist)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue