• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python webnotes.has_permission函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中webnotes.has_permission函数的典型用法代码示例。如果您正苦于以下问题:Python has_permission函数的具体用法?Python has_permission怎么用?Python has_permission使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了has_permission函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_value

def get_value(doctype, fieldname, filters=None, as_dict=True, debug=False):
	if not webnotes.has_permission(doctype):
		webnotes.msgprint("No Permission", raise_exception=True)
		
	if fieldname and fieldname.startswith("["):
		fieldname = json.loads(fieldname)
	return webnotes.conn.get_value(doctype, json.loads(filters), fieldname, as_dict=as_dict, debug=debug)
开发者ID:bindscha,项目名称:wnframework_old,代码行数:7,代码来源:client.py


示例2: save

	def save(self, check_links=1):
		perm_to_check = "write"
		if self.doc.fields.get("__islocal"):
			perm_to_check = "create"
			if not self.doc.owner:
				self.doc.owner = webnotes.session.user
				
		if self.ignore_permissions or webnotes.has_permission(self.doc.doctype, perm_to_check, self.doc):
			self.to_docstatus = 0
			self.prepare_for_save("save")
			if self.doc.fields.get("__islocal"):
				# set name before validate
				self.doc.set_new_name()
				self.run_method('before_insert')
				
			if not self.ignore_validate:
				self.run_method('validate')
			if not self.ignore_mandatory:
				self.check_mandatory()
			self.save_main()
			self.save_children()
			self.run_method('on_update')
		else:
			self.no_permission_to(_(perm_to_check.title()))
		
		return self
开发者ID:ricardomomm,项目名称:wnframework,代码行数:26,代码来源:bean.py


示例3: run

def run(report_name, filters=None):
	report = webnotes.doc("Report", report_name)
	
	if filters and isinstance(filters, basestring):
		filters = json.loads(filters)

	if not webnotes.has_permission(report.ref_doctype, "report"):
		webnotes.msgprint(_("Must have report permission to access this report."), 
			raise_exception=True)
	
	if report.report_type=="Query Report":
		if not report.query:
			webnotes.msgprint(_("Must specify a Query to run"), raise_exception=True)
	
	
		if not report.query.lower().startswith("select"):
			webnotes.msgprint(_("Query must be a SELECT"), raise_exception=True)
		
		result = [list(t) for t in webnotes.conn.sql(report.query, filters)]
		columns = [c[0] for c in webnotes.conn.get_description()]
	else:
		method_name = scrub(webnotes.conn.get_value("DocType", report.ref_doctype, "module")) \
			+ ".report." + scrub(report.name) + "." + scrub(report.name) + ".execute"
		columns, result = webnotes.get_method(method_name)(filters or {})
	
	result = get_filtered_data(report.ref_doctype, columns, result)
	
	if cint(report.add_total_row) and result:
		result = add_total_row(result, columns)
	
	return {
		"result": result,
		"columns": columns
	}
开发者ID:ricardomomm,项目名称:wnframework,代码行数:34,代码来源:query_report.py


示例4: get_events

def get_events(start, end, filters=None):
	from webnotes.widgets.reportview import build_match_conditions
	if not webnotes.has_permission("Task"):
		webnotes.msgprint(_("No Permission"), raise_exception=1)

	conditions = build_match_conditions("Task")
	conditions and (" and " + conditions) or ""
	
	if filters:
		filters = json.loads(filters)
		for key in filters:
			if filters[key]:
				conditions += " and " + key + ' = "' + filters[key].replace('"', '\"') + '"'
	
	data = webnotes.conn.sql("""select name, exp_start_date, exp_end_date, 
		subject, status, project from `tabTask`
		where ((exp_start_date between '%(start)s' and '%(end)s') \
			or (exp_end_date between '%(start)s' and '%(end)s'))
		%(conditions)s""" % {
			"start": start,
			"end": end,
			"conditions": conditions
		}, as_dict=True, update={"allDay": 0})

	return data
开发者ID:cocoy,项目名称:erpnext,代码行数:25,代码来源:task.py


示例5: get_args

def get_args():
    if not webnotes.form_dict.format:
        webnotes.form_dict.format = standard_format
    if not webnotes.form_dict.doctype or not webnotes.form_dict.name:
        return {
            "body": """<h1>Error</h1>
				<p>Parameters doctype, name and format required</p>
				<pre>%s</pre>"""
            % repr(webnotes.form_dict)
        }

    bean = webnotes.bean(webnotes.form_dict.doctype, webnotes.form_dict.name)
    for ptype in ("read", "print"):
        if not webnotes.has_permission(bean.doc.doctype, ptype, bean.doc):
            return {
                "body": """<h1>Error</h1>
					<p>No {ptype} permission</p>""".format(
                    ptype=ptype
                )
            }

    return {
        "body": get_html(bean.doc, bean.doclist),
        "css": get_print_style(webnotes.form_dict.style),
        "comment": webnotes.session.user,
    }
开发者ID:bindscha,项目名称:wnframework_old,代码行数:26,代码来源:print_format.py


示例6: upload

def upload(select_doctype=None, rows=None):
	from webnotes.utils.datautils import read_csv_content_from_uploaded_file
	from webnotes.modules import scrub
	from webnotes.model.rename_doc import rename_doc

	if not select_doctype:
		select_doctype = webnotes.form_dict.select_doctype
		
	if not webnotes.has_permission(select_doctype, "write"):
		raise webnotes.PermissionError

	if not rows:
		rows = read_csv_content_from_uploaded_file()
	if not rows:
		webnotes.msgprint(_("Please select a valid csv file with data."))
		raise Exception
		
	if len(rows) > 500:
		webnotes.msgprint(_("Max 500 rows only."))
		raise Exception
	
	rename_log = []
	for row in rows:
		# if row has some content
		if len(row) > 1 and row[0] and row[1]:
			try:
				if rename_doc(select_doctype, row[0], row[1]):
					rename_log.append(_("Successful: ") + row[0] + " -> " + row[1])
					webnotes.conn.commit()
				else:
					rename_log.append(_("Ignored: ") + row[0] + " -> " + row[1])
			except Exception, e:
				rename_log.append("<span style='color: RED'>" + \
					_("Failed: ") + row[0] + " -> " + row[1] + "</span>")
				rename_log.append("<span style='margin-left: 20px;'>" + repr(e) + "</span>")
开发者ID:BANSALJEE,项目名称:erpnext,代码行数:35,代码来源:rename_tool.py


示例7: run

def run(report_name):
	report = webnotes.doc("Report", report_name)

	if not webnotes.has_permission(report.ref_doctype, "report"):
		webnotes.msgprint(_("Must have report permission to access this report."), 
			raise_exception=True)
	
	if report.report_type=="Query Report":
		if not report.query:
			webnotes.msgprint(_("Must specify a Query to run"), raise_exception=True)
	
	
		if not report.query.lower().startswith("select"):
			webnotes.msgprint(_("Query must be a SELECT"), raise_exception=True)
		
		result = [list(t) for t in webnotes.conn.sql(report.query)]
		columns = [c[0] for c in webnotes.conn.get_description()]
	else:
		from webnotes.modules import scrub
		method_name = scrub(webnotes.conn.get_value("DocType", report.ref_doctype, "module")) \
			+ ".report." + scrub(report.name) + "." + scrub(report.name) + ".execute"
		columns, result = webnotes.get_method(method_name)()
	
	return {
		"result": result,
		"columns": columns
	}
开发者ID:jacara,项目名称:erpclone,代码行数:27,代码来源:query_report.py


示例8: get_mapped_doclist

def get_mapped_doclist(from_doctype, from_docname, table_maps, target_doclist=[], 
		postprocess=None, ignore_permissions=False):
	if isinstance(target_doclist, basestring):
		target_doclist = json.loads(target_doclist)
	
	source = webnotes.bean(from_doctype, from_docname)

	if not ignore_permissions and not webnotes.has_permission(from_doctype, "read", source.doc):
		webnotes.msgprint("No Permission", raise_exception=webnotes.PermissionError)

	source_meta = webnotes.get_doctype(from_doctype)
	target_meta = webnotes.get_doctype(table_maps[from_doctype]["doctype"])
	
	# main
	if target_doclist:
		if isinstance(target_doclist[0], dict):
			target_doc = webnotes.doc(fielddata=target_doclist[0])
		else:
			target_doc = target_doclist[0]
	else:
		target_doc = webnotes.new_doc(table_maps[from_doctype]["doctype"])
	
	map_doc(source.doc, target_doc, table_maps[source.doc.doctype], source_meta, target_meta)
	if target_doclist:
		target_doclist[0] = target_doc
	else:
		target_doclist = [target_doc]
	
	# children
	for source_d in source.doclist[1:]:
		table_map = table_maps.get(source_d.doctype)
		if table_map:
			if "condition" in table_map:
				if not table_map["condition"](source_d):
					continue
			target_doctype = table_map["doctype"]
			parentfield = target_meta.get({
					"parent": target_doc.doctype, 
					"doctype": "DocField",
					"fieldtype": "Table", 
					"options": target_doctype
				})[0].fieldname
			
			if table_map.get("add_if_empty") and row_exists_in_target(parentfield, target_doclist):
				continue
		
			target_d = webnotes.new_doc(target_doctype, target_doc, parentfield)
			map_doc(source_d, target_d, table_map, source_meta, target_meta, source.doclist[0])
			target_doclist.append(target_d)
	
	target_doclist = webnotes.doclist(target_doclist)
	
	if postprocess:
		new_target_doclist = postprocess(source, target_doclist)
		if new_target_doclist:
			target_doclist = new_target_doclist
	
	return target_doclist
开发者ID:frank1638,项目名称:wnframework,代码行数:58,代码来源:mapper.py


示例9: check_permission_and_not_submitted

def check_permission_and_not_submitted(doctype, name):
	# permission
	if webnotes.session.user!="Administrator" and not webnotes.has_permission(doctype, "cancel"):
		webnotes.msgprint(_("User not allowed to delete."), raise_exception=True)

	# check if submitted
	if webnotes.conn.get_value(doctype, name, "docstatus") == 1:
		webnotes.msgprint(_("Submitted Record cannot be deleted")+": "+name+"("+doctype+")",
			raise_exception=True)
开发者ID:alvz,项目名称:wnframework,代码行数:9,代码来源:utils.py


示例10: submit

	def submit(self):
		if webnotes.has_permission(self.doc.doctype, "submit"):
			if self.doc.docstatus != 0:
				webnotes.msgprint("Only draft can be submitted", raise_exception=1)
			self.to_docstatus = 1
			self.save()
			self.run_method('on_submit')
		else:
			webnotes.msgprint("No Permission to Submit", raise_exception=True)
开发者ID:gowrav-vishwakarma,项目名称:wnframework,代码行数:9,代码来源:wrapper.py


示例11: save

	def save(self, check_links=1):
		if webnotes.has_permission(self.doc.doctype, "write"):
			self.prepare_for_save(check_links)
			self.run_method('validate')
			self.save_main()
			self.save_children()
			self.run_method('on_update')
		else:
			webnotes.msgprint("No Permission to Write", raise_exception=True)
开发者ID:gowrav-vishwakarma,项目名称:wnframework,代码行数:9,代码来源:wrapper.py


示例12: get_report_doc

def get_report_doc(report_name):
	bean = webnotes.bean("Report", report_name)
	if not bean.has_read_perm():
		raise webnotes.PermissionError("You don't have access to: {report}".format(report=report_name))
		
	if not webnotes.has_permission(bean.doc.ref_doctype, "report"):
		raise webnotes.PermissionError("You don't have access to get a report on: {doctype}".format(
			doctype=bean.doc.ref_doctype))
		
	return bean.doc
开发者ID:bindscha,项目名称:wnframework_old,代码行数:10,代码来源:query_report.py


示例13: cancel

	def cancel(self):
		if webnotes.has_permission(self.doc.doctype, "submit"):
			if self.doc.docstatus != 1:
				webnotes.msgprint("Only submitted can be cancelled", raise_exception=1)
			self.to_docstatus = 2
			self.prepare_for_save(1)
			self.save_main()
			self.save_children()
			self.run_method('on_cancel')
		else:
			webnotes.msgprint("No Permission to Cancel", raise_exception=True)
开发者ID:gowrav-vishwakarma,项目名称:wnframework,代码行数:11,代码来源:wrapper.py


示例14: submit

	def submit(self):
		if self.ignore_permissions or webnotes.has_permission(self.doc.doctype, "submit", self.doc):
			if self.doc.docstatus != 0:
				webnotes.msgprint("Only draft can be submitted", raise_exception=1)
			self.to_docstatus = 1
			self.save()
			self.run_method('on_submit')
		else:
			self.no_permission_to(_("Submit"))
			
		return self
开发者ID:v2gods,项目名称:wnframework,代码行数:11,代码来源:wrapper.py


示例15: save

	def save(self, check_links=1):
		if self.ignore_permissions or webnotes.has_permission(self.doc.doctype, "write", self.doc):
			self.prepare_for_save(check_links)
			self.run_method('validate')
			self.save_main()
			self.save_children()
			self.run_method('on_update')
		else:
			self.no_permission_to(_("Write"))
		
		return self
开发者ID:v2gods,项目名称:wnframework,代码行数:11,代码来源:wrapper.py


示例16: make

def make(doctype=None, name=None, content=None, subject=None, sent_or_received = "Sent",
	sender=None, recipients=None, communication_medium="Email", send_email=False, 
	print_html=None, attachments='[]', send_me_a_copy=False, set_lead=True, date=None):
	
	if doctype and name and not webnotes.has_permission(doctype, "email", name):
		raise webnotes.PermissionError("You are not allowed to send emails related to: {doctype} {name}".format(
			doctype=doctype, name=name))
			
	_send(doctype=doctype, name=name, content=content, subject=subject, sent_or_received=sent_or_received,
		sender=sender, recipients=recipients, communication_medium=communication_medium, send_email=send_email, 
		print_html=print_html, attachments=attachments, send_me_a_copy=send_me_a_copy, set_lead=set_lead, 
		date=date)
开发者ID:bindscha,项目名称:wnframework_old,代码行数:12,代码来源:communication.py


示例17: save

def save(doclist):
	"""insert or update from form query"""
	if isinstance(doclist, basestring):
		doclist = json.loads(doclist)
		
	if not webnotes.has_permission(doclist[0]["doctype"], "write"):
		webnotes.msgprint("No Write Permission", raise_exception=True)

	doclistobj = webnotes.model_wrapper(doclist)
	doclistobj.save()
	
	return [d.fields for d in doclist]
开发者ID:gowrav-vishwakarma,项目名称:wnframework,代码行数:12,代码来源:client.py


示例18: cancel

	def cancel(self):
		if self.ignore_permissions or webnotes.has_permission(self.doc.doctype, "cancel", self.doc):
			if self.doc.docstatus != 1:
				webnotes.msgprint("Only submitted can be cancelled", raise_exception=1)
			self.to_docstatus = 2
			self.prepare_for_save(1)
			self.save_main()
			self.save_children()
			self.run_method('on_cancel')
		else:
			self.no_permission_to(_("Cancel"))
			
		return self
开发者ID:v2gods,项目名称:wnframework,代码行数:13,代码来源:wrapper.py


示例19: save

    def save(self, check_links=1):
        if self.ignore_permissions or webnotes.has_permission(self.doc.doctype, "write", self.doc):
            self.to_docstatus = 0
            self.prepare_for_save("save")
            if not self.ignore_validate:
                self.run_method("validate")
            self.save_main()
            self.save_children()
            self.run_method("on_update")
        else:
            self.no_permission_to(_("Write"))

        return self
开发者ID:rohitw1991,项目名称:adbwnf,代码行数:13,代码来源:bean.py


示例20: load_doctypes

def load_doctypes():
	"""load all doctypes and roles"""
	global doctypes, roles
	import webnotes.model.doctype

	roles = webnotes.get_roles()
	
	for t in tables:
		if t.startswith('`'):
			doctype = t[4:-1]
			if not webnotes.has_permission(doctype):
				raise webnotes.PermissionError, doctype
			doctypes[doctype] = webnotes.model.doctype.get(doctype)
开发者ID:akshayagarwal,项目名称:wnframework,代码行数:13,代码来源:reportview.py



注:本文中的webnotes.has_permission函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python webnotes.init函数代码示例发布时间:2022-05-26
下一篇:
Python webnotes.get_roles函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap