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


Python Profile.save方法代码示例

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


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

示例1: register

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import save [as 别名]
def register(request):
    if request.method == 'POST':
        span = {1:False}
        form = NewUserForm(request.POST)
        if form.is_valid():
            new_user = form.save()
            user = auth.authenticate(
                email=request.POST.get('email', ''),
                password=request.POST.get('password1',''))
            if user is not None:
                auth.login(request, user)
                profile = Profile(user=user)
                profile.save()
                settings = Settings(user=user)
                settings.save()
                return HttpResponseRedirect("/create/profile/")
            else:
                span[1] = True
                form = NewUserForm()
    else:
        form = NewUserForm()
        span = {1:False}
    return render(request, "registration/register.html", {
        'form': form,
        'span': span
        })
开发者ID:9oh9,项目名称:tangol_app,代码行数:28,代码来源:views.py

示例2: signup_user

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import save [as 别名]
def signup_user(request):
    """
    view untuk fungsionalitas pendaftaran user
    """
    template = "accounts/signup.html"
    if request.POST:
        form = RegistrationForm(request.POST)
        if form.is_valid():
            nohp = form.cleaned_data["nohp"]
            sec_question = form.cleaned_data['sec_question']
            sec_answer = form.cleaned_data['sec_answer']
            user = form.save()
            profile = Profile()
            profile.user = user
            profile.nohp = nohp
            profile.sec_question = sec_question
            profile.sec_answer = sec_answer
            profile.save()
            request.session['signup_success'] = True
            return HttpResponseRedirect(reverse('signup_success'))
    else:
        form = RegistrationForm()
    return render_to_response(template,
        {"form": form},
        context_instance=RequestContext(request))
开发者ID:sakti,项目名称:ittelkomnewsmap,代码行数:27,代码来源:views.py

示例3: profile_edited

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import save [as 别名]
def profile_edited(request):
    user = request.user
    username = user.username
    tagline = request.POST.get("tagline")
    location = request.POST.get("location")
    interests = request.POST.getlist("interests[]")
    other_interests = request.POST.get("other_interests")
    skills = request.POST.getlist("skills[]")
    # other_skills = request.POST.get('other_skills')
    resources = request.POST.getlist("resources[]")
    # other_resources = request.POST.get('other_resources')
    wdywtd = request.POST.get("wdywtd")
    needs = request.POST.get("needs")
    offerings = request.POST.get("offerings")
    ideal_collaboration = request.POST.get("ideal_collaboration")
    profile = Profile(
        username=username,
        tagline=tagline,
        location=location,
        other_interests=other_interests,
        wdywtd=wdywtd,
        needs=needs,
        offerings=offerings,
        ideal_collaboration=ideal_collaboration,
    )
    for cat in interests:
        setattr(profile, cat, True)
    for ski in skills:
        setattr(profile, ski, True)
    for res in resources:
        setattr(profile, res, True)
    profile.save()
    redirect_url = "/profile/%s" % (username)
    return redirect(redirect_url)
开发者ID:CassT,项目名称:myconet,代码行数:36,代码来源:views.py

示例4: save

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import save [as 别名]
 def save(self, user):
     try:
         data = user.get_profile()
     except:
         data = Profile(user=user)
     data.city = self.cleaned_data["city"]
     data.save()
开发者ID:compufreakjosh,项目名称:custom_django_registration,代码行数:9,代码来源:profile.py

示例5: register

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import save [as 别名]
def register(request):
	form = UserRegistrationForm(request.POST)
	if form.is_valid():
	#TODO Add functionality to save
		email = form.cleaned_data['email']
		first_name = form.cleaned_data['first_name']
		last_name = form.cleaned_data['last_name']
		password = form.cleaned_data['password']
		password_again = form.cleaned_data['password_again']
		if password != password_again:
			return my_render(request, 'books/signup.html', {'form': UserRegistrationForm(), 'message': 'passwords did not match' })
		elif len(User.objects.filter(username = email)):
			return my_render(request, 'books/signup.html', {'form': UserRegistrationForm(), 'message': 'ERROR: email already exists' })
		elif "" in [email, first_name, last_name, password, password_again]:
			return my_render(request, 'books/signup.html', {'form': UserRegistrationForm(), 'message': 'all fields should be filled' })
		else:
			user = User.objects.create_user(username = email, email=None, password=password, last_name=last_name, first_name=first_name)
			user.save()
			a = Profile(user = user, name = user.first_name + " " + user.last_name, email = user.username)
			a.save()
			user = authenticate(username=email, password =password)
			login(request, user)
			context = {'user': request.user}
	
			return my_render(request, 'books/homepage.html', context)
开发者ID:meet-projects,项目名称:bookLists-y2-2013,代码行数:27,代码来源:views.py

示例6: signup

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import save [as 别名]
def signup(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            user = User.objects.create_user(
                username=form.cleaned_data['username'],
                password=form.cleaned_data['password1'],
                email=form.cleaned_data['email']
            )
            user = authenticate(username=form.cleaned_data['username'],
                                    password=form.cleaned_data['password1'])
            profile = Profile(
                first_name=form.cleaned_data['first_name'],
                last_name=form.cleaned_data['last_name'], user=user)
            profile.save()
            login(request, user)
            msg = ("Thanks for registering! You are now logged in and ready to "
                   "go questing.")
            messages.info(request, msg)
            return HttpResponseRedirect(reverse('quest_maker_app:homepage'))
    else:
        form = RegistrationForm()

    variables = RequestContext(request, {'form': form})

    return render_to_response('registration/signup.html', variables)
开发者ID:catherinev,项目名称:quest_maker,代码行数:28,代码来源:views.py

示例7: get_profiles

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import save [as 别名]
def get_profiles():
    """Fetches some JSON and saves it in the database."""
    if request.method == "POST":
        # Get some JSON
        r = requests.get("https://api.github.com/users/{}".format(request.form["username"]))

        # Make sure we got some JSON back
        if r.status_code != 200:
            flash("That username didn't work. Please try again.")
            return redirect(url_for(profiles))

        # Load the JSON into a Python dict
        profile_dict = r.json()

        # Create a new Profile object with Mongoengine, passing in the dict
        profile_object = Profile(raw_json=profile_dict)
        profile_object.save()

        # Prepare a message for the user
        flash("Saved a new profile.")

        # Redirect back to the profile list
        return redirect(url_for("profiles"))
    else:
        flash("That URL only accepts POST requests.")
        return redirect(url_for("profiles"))
开发者ID:CodeSelfStudy,项目名称:flask_mongoengine_example,代码行数:28,代码来源:app.py

示例8: _add_profile

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import save [as 别名]
def _add_profile(data, user, id=0):
    if id:
        obj = get_profile(id)
        update_ref_count(obj.construct_list, -1)
        obj.name = data[NAME]

        if not data[CONSTRUCT_LIST]:
            raise IgniteException(ERR_PROF_IS_EMPTY)
        else:
            obj.construct_list = data[CONSTRUCT_LIST]

        obj.submit = data[SUBMIT]
        obj.updated_by = user
        update_ref_count(data[CONSTRUCT_LIST], +1)
        obj.save()
        return obj
    else:
        fp_object = Profile()
        fp_object.name = data[NAME]

        if not data[CONSTRUCT_LIST]:
            raise IgniteException(ERR_PROF_IS_EMPTY)
        else:
            fp_object.construct_list = data[CONSTRUCT_LIST]

        fp_object.submit = data[SUBMIT]
        fp_object.updated_by = user
        update_ref_count(data[CONSTRUCT_LIST], +1)
        fp_object.save()
        return fp_object
开发者ID:datacenter,项目名称:ignite,代码行数:32,代码来源:feature.py

示例9: join

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import save [as 别名]
def join(request, code):
    """ 
        TODO: After registring a user invitation should be disable.
    """
    if not check_invitation(code):
        messages.error(request, 'Your personal URL is incorrect, please ask for new invitation or provide proper url')
        return redirect('index')

    from forms import JoinForm
    if request.method == 'POST':
        form = JoinForm(request.POST) 
        if form.is_valid():
            profile=Profile(first_name=form.cleaned_data['first_name'],
                            last_name=form.cleaned_data['last_name'],
                            unit=form.cleaned_data['unit'],
                            email=form.cleaned_data['email'],
                            key=generate_key())
            profile.save()
            keywords = __to_keywords(form.cleaned_data['keywords'])
            profile.keywords.clear();
            for k in keywords:
                profile.keywords.add(k)
            profile.save()

            return redirect('homepage', code=profile.key 
                            )
    else:
        form = JoinForm(initial={'key':code}) 
    
    return render_to_response('researchers/join.html', {
                              'form': form,
                              'key':code,  # invitation code
                              },context_instance=RequestContext(request))
    
    return render_to_response('researchers/join.html', {'form':form}, context_instance=RequestContext(request))
开发者ID:Top500Innovators,项目名称:but,代码行数:37,代码来源:views.py

示例10: post

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import save [as 别名]
    def post(self, request, *args, **kwargs):

        request.data.pop('active', None)
        skills = request.data.pop('skills')

        now = datetime.utcnow()

        compensation = request.data.pop('compensation')
        comp, created = Compensation.objects.get_or_create(**compensation)

        profile_dict = request.data
        profile_dict['compensation'] = comp
        if 'profile_id' not in profile_dict:
            okStatus = status.HTTP_201_CREATED
        else:
            okStatus = status.HTTP_200_OK

        profile = Profile(**profile_dict)
        profile.save()

        # create skills and mapping
        for skill in skills:
            skill_data = {
                'skill': skill,
                # 'profile': profile.pk
            }
            skill, created = Skill.objects.get_or_create(**skill_data)
            skill_mapping = {
                'profile': profile,
                'skill': skill
            }
            mapping, created = SkillId.objects.get_or_create(**skill_mapping);

        z = ProfileSerializer(profile)
        return Response(z.data, status=okStatus)
开发者ID:benwu9999,项目名称:userservice,代码行数:37,代码来源:views.py

示例11: handle_join

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import save [as 别名]
def handle_join(request):
    # Handle request here
    vkuser = request.session.get('vk_user')
    errors = {}
    phone = request.REQUEST.get('phone')
    email = request.REQUEST.get('email')
    if phone:
        if not phone_validate(phone):
            errors["phone_error"] = u'Введите правильный телефон'
    else:
        errors['phone_error'] = u'Это поле не должно быть пустым'
        
    if email:
        if not email_validate(email):
            errors['email_error'] = u'Введите корректный e-mail'
    else:
        errors['email_error'] = u'Это поле не должно быть пустым'
    
    if errors:
        ec = {'vkuser': vkuser, 'email': email, 'phone': phone}
        ec.update(errors)
        return render_to_response('joinus.html', ec, context_instance=RequestContext(request))
    else:
        p = Profile(name = ' '.join([vkuser.first_name, vkuser.last_name]),
            vkontakte_id = vkuser.uid, email = email, phone = phone,
            photo = vkuser.photo, photo_medium = vkuser.photo_medium,
            status = u'Игрок')
        p.save()
        return redirect('/thankyou/')
开发者ID:nskrypnik,项目名称:Mafia10,代码行数:31,代码来源:views.py

示例12: save_manifest_in_model

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import save [as 别名]
def save_manifest_in_model(house_id, m3u8_manifest):
    
    # 
    # Search de Video, if exist return Error
    try:
	video = Video.objects.get(house_id=house_id)
	return False
    except:
	video = Video()
	video.house_id = house_id
	video.format   = 'hls'
	video.save()

    for rendition in m3u8_manifest.files:
	profile = Profile()
	profile.video = video
	profile.bandwidth  	= rendition['bandwidth']
        profile.average    	= rendition['average']
        profile.codecs     	= rendition['codecs']
        profile.resolution 	= rendition['resolution']
        profile.filename   	= rendition['filename']
	profile.version	   	= rendition['rendition'].header['version']
	profile.media_seq  	= rendition['rendition'].header['media_seq']
	profile.allow_cache	= rendition['rendition'].header['allow_cache']
	profile.target_duration = rendition['rendition'].header['target_duration']
	profile.save()
	for tsfile in rendition['rendition'].files:
	    profile_file = ProfileFile()
	    profile_file.profile  = profile
	    profile_file.number   = tsfile['number']
	    profile_file.extinf   = tsfile['extinf']
	    profile_file.filename = tsfile['filename']
	    profile_file.save()

    return True
开发者ID:emilianobilli,项目名称:content-manager,代码行数:37,代码来源:Utils.py

示例13: form_valid

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import save [as 别名]
 def form_valid(self, form):
     login           = form.cleaned_data['login']
     password1       = form.cleaned_data['password1']
     first_name      = form.cleaned_data['first_name']
     image           = form.cleaned_data['image']
     new_user = User(
         username=login,
         first_name=first_name,
     )
     new_user.set_password(password1)
     try:
         new_user.full_clean()
     except ValidationError:
         self.set_message(u'Не правильно заполненна форма', True)
         return super(CreateCompanyView, self).form_invalid(form)
     new_user.save()
     new_profile = Profile(
         user=new_user,
         is_company=True,
         is_report=False,
         is_super_user=False,
         image=image,
     )
     new_profile.save()
     new_company = Company(com_user=new_user)
     new_company.save()
     self.set_message(u'Компания успешно добавлена.')
     return super(CreateCompanyView,self).form_valid(form)
开发者ID:Alexandrov-Michael,项目名称:helpdesk,代码行数:30,代码来源:views.py

示例14: registration

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import save [as 别名]
def registration(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)

        if form.is_valid():
            user = User.objects.create_user(form.cleaned_data['username'], form.cleaned_data['email'], form.cleaned_data['password1'])
            user.first_name = form.cleaned_data['first_name']
            user.last_name = form.cleaned_data['last_name']
            user.save()

            profile = Profile(user_id=user.id, phone=form.cleaned_data['phone'])
            profile.save()
            messages.info(request, 'Registrácia prebehla úspešne')

            return HttpResponseRedirect('/')
    else:
        form = RegistrationForm()
    
    page_info = {}
    page_info['title'] = 'Registrácia nového uživateľa'
    page_info['page'] = 1
    page_info['form_name'] = 'registration'
    page_info['form_action'] = '/registracia/'
    
    return render_to_response('registracia.html', {'form': form, 'countInfo': countInfo, 'recentNews': recentNews, 
                                                   'page_info': page_info}, 
                              context_instance=RequestContext(request))
开发者ID:huzvak,项目名称:bachelor-thesis-nevyhadzujto.sk,代码行数:29,代码来源:views.py

示例15: create_profile

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import save [as 别名]
def create_profile(user, oauth_token, secret_token):
    profile = Profile()
    profile.user = user
    profile.oauth_token = oauth_token
    profile.oauth_secret = secret_token
    profile.save()
    return
开发者ID:IAbuElRuzz,项目名称:ReTweeted,代码行数:9,代码来源:dbapi.py


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