本文整理汇总了Python中udata.auth.current_user._get_current_object函数的典型用法代码示例。如果您正苦于以下问题:Python _get_current_object函数的具体用法?Python _get_current_object怎么用?Python _get_current_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_get_current_object函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
def save(self, commit=True, **kwargs):
dataset = super(DatasetCreateForm, self).save(commit=False, **kwargs)
if not dataset.organization:
dataset.owner = current_user._get_current_object()
if commit:
dataset.save()
return dataset
示例2: reject_source
def reject_source(ident, comment):
'''Reject a source for automatic harvesting'''
source = get_source(ident)
source.validation.on = datetime.now()
source.validation.comment = comment
source.validation.state = VALIDATION_REFUSED
if current_user.is_authenticated():
source.validation.by = current_user._get_current_object()
source.save()
return source
示例3: refuse_transfer
def refuse_transfer(transfer, comment=None):
'''Refuse an incoming a transfer request'''
TransferResponsePermission(transfer).test()
transfer.responded = datetime.now()
transfer.responder = current_user._get_current_object()
transfer.status = 'refused'
transfer.response_comment = comment
transfer.save()
return transfer
示例4: validate_source
def validate_source(ident, comment=None):
'''Validate a source for automatic harvesting'''
source = get_source(ident)
source.validation.on = datetime.now()
source.validation.comment = comment
source.validation.state = VALIDATION_ACCEPTED
if current_user.is_authenticated():
source.validation.by = current_user._get_current_object()
source.save()
launch(ident)
return source
示例5: save_grant
def save_grant(client_id, code, request, *args, **kwargs):
# decide the expires time yourself
expires = datetime.utcnow() + timedelta(seconds=GRANT_EXPIRATION)
return OAuth2Grant.objects.create(
client=ObjectId(client_id),
code=code['code'],
redirect_uri=request.redirect_uri,
scopes=request.scopes,
user=current_user._get_current_object(),
expires=expires
)
示例6: validate_source
def validate_source(ident, comment=None):
'''Validate a source for automatic harvesting'''
source = get_source(ident)
source.validation.on = datetime.now()
source.validation.comment = comment
source.validation.state = VALIDATION_ACCEPTED
if current_user.is_authenticated:
source.validation.by = current_user._get_current_object()
source.save()
schedule(ident, cron=current_app.config['HARVEST_DEFAULT_SCHEDULE'])
launch(ident)
return source
示例7: save
def save(self, commit=True, **kwargs):
'''Register the current user as admin on creation'''
org = super(OrganizationForm, self).save(commit=False, **kwargs)
if not org.id:
user = current_user._get_current_object()
member = Member(user=user, role='admin')
org.members.append(member)
if commit:
org.save()
return org
示例8: post
def post(self, org, id):
'''Refuse user membership to a given organization.'''
membership_request = self.get_or_404(org, id)
form = api.validate(MembershipRefuseForm)
membership_request.status = 'refused'
membership_request.handled_by = current_user._get_current_object()
membership_request.handled_on = datetime.now()
membership_request.refusal_comment = form.comment.data
org.save()
return {}, 200
示例9: post
def post(self, org, id):
"""Refuse user membership to a given organization."""
EditOrganizationPermission(org).test()
membership_request = self.get_or_404(org, id)
form = api.validate(MembershipRefuseForm)
membership_request.status = "refused"
membership_request.handled_by = current_user._get_current_object()
membership_request.handled_on = datetime.now()
membership_request.refusal_comment = form.comment.data
org.save()
notify_membership_response.delay(org, membership_request)
return {}, 200
示例10: post
def post(self, org, id):
'''Accept user membership to a given organization.'''
EditOrganizationPermission(org).test()
membership_request = self.get_or_404(org, id)
if org.is_member(membership_request.user):
return org.member(membership_request.user), 409
membership_request.status = 'accepted'
membership_request.handled_by = current_user._get_current_object()
membership_request.handled_on = datetime.now()
member = Member(user=membership_request.user, role='editor')
org.members.append(member)
org.save()
notify_membership_response.delay(org, membership_request)
return member
示例11: accept_transfer
def accept_transfer(transfer, comment=None):
'''Accept an incoming a transfer request'''
TransferResponsePermission(transfer).test()
transfer.responded = datetime.now()
transfer.responder = current_user._get_current_object()
transfer.status = 'accepted'
transfer.response_comment = comment
transfer.save()
subject = transfer.subject
recipient = transfer.recipient
if isinstance(recipient, Organization):
subject.organization = recipient
elif isinstance(recipient, User):
subject.owner = recipient
subject.save()
return transfer
示例12: on_user_deleted_dataset
def on_user_deleted_dataset(dataset):
if (not dataset.private and current_user and
current_user.is_authenticated):
user = current_user._get_current_object()
organization = dataset.organization
write_activity.delay(UserDeletedDataset, user, dataset, organization)
示例13: is_following
def is_following(obj):
return current_user.is_authenticated() and Follow.objects.is_following(current_user._get_current_object(), obj)
示例14: get
def get(self):
'''List all current user pending notifications'''
user = current_user._get_current_object()
return get_notifications(user)
示例15: inject_organization_needs
def inject_organization_needs(sender, identity):
if current_user.is_authenticated():
for org in Organization.objects(members__user=current_user.id):
membership = get_by(org.members, 'user', current_user._get_current_object())
identity.provides.add(OrganizationNeed(membership.role, org.id))