当前位置: 首页>>代码示例>>Python>>正文


Python Point.delete方法代码示例

本文整理汇总了Python中models.point.Point.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Point.delete方法的具体用法?Python Point.delete怎么用?Python Point.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.point.Point的用法示例。


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

示例1: __init__

# 需要导入模块: from models.point import Point [as 别名]
# 或者: from models.point.Point import delete [as 别名]

#.........这里部分代码省略.........
	### Edit
	def get_edit_point(self, point_id=None):
		data = self.point_hook.retrieve_one(where={'id':point_id})

		points = self.point_hook.retrieve(where={'pv_id':data['pv_id']})

		return template('point/edit', title="Edit point", data=data, points=points, errors=dict())
	get_edit_point.route = '/point/edit/<point_id>'
	get_edit_point.method = 'GET'

	def ajax_get_edit_point(self):
		data = self.point_hook.retrieve_one(where={'id':request.query.point_id})

		points = self.point_hook.retrieve(where={'pv_id':data['pv_id']})

		return template('point/edit', ajax=True, title="Edit point", data=data, points=points, errors=dict())
	ajax_get_edit_point.route = '/point/ajax/edit'
	ajax_get_edit_point.method = 'GET'

	def post_edit_point(self):
		fields = dict()
		fields['id'] = request.forms.point_id
		fields['pv_id'] = request.forms.pv_id
		fields['title'] = request.forms.title
		fields['description'] = request.forms.description
		fields['rank'] = request.forms.rank
		fields['parent_id'] = request.forms.parent_id

		validation_result = self.point_hook.update(fields, {'id': fields['id']})

		if isinstance(validation_result, dict):
			data = self.point_hook.retrieve_one(where={'id':fields['id']})

			points = self.point_hook.retrieve(where={'pv_id':fields['pv_id']})

			return template('point/edit', data=data, points=points, errors=validation_result)
		else:
			redirect('/pv/'+fields['pv_id'])
	post_edit_point.route = '/point/edit'
	post_edit_point.method = 'POST'

	def ajax_post_edit_point(self):
		fields = dict()
		fields['id'] = request.forms.point_id
		fields['pv_id'] = request.forms.pv_id
		fields['title'] = request.forms.title
		fields['description'] = request.forms.description
		fields['rank'] = request.forms.rank
		fields['parent_id'] = request.forms.parent_id

		validation_result = self.point_hook.update(fields, {'id': fields['id']})

		if isinstance(validation_result, dict):
			return validation_result
		else:
			return {'id': validation_result, 'number': self.point_hook.get_numbering(int(validation_result))}
	ajax_post_edit_point.route = '/point/ajax/edit'
	ajax_post_edit_point.method = 'POST'

	### Delete
	def get_delete_point(self, point_id=None):
		if point_id is None:
			redirect('/')
		else:
			return template('point/delete', title="Delete point", point_id=point_id)
	get_delete_point.route = '/point/delete/<point_id>'
	get_delete_point.method = 'GET'

	def ajax_get_delete_point(self):
		point_id = request.query.point_id
		return template('point/delete', ajax=True, title="Delete point", point_id=point_id)
	ajax_get_delete_point.route = '/point/ajax/delete'
	ajax_get_delete_point.method = 'GET'

	def post_delete_point(self):
		point_id = request.forms.point_id

		pv_id = self.point_hook.retrieve_one(where={'id':point_id})['pv_id']

		if 'yes' not in request.forms or 'no' in request.forms or point_id is None:
			redirect('/pv/' + str(pv_id))
		else:
			if self.point_hook.delete({'id':point_id}):
				redirect('/pv/' + str(pv_id))
			else:
				print('Error. Do something.') # TODO
	post_delete_point.route = '/point/delete'
	post_delete_point.method = 'POST'

	def ajax_post_delete_point(self):
		point_id = request.forms.point_id
		if point_id is None:
			redirect('/')
		else:
			if self.point_hook.delete({'id':point_id}):
				redirect('/')
			else:
				print('Error. Do something.') # TODO
	ajax_post_delete_point.route = '/point/ajax/delete'
	ajax_post_delete_point.method = 'POST'
开发者ID:sirzerator,项目名称:spvm,代码行数:104,代码来源:point.py


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