本文整理匯總了Python中models.Submission.get方法的典型用法代碼示例。如果您正苦於以下問題:Python Submission.get方法的具體用法?Python Submission.get怎麽用?Python Submission.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Submission
的用法示例。
在下文中一共展示了Submission.get方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: update_group
# 需要導入模塊: from models import Submission [as 別名]
# 或者: from models.Submission import get [as 別名]
def update_group(self, key):
if not auth.logged_in():
return self.redirect('/groups')
user = auth.current_user()
group = Group.get(key)
if group.owner.user_id() != user.user_id() and not auth.user_is_admin():
Messages.add('Only the owner of the group owner may modify it')
return self.redirect('/groups')
name = self.request.get('name')
public = self.request.get('public') == 'public'
abandon = self.request.get('abandon-project')
sub_text = self.request.get('submission-text')
sub_url = self.request.get('submission-url')
remove_submission = self.request.get_all('remove-submission')
remove = self.request.get_all('remove')
owner = self.request.get('owner')
delete = self.request.get('delete')
if delete:
group.delete()
return self.redirect('/groups')
group.name = name
group.public = public
if abandon:
group.project = None
if sub_text and sub_url:
Submission(text=sub_text, url=sub_url, group=group).put()
for sub in Submission.get(remove_submission):
sub.delete()
pending = list(group.pending_users)
for user in pending:
approve = self.request.get("approve-%s" % user)
if approve == "approve":
group.members.append(user)
group.pending_users.remove(user)
elif approve == "refuse":
group.pending_users.remove(user)
group.owner = auth.user_from_email(owner)
for user in remove:
if auth.user_from_email(user) == group.owner:
Messages.add('Cannot remove the group owner')
return self.redirect('/groups/%s/edit' % key)
else:
group.members.remove(auth.user_from_email(user))
group.put()
return self.redirect('/groups/%s' % key)
示例2: update_group
# 需要導入模塊: from models import Submission [as 別名]
# 或者: from models.Submission import get [as 別名]
def update_group(self, key):
"""Updates a group with information from the moderation form.
Form Variables:
name: the name of the group
public: true if the group should be joinable by the
public
abandon-project: true if the group moderator wants to abandon the
current project
submission-text: the text to be displayed for the new submission
submission-url: the URL of the new submission
remove-submission: a list of submissions to be removed
remove: a list of users to be removed from the group
owner: the owner of the group
delete: true if the group moderator wants to disband the
group
"""
if not auth.logged_in():
return self.redirect('/groups')
user = auth.current_user()
group = Group.get(key)
if (group.owner.user_id() != user.user_id() and
not auth.user_is_admin()):
Messages.add('Only the owner of the group owner may modify it')
return self.redirect('/groups')
name = self.request.get('name')
public = self.request.get('public') == 'public'
abandon = self.request.get('abandon-project')
sub_text = self.request.get('submission-text')
sub_url = self.request.get('submission-url')
remove_submission = self.request.get_all('remove-submission')
remove = self.request.get_all('remove')
owner = self.request.get('owner')
delete = self.request.get('delete')
if delete:
group.delete()
return self.redirect('/groups')
group.name = name
group.public = public
if abandon:
group.project = None
if sub_text and sub_url:
Submission(text=sub_text, url=sub_url, group=group).put()
for sub in Submission.get(remove_submission):
sub.delete()
pending = list(group.pending_users)
for user in pending:
approve = self.request.get("approve-%s" % user)
if approve == "approve":
group.members.append(user)
group.pending_users.remove(user)
elif approve == "refuse":
group.pending_users.remove(user)
group.owner = auth.user_from_email(owner)
for user in remove:
if auth.user_from_email(user) == group.owner:
Messages.add('Cannot remove the group owner')
return self.redirect('/groups/%s/edit' % key)
else:
group.members.remove(auth.user_from_email(user))
group.put()
return self.redirect('/groups/%s' % key)