本文整理汇总了Python中models.Member.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Member.get_by_id方法的具体用法?Python Member.get_by_id怎么用?Python Member.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Member
的用法示例。
在下文中一共展示了Member.get_by_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import get_by_id [as 别名]
def get(self, member_id=""):
if member_id:
self.member_allowd(member_id)
members = Member.get_by_id(member_id)
else:
members = Member.get_by_uid(self.current_user)
result = {"data": members}
self.finish(result)
示例2: post
# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import get_by_id [as 别名]
def post(self):
post = self.request.POST
if post['kind'] == 'badge':
badge = Badge(
name=post['name'],
description=post['description'],
category=post['category'],
image=post['image'],
value=int(post['value'])
)
badge.save()
elif post['kind'] == 'article':
date = datetime.datetime.strptime(post['date'], '%Y-%m-%d').date()
article = NewsArticle(
title=post['title'],
author=post['author'],
body=post['body'],
date=date
)
article.save()
elif post['kind'] == 'award':
badge = Badge.get_by_id(int(post['badge']))
for member in post.getall('members'):
member = Member.get_by_id(int(member))
award = Award(
member=member,
badge=badge,
date=datetime.date.today(),
proof=post['proof']
)
award.save()
member.score_cache = member.score + badge.value
member.save()
elif post['kind'] == 'talk':
talk = Talk(
title=post['title'],
date=datetime.datetime.strptime(post['date'], '%Y-%m-%d').date(),
description=post['description'],
member=Member.get_by_id(int(post['member'])),
video=post['video']
)
talk.put()
self.get()
示例3: post
# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import get_by_id [as 别名]
def post(self):
post = self.request.POST
if post['kind'] == 'badge':
badge = Badge(
name=post['name'],
description=post['description'],
category=post['category'],
image=post['image'],
value=int(post['value'])
)
badge.save()
elif post['kind'] == 'award':
badge = Badge.get_by_id(int(post['badge']))
for member in post.getall('members'):
member = Member.get_by_id(int(member))
award = Award(
member=member,
badge=badge,
date=datetime.date.today(),
proof=post['proof']
)
award.save()
member.score += badge.value
member.save()
elif post['kind'] == 'talk':
talk = Talk(
title=post['title'],
date=utils.parse_date(post['date']),
description=post['description'],
member=Member.get_by_id(int(post['member'])),
video=post['video']
)
talk.put()
elif post['kind'] == 'taglineform':
properties = GeneralSiteProperties.all().get()
if properties == None:
properties = GeneralSiteProperties(tag_line=post['tagline'])
properties.put()
else:
properties.tag_line = post['tagline']
properties.put()
self.get()
示例4: post
# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import get_by_id [as 别名]
def post(self, key):
post = self.request.POST
edit = self.request.get('kind')
form_data = dict((k, post.get(k, ''))
for k in ('title', 'author', 'date', 'body', 'picture','video'))
template_dict = {'form_data': form_data, 'key': key, 'show_form' : True,'members': Member.all(),
'edit':edit,'thing' : self.thing_descriptors.get(edit),'images':Image.all().filter('name != ', "no-name")}
try:
this_date = utils.parse_date(form_data['date'])
except ValueError:
template_dict['message'] = \
'Date is not in the correct format (YYYY-MM-DD).'
else:
if key == 'new':
try:
if(edit=="news"):
thing = NewsArticleNew(
title=post['title'],
author=Member.get_by_id(int(post['author'])),
date=this_date,
body=post['body']
)
elif(edit=="talk"):
thing = TalkNew(
title=post['title'],
author=Member.get_by_id(int(post['author'])),
date=this_date,
body=post['body']
)
if('video' in post):
talk.video = post['video']
elif(edit=="hack"):
thing = Hack(
title=post['title'],
date=this_date,
body=post['body']
)
if(edit=="news" or edit=="hack"):
if(self.request.get("picture")):
pictureImage = Image(
picture=images.resize(self.request.get("picture"), self.image_height, self.image_width),
name="no-name",title=" ",alt=" ")
if post['picture_title'] :
pictureImage.title=post['picture_title']
if post['picture_alt'] :
pictureImage.alt=post['picture_alt']
pictureImage.put()
thing.picture=pictureImage
elif(post['picture_alias']!="none"):
thing.picture=Image.get_by_id(int(post['picture_alias']))
thing.put()
template_dict['key']=thing.key
except datastore_errors.Error:
template_dict['message'] = \
'Could not create new %s.' % self.thing_descriptors.get(edit)
else:
template_dict['message'] = '%s created.' % self.thing_descriptors.get(edit)
template_dict['show_form'] = False
else:
try:
if(edit=="news"):
thing = NewsArticleNew.get(Key(key))
thing.title = form_data['title']
thing.author = Member.get_by_id(int(post['author']))
thing.date = this_date
thing.body = form_data['body']
elif(edit=="talk"):
thing = TalkNew.get(Key(key))
thing.title = form_data['title']
thing.date = this_date
thing.body = form_data['body']
elif(edit=="hack"):
thing = Hack.get(Key(key))
thing.title = form_data['title']
thing.date = this_date
thing.body = form_data['body']
if(self.request.get("picture")):
pictureImage = Image(picture=images.resize(self.request.get("picture"), self.image_height, self.image_width),
name="no-name",title=" ",alt=" ")
if post['picture_title'] :
pictureImage.title=post['picture_title']
if post['picture_alt'] :
pictureImage.alt=post['picture_alt']
pictureImage.put()
thing.picture = pictureImage
elif(post['picture_alias']!="none"):
thing.picture=Image.get_by_id(int(post['picture_alias']))
if 'delete_picture' in post:
thing.picture=None
except BadKeyError:
#.........这里部分代码省略.........