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


Python Member.query方法代码示例

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


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

示例1: get

# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import query [as 别名]
	def get(self, args):
		if not require_admin(self):
			return
		
		template_vals = generate_base_template_vals(self)
		template_vals['title'] = 'Edit Member'
		template_vals['page'] = 'members'
		
		req_id = self.request.get('id')
		
		if not req_id:
			while True:
				# Create a new ID and verify it is unique.
				new_id = uuid4().hex
				if not Member.query(Member.id == new_id).get():
					new_member = Member()
					new_member.id = new_id
					new_member.name = 'New Member'
					template_vals['member'] = new_member
					break
		else:
			member = Member.query(Member.id == req_id).get()
			if member:
				template_vals['member'] = member
			else:
				self.error(404)
				return
		
		template_vals['semesters'] = get_all_semesters()
		
		template = JINJA_ENVIRONMENT.get_template('member_edit.html')
		self.response.write(template.render(template_vals))
开发者ID:zmyaro,项目名称:star-site,代码行数:34,代码来源:members.py

示例2: get

# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import query [as 别名]
	def get(self):
		if not check_authentication(self):
			return
		
		# Get all users from the given semester
		selected_semester = self.request.get('semester')
		
		if selected_semester:
			members = Member.query(Member.show == True, Member.semesters_paid == selected_semester).order(Member.name).fetch(limit=None)
		else:
			members = Member.query(Member.show == True, Member.never_paid == False).order(Member.name).fetch(limit=None)
		
		output = []
		for member in members:
			output.append(format_member(member))
		
		self.response.headers['Content-Type'] = 'application/json'
		self.response.write(json.dumps(output))
开发者ID:zmyaro,项目名称:star-site,代码行数:20,代码来源:api.py

示例3: post

# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import query [as 别名]
	def post(self, args):
		if not require_admin(self):
			return
		
		req_id = self.request.get('id')
		if not req_id:
			self.error(422)
			return
		
		member = Member.query(Member.id == req_id).get()
		if not member:
			member = Member()
			member.id = req_id
		
		# Update string values.
		for str_param in ['name', 'dce', 'email', 'card_color', 'card_emblem']:
			req_val = self.request.get(str_param)
			if req_val or req_val == '':
				req_val = req_val.strip()
				setattr(member, str_param, urllib2.unquote(req_val))
		
		# Update boolean values.
		for bool_param in ['show','mailing_list', 'current_student', 'committee_rank', 'merit_rank1', 'merit_rank2', 'card_printed']:
			req_val = self.request.get(bool_param)
			setattr(member, bool_param, not not req_val)
		
		# Update multi-select values.
		member.semesters_paid = [float(semester) for semester in self.request.get('semesters_paid', allow_multiple=True)]
		
		# Save the updated member.
		member.put()
		
		if member.never_paid:
			self.redirect('/members/hidden', code=303)
			return
		
		self.redirect('/members/' + member.id, code=303)
开发者ID:zmyaro,项目名称:star-site,代码行数:39,代码来源:members.py


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