本文整理匯總了Python中reddit_liveupdate.models.LiveUpdateContributorInvitesByEvent.get方法的典型用法代碼示例。如果您正苦於以下問題:Python LiveUpdateContributorInvitesByEvent.get方法的具體用法?Python LiveUpdateContributorInvitesByEvent.get怎麽用?Python LiveUpdateContributorInvitesByEvent.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類reddit_liveupdate.models.LiveUpdateContributorInvitesByEvent
的用法示例。
在下文中一共展示了LiveUpdateContributorInvitesByEvent.get方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: POST_set_contributor_permissions
# 需要導入模塊: from reddit_liveupdate.models import LiveUpdateContributorInvitesByEvent [as 別名]
# 或者: from reddit_liveupdate.models.LiveUpdateContributorInvitesByEvent import get [as 別名]
def POST_set_contributor_permissions(self, form, jquery, user, type_and_perms):
"""Change a contributor or contributor invite's permissions.
Requires the `manage` permission for this thread.
See also: [/api/live/*thread*/invite_contributor]
(#POST_api_live_{thread}_invite_contributor) and
[/api/live/*thread*/rm_contributor]
(#POST_api_live_{thread}_rm_contributor).
"""
if form.has_errors("name", errors.USER_DOESNT_EXIST,
errors.NO_USER):
return
if form.has_errors("type", errors.INVALID_PERMISSION_TYPE):
return
if form.has_errors("permissions", errors.INVALID_PERMISSIONS):
return
type, permissions = type_and_perms
if type == "liveupdate_contributor":
if user._id not in c.liveupdate_event.contributors:
c.errors.add(errors.LIVEUPDATE_NOT_CONTRIBUTOR, field="user")
form.has_errors("user", errors.LIVEUPDATE_NOT_CONTRIBUTOR)
return
c.liveupdate_event.update_contributor_permissions(user, permissions)
elif type == "liveupdate_contributor_invite":
try:
LiveUpdateContributorInvitesByEvent.get(
c.liveupdate_event, user)
except InviteNotFoundError:
c.errors.add(errors.LIVEUPDATE_NO_INVITE_FOUND, field="user")
form.has_errors("user", errors.LIVEUPDATE_NO_INVITE_FOUND)
return
else:
LiveUpdateContributorInvitesByEvent.update_invite_permissions(
c.liveupdate_event, user, permissions)
row = form.closest("tr")
editor = row.find(".permissions").data("PermissionEditor")
editor.onCommit(permissions.dumps())
示例2: POST_accept_contributor_invite
# 需要導入模塊: from reddit_liveupdate.models import LiveUpdateContributorInvitesByEvent [as 別名]
# 或者: from reddit_liveupdate.models.LiveUpdateContributorInvitesByEvent import get [as 別名]
def POST_accept_contributor_invite(self, form, jquery):
try:
permissions = LiveUpdateContributorInvitesByEvent.get(
c.liveupdate_event, c.user)
except InviteNotFoundError:
c.errors.add(errors.LIVEUPDATE_NO_INVITE_FOUND)
form.set_error(errors.LIVEUPDATE_NO_INVITE_FOUND, None)
return
LiveUpdateContributorInvitesByEvent.remove(
c.liveupdate_event, c.user)
c.liveupdate_event.add_contributor(c.user, permissions)
jquery.refresh()
示例3: POST_accept_contributor_invite
# 需要導入模塊: from reddit_liveupdate.models import LiveUpdateContributorInvitesByEvent [as 別名]
# 或者: from reddit_liveupdate.models.LiveUpdateContributorInvitesByEvent import get [as 別名]
def POST_accept_contributor_invite(self, form, jquery):
"""Accept a pending invitation to contribute to the thread.
See also: [/api/live/*thread*/leave_contributor]
(#POST_api_live_{thread}_leave_contributor).
"""
try:
permissions = LiveUpdateContributorInvitesByEvent.get(
c.liveupdate_event, c.user)
except InviteNotFoundError:
c.errors.add(errors.LIVEUPDATE_NO_INVITE_FOUND)
form.set_error(errors.LIVEUPDATE_NO_INVITE_FOUND, None)
return
LiveUpdateContributorInvitesByEvent.remove(
c.liveupdate_event, c.user)
c.liveupdate_event.add_contributor(c.user, permissions)
jquery.refresh()