• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.UserProfile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.UserProfile的典型用法代码示例。如果您正苦于以下问题:Python UserProfile类的具体用法?Python UserProfile怎么用?Python UserProfile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: post

    def post(self):
        """
        """
        new_profile = self.current_userprofile.to_python()

        # Apply each argument we accept to the new structure
        new_profile["name"] = self.get_argument("name", None)
        new_profile["bio"] = self.get_argument("bio", None)
        new_profile["location_text"] = self.get_argument("location_text", None)
        new_profile["avatar_url"] = self.get_argument("avatar_url", None)
        new_profile["email"] = self.get_argument("email", None)

        # Help a user out if they didn't put the "http" in front
        website = self.get_argument("website", None)
        if not website.startswith("http"):
            website = "http://%s" % (website)
        new_profile["website"] = website

        # Save values if they pass validation
        try:
            new_up = UserProfile(**new_profile)
            new_up.validate()
            save_userprofile(self.db_conn, new_up)
            self._current_userprofile = new_up
        except Exception, e:
            # TODO handle errors nicely
            raise
开发者ID:B-Rich,项目名称:readify,代码行数:27,代码来源:handlers.py


示例2: api_signup

def api_signup(request, email=None, password=None, first_name=None, last_name=None):
    """
    registers a new user and authenticates it

    :param email:
    :param password:
    :param first_name:
    :param last_name:
    :return: :json:`{"profile": {"id": ""}, "sessionid": ""}`
    :raises ApiException: (200, 'Missing or invalid parameter FIELD_NAME VALUE')
    :raises ApiException: (402, 'Invalid email address or password')
    :raises ApiException: (403, 'Email address already registered')
    """

    email = param_email(email, required=True, blank=False, field_name='email')
    password = param_string(password, required=True, blank=False, field_name='password')
    first_name = param_string(first_name, required=False, blank=False, field_name='first_name')
    last_name = param_string(last_name, required=False, blank=False, field_name='last_name')

    UserProfile.create_user(
            email=email,
            password=password,
            first_name=first_name,
            last_name=last_name)
    response_json = _signin(request, email=email, password=password)

    curr_user = get_curr_user(request, required=True)
    emails.send_welcome_email(curr_user)

    return response_json
开发者ID:nrabe,项目名称:todoapp,代码行数:30,代码来源:api.py


示例3: _register

def _register(request):
    if REGISTER_TURN_OFF:
        return render('register_turn_off.html', RequestContext(request))
    if request.user.is_authenticated():
        auth.logout(request)
    if request.method == 'GET':
        form = RegisterForm()
        return render('register.html', RequestContext(request, {'form': form}))
    if request.method == 'POST':
        form = RegisterForm(request.POST)
        if form.is_valid():
            data = form.clean()
            if data['password'] != data['re_password']:
                return render('register.html', RequestContext(request, {'form': form}))
            obj_user = User.objects
            if obj_user.filter(username=data['username']).exists() or obj_user.filter(email=data['email']).exists():
                messages.error(request, 'user or email already existed')
                return render('register.html', RequestContext(request, {'form': form}))
            new_user = obj_user.create_user(username=data['username'], password=data['password'], email=data['email'])
            new_user.is_active = True
            new_user.is_staff = True
            new_user.save()
            new_profile = UserProfile(user=new_user)
            try:
                new_profile.save()
                return HttpResponseRedirect('/')
            except:
                messages.error(request, 'register new user failed!')
                return render('register.html', RequestContext(request, {'form': form}))
            return HttpResponseRedirect('/')
        return render('register.html', RequestContext(request, {'form': form}))
开发者ID:Zuckonit,项目名称:timeline,代码行数:31,代码来源:views.py


示例4: regist

def regist(request):

    if request.method == "POST":
        form = UserForm(request.POST)

        if form.is_valid():

            loginname = form.cleaned_data["loginname"]
            username = form.cleaned_data["username"]
            password = form.cleaned_data["password"]
            rule_no = form.cleaned_data["rule_no"]
            intro = form.cleaned_data["intro"]
            contact = form.cleaned_data["contact"]
            email = form.cleaned_data["email"]

            userid = User.objects.create_user(username=loginname, email=email, password=password)
            new_usr_profile = UserProfile(
                user=userid,
                loginname=loginname,
                username=username,
                password=password,
                rule_no=rule_no,
                intro=intro,
                contact=contact,
                email=email,
            )
            new_usr_profile.save()

            return HttpResponseRedirect("/")
    else:
        form = UserForm()

    return render_to_response("register.html", {"form": form})
开发者ID:lngz,项目名称:misj,代码行数:33,代码来源:views.py


示例5: account_login

def account_login(request):
    # print request.method
    if request.method == 'GET':
        return render(request, 'one_finger/login.html')

    else:
        # print request.POST
        username = request.POST.get('username')
        password = request.POST.get('password')
        user = authenticate(username=username,
                            password=password)
        if user is not None:
            print 'user_login ok'
            login(request, user)
            if not UserProfile.objects.filter():
                admin_obj = User.objects.first()
                user_obj = UserProfile(name=admin_obj.username,
                                       user_id=admin_obj.id)
                user_obj.save()
            user.userprofile.online = True
            user.userprofile.save()
            # check_cloud()
            status = check_cloud()
            # pdb.set_trace()
            if status:
                return HttpResponseRedirect('/')
            else:
                return HttpResponseRedirect('/input')
        else:
            return render(request, 'one_finger/login.html', {
                'login_err': "Wrong username or password!"
            })
开发者ID:zhaogaolong,项目名称:oneFinger,代码行数:32,代码来源:views.py


示例6: register

def register(request):
	if request.user.is_authenticated():
		return HttpResponseRedirect(reverse("home"))
	else:
		if request.method == 'POST':
			form = RegisterForm(request.POST)
			
			x_user = User.objects.filter(email=request.POST["email"])
			if x_user.count() > 0:
				form.add_error('email', _('Este email ya existe'))
			else:
				if form.is_valid():
					current = form.save(commit=False)
					current.save()
					perfil = UserProfile()
					perfil.user = current
					perfil.save() 


					complete_signup(request, current,app_settings.EMAIL_VERIFICATION, "/")
					return HttpResponseRedirect(reverse("registered"))


		else:
			form = RegisterForm()
		return render(
			request, 
			'register.html',
				{
					"form": form
				}
			)
开发者ID:opennut,项目名称:stack-blog,代码行数:32,代码来源:views.py


示例7: post

    def post(self, request, *args, **kwargs):
        form = self.form_class(request.POST)
        message = None

        if form.is_valid():
            cd = form.cleaned_data
            user = User()

            user.username = cd["username"]
            user.email = cd["email"]
            user.set_password(cd["password"])

            try:
                user.save()

                # create UserProfile
                profile = UserProfile()
                profile.user = user
                profile.save()
                return HttpResponseRedirect("/")
            except IntegrityError:
                message = "The username you entered is taken"

        return render(
            request, self.template_name, {"form": form, "message": message}, context_instance=RequestContext(request)
        )
开发者ID:unscsprt,项目名称:TPB-mobile,代码行数:26,代码来源:views.py


示例8: _register

def _register(request):
    """
    用户注册
    """

    form = RegisterForm(request.POST)
    if form.is_valid():
        data = form.clean()
    else:
        return render('account_register.html',locals(),context_instance=RequestContext(request))

    # 检查email是否存在
    try:
        user = User.objects.get(username=data['username'])
    except User.DoesNotExist:
        pass
    else:
        messages.error(request,'email已经注册过,请换一个')
        return render('account_register.html',locals(),context_instance=RequestContext(request))

    # 创建新用户
    new_user = User.objects.create_user(username=data['username'],email=data['username'],
                                        password=data['password'])
    new_user.is_active = False
    new_user.save()
    new_profile = UserProfile(user=new_user,screen_name=data['screen_name'])

    try:
        new_profile.save()
        return HttpResponseRedirect('/accounts/active/%d/not_active/' %new_user.id)
    except Exception,e:
        messages.error(request,'服务器出现错误:%s' %e)
开发者ID:Josephye,项目名称:pythoner.net,代码行数:32,代码来源:views.py


示例9: register

def register(request):
    error = ''
    if request.method == 'GET':
        return render_to_response('usercenter_register.html',{},context_instance=RequestContext(request))
    else:
        username = request.POST['username'].strip()
        email = request.POST['email'].strip()
        password = request.POST['password'].strip()
        re_password = request.POST['re_password'].strip()

        if not username or not password or not email:
            error = u'任何字段都不能为空'
        if password != re_password:
            error = u'密码不一致'
        if User.objects.filter(username=username).count() > 0:
            error = u'用户已存在'
        if not error:
            user = User.objects.create_user(username=username,email=email,password=password)
            user.is_active = False
            user.save()
            profile = UserProfile(owner=user,avatar="http://res.myform.com/mmexport1445957752296.jpg")
            profile.save()

            new_code = str(uuid.uuid4()).replace("-","")
            expire_time = datetime.datetime.now() + datetime.timedelta(days=2)
            code_record = ActivateCode(owner=user,code=new_code,expire_timestamp=expire_time)
            code_record.save()

            activate_link = "http://%s%s" % ((request.get_host()),reverse("usercenter_activate",args=[new_code]))
            send_mail(u'激活邮件',u'您的激活链接为: %s' % activate_link,"[email protected]",[email],fail_silently=False)
        else:
            return render_to_response("usercenter_register.html",{"error":error},context_instance=RequestContext(request))
        return redirect('login')
开发者ID:lijunchao16,项目名称:Forum_project,代码行数:33,代码来源:views.py


示例10: save

    def save(self, profile_callback=None):
        """
        Creates the new ``User`` and ``RegistrationProfile``, and
        returns the ``User``.

        Also create the userprofile with additional info from the form.

        Differs from the default by using the email address as the username.
        """

        # construct a username based on the email address
        # need to truncate to 30 chars
        username = self.cleaned_data['email'].replace('@', '').replace('.', '')
        username = username[:30]

        new_user = RegistrationProfile.objects.create_inactive_user(username=username,
                                                                    password=self.cleaned_data[
                                                                        'password1'],
                                                                    email=self.cleaned_data[
                                                                        'email'],
                                                                    firstname=self.cleaned_data[
                                                                        'firstname'],
                                                                    lastname=self.cleaned_data[
                                                                        'lastname'],
                                                                    profile_callback=profile_callback)

        # now also create the userprofile for this user with
        # the extra information from the form

        profile = UserProfile(user=new_user)

        profile.save()

        return new_user
开发者ID:Signbank,项目名称:FinSL-signbank,代码行数:34,代码来源:forms.py


示例11: save

    def save(self, profile_callback=None):
        """
        Create the new ``User`` and ``RegistrationProfile``, and
        returns the ``User``.

        This is essentially a light wrapper around
        ``RegistrationProfile.objects.create_inactive_user()``,
        feeding it the form data and a profile callback (see the
        documentation on ``create_inactive_user()`` for details) if
        supplied.

        """
        new_user = RegistrationProfile.objects.create_inactive_user(
            username=self.cleaned_data['username'],
            password=self.cleaned_data['password1'],
            email=self.cleaned_data['email'],
            profile_callback=profile_callback)
        new_user.first_name = self.cleaned_data['first_name']
        new_user.last_name = self.cleaned_data['last_name']
        new_user.save()

        new_profile = UserProfile(
            user=new_user,
            fiscale_code=self.cleaned_data['codice_fiscale'],
            telephone=self.cleaned_data['telefono'],
            area=self.cleaned_data['area'],
            personal_data=self.cleaned_data['personal_data'],)
        new_profile.save()
        return new_user
开发者ID:MPBAUnofficial,项目名称:gsgisng,代码行数:29,代码来源:forms.py


示例12: test_mine

    def test_mine(self):

        user_info = {'username': 'guybrush2',
                 'email': '[email protected]',
                 'password': 'secret2'}

        new_user = User.objects.create_user(**user_info)
        user_profile = UserProfile()
        user_profile.user = new_user

        scan = ScanningEquipment.objects.get_or_create(name="Oil Lamp", modifier=0.2, image='icons/Scan/Oil Lamp.png', price=1, description="It won't allow you to see much but it's better than going in blind!", store_val=20)[0]
        dig = DiggingEquipment.objects.get_or_create(name='Spoon', modifier=0.3, time_modifier=5, image='icons/Tools/Spoon.png', price=1, description="What am I supposed to do with this?", store_val=30)[0]
        move = Vehicle.objects.get_or_create(name='Boots', modifier=10, image='icons/Vehicle/Boots.png', price=1, description="Two boots is better than no boots!")[0]
        user_profile.equipment = scan
        user_profile.tool = dig
        user_profile.vehicle = move

        accuracy = 0.2
        max_gold = 100
        gen = yieldgen.ScotlandQuadraticYieldGenerator(depth=10, max=max_gold, min=0)

        m = mine.Mine(gen, accuracy, user_profile)

        for block in m.blocks:
            self.failIf(block.cue == None)
            self.failIf(block.gold == None)
            self.failIf(block.dug == True)
            self.failIf((block.pos/10)>=1)
            self.failIf((block.pos/10)<=-1)
开发者ID:Loptr250,项目名称:Gold-Digger,代码行数:29,代码来源:tests.py


示例13: test_user_profile_data

    def test_user_profile_data(self):
        """
        Check if UserProfile object is created with appropriate  data
        """
        user_info = {'username': 'guybrush',
                 'email': '[email protected]',
                 'password': 'secret'}

        new_user = User.objects.create_user(**user_info)
        user_profile = UserProfile()
        user_profile.user = new_user

        scan = ScanningEquipment.objects.get_or_create(name="Oil Lamp", modifier=0.2, image='icons/Scan/Oil Lamp.png', price=1, description="It won't allow you to see much but it's better than going in blind!", store_val=20)[0]
        dig = DiggingEquipment.objects.get_or_create(name='Spoon', modifier=0.3, time_modifier=5, image='icons/Tools/Spoon.png', price=1, description="What am I supposed to do with this?", store_val=30)[0]
        move = Vehicle.objects.get_or_create(name='Boots', modifier=10, image='icons/Vehicle/Boots.png', price=1, description="Two boots is better than no boots!")[0]
        user_profile.equipment = scan
        user_profile.tool = dig
        user_profile.vehicle = move

        self.assertEqual(user_profile.user.username, 'guybrush')
        self.assertEqual(new_user.email, '[email protected]')
        self.failUnless(new_user.check_password('secret'))
        self.failIf(not new_user.is_active)
        self.failIf(not user_profile.equipment)
        self.failIf(not user_profile.tool)
        self.failIf(not user_profile.vehicle)
        self.assertEqual(user_profile.gold, 100)
        self.assertEqual(user_profile.games_played, 0)
        self.assertEqual(user_profile.game_overs, 0)
        self.assertEqual(user_profile.mines, 0)
开发者ID:Loptr250,项目名称:Gold-Digger,代码行数:30,代码来源:tests.py


示例14: register

 def register(self, request, form_class):
     new_user = super(MyRegistrationView).register(self, request, form_class)
     user_profile = UserProfile()
     user_profile.user = new_user
     user_profile.field = form_class.cleaned_data['field']
     user_profile.save()
     return user_profile
开发者ID:OmarWKH,项目名称:324-gamehub,代码行数:7,代码来源:regbackend.py


示例15: passet

def passet(request):
    """ Set credentials for new users registered with social auth. """
    ctx = {
        'title': _("Set your password"),
    }
    if request.method == 'POST':
        f = SocialAuthPassetForm(request.POST)
        if f.is_valid():
            user = User(request.user.id)
            user.username = f.cleaned_data['username']
            user.set_password(f.cleaned_data['password'])
            # Re-fetch user object from DB
            user = User.objects.get(pk=request.user.id)
            # Create user profile if not exists
            try:
                prof = UserProfile.objects.get(user=request.user.id)
            except:
                prof = UserProfile()
                prof.user = user
                prof.save()
            return redirect('user:index')
        ctx['form'] = SocialAuthPassetForm(request.POST)
        return render(request, 'userspace/pass.html', ctx)
    ctx['form'] = SocialAuthPassetForm()
    return render(request, 'userspace/pass.html', ctx)
开发者ID:14mmm,项目名称:CivilHub,代码行数:25,代码来源:views.py


示例16: add_offer

def add_offer(request):
    enterprise = Enterprise.objects.get(pk=request.user.id)
    error = None

    # If the enterprise has closed offers without feedback
    if enterprise.get_closed_offers_without_feedback():
        request.flash['error_message'] = 'No puede crear nuevas ofertas hasta entregar el feedback de las ya cerradas'
        return HttpResponseRedirect(reverse('bolsa_trabajo.views_enterprise.offer'))

    if request.method == 'POST':
        form = OfferForm(request.POST)
        if form.is_valid():
            offer = Offer.create_from_form(enterprise, form)
            offer.save()

            UserProfile.notify_staff_of_new_offer()

            request.flash['message'] = 'Oferta propuesta exitosamente, por favor espere a que un encargado la valide'
            url = reverse('bolsa_trabajo.views_account.index')
            return HttpResponseRedirect(url)
    else:
        form = OfferForm()

    return append_user_to_response(request, 'enterprise/add_offer.html', {
        'offer_form': form,
        'error': error
    })
开发者ID:goldenboy,项目名称:BolsaTrabajo,代码行数:27,代码来源:views_enterprise.py


示例17: my_account

def my_account(request):
    if request.user:
        try:
            profile = UserProfile.objects.get(user=request.user)
        except:
            profile = UserProfile(user=request.user)
            profile.save()
开发者ID:puaykai,项目名称:noodle,代码行数:7,代码来源:views.py


示例18: register

def register(request):
    if request.method == 'POST':
        username = request.POST.get('username', None)
        password = request.POST.get('password', None)

        try:
            user = User.objects.get(username=username)
        except User.DoesNotExist:
            pass
        else:
            return redirect('/')

        if username and password:
            user = User(
                username=username,
            )
            user.set_password(password)
            user.save()
            print 'saved'

            user_pro = UserProfile(
                user=user,
            )
            user_pro.save()
            print 'saved'

            user_url = '/users/%s' % user.id
            return redirect('/welcome')

    return redirect('/')
开发者ID:RizkyWellyanto,项目名称:yelpy,代码行数:30,代码来源:views.py


示例19: login_user

def login_user(request):
	url = request.GET.get('next','/')
	
	if url == reverse('accounts.views.create_account'):
		url = "/"

	if request.method == 'POST':
		form = LoginForm(request.POST)
		if form.is_valid():
			user = authenticate(username = form.cleaned_data['username'],password = form.cleaned_data['password'])
			
			if user:
				if user.is_active:
					try:
						user.get_profile()
					except UserProfile.DoesNotExist:
						profile = UserProfile(user=user)
						profile.save()
						
					login(request,user)
					return HttpResponseRedirect(url)
				else:
					messages.add_message(request,messages.WARNING,'Your account has been disabled')
					return HttpResponseRedirect("/")
			else:
				messages.add_message(request,messages.ERROR,'Username / password do not match')
		else:
			messages.add_message(request,messages.ERROR,'Username / password do not match')
		
	else:
		form = LoginForm()
		
	return render_to_response("login.html",{ 'form' : form,'next' : url },context_instance=RequestContext(request))
开发者ID:3241966,项目名称:PMS,代码行数:33,代码来源:views.py


示例20: signup

def signup(request):
    #http://stackoverflow.com/questions/21107655/using-django-registration-with-a-flat-ui-template
    #http://stackoverflow.com/questions/2339369/how-can-i-override-the-django-authenticationform-input-css-class
    #http://stackoverflow.com/questions/1453488/how-to-markup-form-fields-with-div-class-field-type-in-django/1504903#1504903
    context = RequestContext(request)

    registered = False

    if request.method == 'POST':
        user_form = UserForm(data=request.POST)
        if user_form.is_valid():
            user = user_form.save()
        user.set_password(user.password)

        #created django user
        user.save()

        #created racehub user, link django user to it
        new_racehub_user = UserProfile(user=user)
        new_racehub_user.save()

        registered = True

    else:
        user_form = UserForm()

    context_dict = {'user_form': user_form, 'registered': registered}

    return render_to_response('signup.html', context_dict, context)
开发者ID:OxiStudios,项目名称:NASCAR,代码行数:29,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Users类代码示例发布时间:2022-05-27
下一篇:
Python models.UserInfo类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap