當前位置: 首頁>>代碼示例>>Python>>正文


Python User.load方法代碼示例

本文整理匯總了Python中website.project.model.User.load方法的典型用法代碼示例。如果您正苦於以下問題:Python User.load方法的具體用法?Python User.load怎麽用?Python User.load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在website.project.model.User的用法示例。


在下文中一共展示了User.load方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: remove_2_factor

# 需要導入模塊: from website.project.model import User [as 別名]
# 或者: from website.project.model.User import load [as 別名]
def remove_2_factor(request, guid):
    user = User.load(guid)
    try:
        user.delete_addon('twofactor')
    except AttributeError:
        page_not_found(request)
    return redirect(reverse_user(guid))
開發者ID:digideskio,項目名稱:osf.io,代碼行數:9,代碼來源:views.py

示例2: serialize_simple_user

# 需要導入模塊: from website.project.model import User [as 別名]
# 或者: from website.project.model.User import load [as 別名]
def serialize_simple_user(user_info):
    user = User.load(user_info[0])
    return {
        'id': user._id,
        'name': user.fullname,
        'permission': reduce_permissions(user_info[1]) if user_info[1] else None,
    }
開發者ID:545zhou,項目名稱:osf.io,代碼行數:9,代碼來源:serializers.py

示例3: form_valid

# 需要導入模塊: from website.project.model import User [as 別名]
# 或者: from website.project.model.User import load [as 別名]
 def form_valid(self, form):
     osf_id = form.cleaned_data.get('osf_id')
     osf_user = User.load(osf_id)
     try:
         osf_user.system_tags.append(PREREG_ADMIN_TAG)
     except AttributeError:
         raise Http404(('OSF user with id "{}" not found.'
                        ' Please double check.').format(osf_id))
     new_user = MyUser.objects.create_user(
         email=form.cleaned_data.get('email'),
         password=form.cleaned_data.get('password1')
     )
     new_user.first_name = form.cleaned_data.get('first_name')
     new_user.last_name = form.cleaned_data.get('last_name')
     new_user.osf_id = osf_id
     for group in form.cleaned_data.get('group_perms'):
         new_user.groups.add(group)
     new_user.save()
     reset_form = PasswordRecoveryForm(
         data={'username_or_email': new_user.email}
     )
     if reset_form.is_valid():
         send = Recover()
         send.request = self.request
         send.form_valid(reset_form)
     messages.success(self.request, 'Registration successful!')
     return super(RegisterUser, self).form_valid(form)
開發者ID:545zhou,項目名稱:osf.io,代碼行數:29,代碼來源:views.py

示例4: get_context_data

# 需要導入模塊: from website.project.model import User [as 別名]
# 或者: from website.project.model.User import load [as 別名]
 def get_context_data(self, **kwargs):
     user = User.load(self.kwargs.get('guid'))
     try:
         self.initial.setdefault('emails', [(r, r) for r in user.emails])
     except AttributeError:
         raise
     kwargs.setdefault('guid', user.pk)
     return super(ResetPasswordView, self).get_context_data(**kwargs)
開發者ID:545zhou,項目名稱:osf.io,代碼行數:10,代碼來源:views.py

示例5: get_object

# 需要導入模塊: from website.project.model import User [as 別名]
# 或者: from website.project.model.User import load [as 別名]
 def get_object(self, queryset=None):
     customer_id = self.kwargs.get('user_id', None)
     customer = User.load(customer_id)
     email = customer.emails[0]
     desk = DeskClient(self.request.user)
     params = {'email': email}
     customer = desk.find_customer(params)
     return customer
開發者ID:baylee-d,項目名稱:osf.io,代碼行數:10,代碼來源:views.py

示例6: get_context_data

# 需要導入模塊: from website.project.model import User [as 別名]
# 或者: from website.project.model.User import load [as 別名]
 def get_context_data(self, **kwargs):
     self.guid = self.kwargs.get('guid', None)
     try:
         user = User.load(self.guid)
     except AttributeError:
         raise
     self.initial.setdefault('emails', [(r, r) for r in user.emails])
     kwargs.setdefault('guid', self.guid)
     kwargs.setdefault('form', self.get_form())  # TODO: 1.9 xx
     return super(ResetPasswordView, self).get_context_data(**kwargs)
開發者ID:digideskio,項目名稱:osf.io,代碼行數:12,代碼來源:views.py

示例7: get_queryset

# 需要導入模塊: from website.project.model import User [as 別名]
# 或者: from website.project.model.User import load [as 別名]
 def get_queryset(self):
     customer_id = self.kwargs.get('user_id', None)
     customer = User.load(customer_id)
     email = customer.emails[0]
     desk = DeskClient(self.request.user)
     params = {
         'email': email,
     }
     queryset = desk.cases(params)
     return queryset
開發者ID:baylee-d,項目名稱:osf.io,代碼行數:12,代碼來源:views.py

示例8: _validate_reports

# 需要導入模塊: from website.project.model import User [as 別名]
# 或者: from website.project.model.User import load [as 別名]
def _validate_reports(value, *args, **kwargs):
    for key, val in value.iteritems():
        if not User.load(key):
            raise ValidationValueError('Keys must be user IDs')
        if not isinstance(val, dict):
            raise ValidationTypeError('Values must be dictionaries')
        if ('category' not in val or 'text' not in val or 'date' not in val or 'retracted' not in val):
            raise ValidationValueError(
                ('Values must include `date`, `category`, ',
                 '`text`, `retracted` keys')
            )
開發者ID:baylee-d,項目名稱:osf.io,代碼行數:13,代碼來源:model.py

示例9: get_context_data

# 需要導入模塊: from website.project.model import User [as 別名]
# 或者: from website.project.model.User import load [as 別名]
 def get_context_data(self, **kwargs):
     user = User.load(self.kwargs.get('guid'))
     try:
         self.initial.setdefault('emails', [(r, r) for r in user.emails])
     except AttributeError:
         raise Http404(
             '{} with id "{}" not found.'.format(
                 self.context_object_name.title(),
                 self.kwargs.get('guid')
             ))
     kwargs.setdefault('guid', user.pk)
     return super(ResetPasswordView, self).get_context_data(**kwargs)
開發者ID:atelic,項目名稱:osf.io,代碼行數:14,代碼來源:views.py

示例10: serialize_comment

# 需要導入模塊: from website.project.model import User [as 別名]
# 或者: from website.project.model.User import load [as 別名]
def serialize_comment(comment, full=False):
    reports = serialize_reports(comment.reports)
    author_abs_url = furl(OSF_DOMAIN)
    author_abs_url.path.add(comment.user.url)

    return {
        'id': comment._id,
        'author': User.load(comment.user._id),
        'author_path': author_abs_url.url,
        'date_created': comment.date_created,
        'date_modified': comment.date_modified,
        'content': comment.content,
        'has_children': bool(getattr(comment, 'commented', [])),
        'modified': comment.modified,
        'is_deleted': comment.is_deleted,
        'reports': reports,
        'node': comment.node,
        'category': reports[0]['category'],
    }
開發者ID:AllisonLBowers,項目名稱:osf.io,代碼行數:21,代碼來源:serializers.py

示例11: delete

# 需要導入模塊: from website.project.model import User [as 別名]
# 或者: from website.project.model.User import load [as 別名]
 def delete(self, request, *args, **kwargs):
     user_ids = [
         uid for uid in request.POST.keys()
         if uid != 'csrfmiddlewaretoken'
     ]
     for uid in user_ids:
         user = User.load(uid)
         if 'spam_flagged' in user.system_tags:
             user.system_tags.remove('spam_flagged')
         user.system_tags.append('spam_confirmed')
         user.save()
         update_admin_log(
             user_id=self.request.user.id,
             object_id=uid,
             object_repr='User',
             message='Confirmed SPAM: {}'.format(uid),
             action_flag=CONFIRM_SPAM
         )
     return redirect('users:flagged-spam')
開發者ID:alexschiller,項目名稱:osf.io,代碼行數:21,代碼來源:views.py

示例12: serialize_comment

# 需要導入模塊: from website.project.model import User [as 別名]
# 或者: from website.project.model.User import load [as 別名]
def serialize_comment(comment):
    reports = [
        serialize_report(user, report)
        for user, report in comment.reports.iteritems()
    ]
    author_abs_url = furl(OSF_DOMAIN)
    author_abs_url.path.add(comment.user.url)

    return {
        'id': comment._id,
        'author': User.load(comment.user._id),
        'author_id': comment.user._id,
        'author_path': author_abs_url.url,
        'date_created': comment.date_created,
        'date_modified': comment.date_modified,
        'content': comment.content,
        'has_children': bool(getattr(comment, 'commented', [])),
        'modified': comment.modified,
        'is_deleted': comment.is_deleted,
        'spam_status': comment.spam_status,
        'reports': reports,
        'node': comment.node,
        'category': reports[0]['category'],
    }
開發者ID:545zhou,項目名稱:osf.io,代碼行數:26,代碼來源:serializers.py

示例13: get_object

# 需要導入模塊: from website.project.model import User [as 別名]
# 或者: from website.project.model.User import load [as 別名]
 def get_object(self, queryset=None):
     return User.load(self.kwargs.get('guid'))
開發者ID:545zhou,項目名稱:osf.io,代碼行數:4,代碼來源:views.py

示例14: disable_user

# 需要導入模塊: from website.project.model import User [as 別名]
# 或者: from website.project.model.User import load [as 別名]
def disable_user(request, guid):
    user = User.load(guid)
    user.disable_account()
    user.save()
    return redirect(reverse_user(guid))
開發者ID:digideskio,項目名稱:osf.io,代碼行數:7,代碼來源:views.py

示例15: reactivate_user

# 需要導入模塊: from website.project.model import User [as 別名]
# 或者: from website.project.model.User import load [as 別名]
def reactivate_user(request, guid):
    user = User.load(guid)
    user.date_disabled = None
    subscribe_on_confirm(user)
    user.save()
    return redirect(reverse_user(guid))
開發者ID:digideskio,項目名稱:osf.io,代碼行數:8,代碼來源:views.py


注:本文中的website.project.model.User.load方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。