當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。