当前位置: 首页>>代码示例>>Python>>正文


Python models.User方法代码示例

本文整理汇总了Python中account.models.User方法的典型用法代码示例。如果您正苦于以下问题:Python models.User方法的具体用法?Python models.User怎么用?Python models.User使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在account.models的用法示例。


在下文中一共展示了models.User方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sign_in

# 需要导入模块: from account import models [as 别名]
# 或者: from account.models import User [as 别名]
def sign_in(request):
    if request.method == "POST":
        uf = UserForm(request.POST)
        if uf.is_valid():
            email = uf.cleaned_data['email']
            password = uf.cleaned_data['password']
            user = User.objects.filter(email=email, password=password)
            if user: 
                tip = "????"
                return render_to_response('sign_in.html', {'uf':uf, 'tip':tip})
            else:
                tip = "???????"
                return render_to_response('sign_in.html', {'uf':uf, 'tip':tip})
    else:
        uf = UserForm()
    return render_to_response('sign_in.html', {'uf':uf}) 
开发者ID:lijialinneu,项目名称:GWS,代码行数:18,代码来源:views.py

示例2: sign_up

# 需要导入模块: from account import models [as 别名]
# 或者: from account.models import User [as 别名]
def sign_up(request):
    if request.method == "POST":
        uf = UserForm(request.POST)
        if uf.is_valid():
            email = uf.cleaned_data['email']
            password = uf.cleaned_data['password']

            user = User.objects.get(email=email)
            if user:
                tip = "??????????"
                return render_to_response('sign_up.html', {'uf':uf, 'tip':tip})
            else:
                user = User()
                user.email = email
                user.password = password           
                user.save()
                tip = "???????????"
                return render_to_response('sign_up.html',{'uf':uf, 'tip':tip})
    else:
        uf = UserForm()
    return render_to_response('sign_up.html',{'uf':uf}) 
开发者ID:lijialinneu,项目名称:GWS,代码行数:23,代码来源:views.py

示例3: user

# 需要导入模块: from account import models [as 别名]
# 或者: from account.models import User [as 别名]
def user(self, db):
        user = mixer.blend(User)
        return user 
开发者ID:flame0,项目名称:atom-hw,代码行数:5,代码来源:test_views.py

示例4: create

# 需要导入模块: from account import models [as 别名]
# 或者: from account.models import User [as 别名]
def create(self, validated_data):
        """
        Create a new user from the serializer's validated data.

        This also sends out an email to the user confirming their email
        address.

        Args:
            validated_data:
                The data to create the new user from.

        Returns:
            The newly created ``User`` instance.
        """
        logger.info(
            'Registering new user with email: %s',
            validated_data['email'])

        user = User.objects.create_user(**validated_data)
        email = EmailAddress.objects.create(
            email=self.validated_data['email'],
            user=user)

        confirmation = EmailConfirmation.objects.create(email=email)
        confirmation.send_confirmation()

        return user 
开发者ID:knowmetools,项目名称:km-api,代码行数:29,代码来源:serializers.py

示例5: create_submission

# 需要导入模块: from account import models [as 别名]
# 或者: from account.models import User [as 别名]
def create_submission(problem, author: User, code, lang, contest=None, status=SubmissionStatus.WAITING, ip=''):
    if not 6 <= len(code) <= 65536:
        raise ValueError("Code is too short or too long.")
    if author.submission_set.exists() and (
        datetime.now() - author.submission_set.first().create_time).total_seconds() < 10:
        raise ValueError("Please don't resubmit in 10 seconds.")
    if isinstance(problem, (int, str)):
        return Submission.objects.create(lang=lang, code=code, author=author, problem_id=problem, contest=contest,
                                         status=status, status_private=status, ip=ip)
    else:
        return Submission.objects.create(lang=lang, code=code, author=author, problem=problem, contest=contest,
                                         status=status, status_private=status, ip=ip) 
开发者ID:ultmaster,项目名称:eoj3,代码行数:14,代码来源:tasks.py

示例6: query_user

# 需要导入模块: from account import models [as 别名]
# 或者: from account.models import User [as 别名]
def query_user(kw):
    results = list()
    if kw and len(kw) >= 3:
        for user in User.objects.filter(username__icontains=kw, is_active=True).all().only('username')[:5]:
            results.append(dict(title=user.username, url=reverse('generic', kwargs=dict(pk=user.pk))))
    return dict(name='User', results=results) 
开发者ID:ultmaster,项目名称:eoj3,代码行数:8,代码来源:search_api.py

示例7: get

# 需要导入模块: from account import models [as 别名]
# 或者: from account.models import User [as 别名]
def get(self, request):
        kw = request.GET.get('kw')
        results = list()
        if kw:
            for user in User.objects.filter(username__icontains=kw, is_active=True).all().only('username', 'pk')[:5]:
                results.append(dict(name=user.username, value=user.pk))
        return Response(dict(success=True, results=results)) 
开发者ID:ultmaster,项目名称:eoj3,代码行数:9,代码来源:search_api.py

示例8: get_queryset

# 需要导入模块: from account import models [as 别名]
# 或者: from account.models import User [as 别名]
def get_queryset(self):
        self.user = get_object_or_404(User, pk=self.kwargs.get('pk'))
        qs = self.user.blog_set.all().with_likes().with_likes_flag(self.request.user)
        if not is_admin_or_root(self.request.user) and not self.request.user == self.user:
            qs = qs.filter(visible=True)
        return qs 
开发者ID:ultmaster,项目名称:eoj3,代码行数:8,代码来源:views.py

示例9: post

# 需要导入模块: from account import models [as 别名]
# 或者: from account.models import User [as 别名]
def post(self, request):
        user = get_object_or_404(User, username=request.POST['name'])
        return HttpResponseRedirect(reverse('generic', kwargs={'pk': user.pk})) 
开发者ID:ultmaster,项目名称:eoj3,代码行数:5,代码来源:views.py

示例10: add_users

# 需要导入模块: from account import models [as 别名]
# 或者: from account.models import User [as 别名]
def add_users(self, *users: User):
        for user in users:
            UserConversation.objects.create(conversation=self, user=user) 
开发者ID:ultmaster,项目名称:eoj3,代码行数:5,代码来源:models.py

示例11: submission_count_api

# 需要导入模块: from account import models [as 别名]
# 或者: from account.models import User [as 别名]
def submission_count_api(request, name):
    user = get_object_or_404(User, username=name)
    now = datetime.datetime.now()
    one_year_ago = now.replace(year=now.year - 1)
    submissions = Submission.objects.filter(author=user, create_time__gte=one_year_ago)
    result = {submission.create_time.timestamp(): 1 for submission in submissions}
    return JsonResponse(result) 
开发者ID:ultmaster,项目名称:eoj3,代码行数:9,代码来源:views.py

示例12: update_rank

# 需要导入模块: from account import models [as 别名]
# 或者: from account.models import User [as 别名]
def update_rank(self, submission):
        if not submission.contest_id or submission.contest_id != self.contest_id:
            raise ValueError("Error submission type")

        if User.objects.get(id=submission.user_id).admin_type == SUPER_ADMIN:
            logger.warning("SUPER_ADMIN is cheating in the contest!")
            return

        if submission.result == result["system_error"]:
            logger.warning("submission " + submission.id + " result is system error, update rank operation is ignored")
            return

        # ????????
        if str(submission.problem_id) in self.submission_info:
            info = self.submission_info[str(submission.problem_id)]
            # ???????? ac ????
            if info["is_ac"]:
                return

            self.total_submission_number += 1

            if submission.result == result["accepted"]:

                self.total_ac_number += 1

                info["is_ac"] = True
                info["ac_time"] = (submission.create_time - self.contest.start_time).total_seconds()

                # ??????????????????????????????????
                self.total_time += (info["ac_time"] + info["error_number"] * 20 * 60)
                problem = ContestProblem.objects.get(id=submission.problem_id)
                # ????????? ???1
                if problem.total_accepted_number == 1:
                    info["is_first_ac"] = True

            else:
                info["error_number"] += 1
                info["is_ac"] = False

        else:
            # ?????????
            self.total_submission_number += 1
            info = {"is_ac": False, "ac_time": 0, "error_number": 0, "is_first_ac": False}
            if submission.result == result["accepted"]:
                self.total_ac_number += 1
                info["is_ac"] = True
                info["ac_time"] = (submission.create_time - self.contest.start_time).total_seconds()
                self.total_time += info["ac_time"]
                problem = ContestProblem.objects.get(id=submission.problem_id)

                if problem.total_accepted_number == 1:
                    info["is_first_ac"] = True

            else:
                info["is_ac"] = False
                info["error_number"] = 1
        self.submission_info[str(submission.problem_id)] = info
        self.save() 
开发者ID:lonelam,项目名称:OnlineJudgeSHU,代码行数:60,代码来源:models.py


注:本文中的account.models.User方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。