本文整理汇总了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))
示例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))
示例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)