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


Python UserProfile.save方法代码示例

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


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

示例1: savetrainers

# 需要导入模块: from userprofile.models import UserProfile [as 别名]
# 或者: from userprofile.models.UserProfile import save [as 别名]
def savetrainers():
    with open("sisteme_eklenecek_egitmenler.csv") as e:
        egitmenler = e.readlines()
        for egit in egitmenler:
            print egit
            cols=egit.split('|')
            try:
                egitu = User(first_name=cols[0],last_name=cols[1],email=cols[4].rstrip(),username=cols[4].rstrip())
                egitu.set_password = '123456'
                egitu.save()
                egitup = UserProfile(user=egitu,
                                     organization=cols[2],
                                     tckimlikno='',
                                     ykimlikno='',
                                     gender='',
                                     mobilephonenumber='',
                                     address='',
                                     job='',
                                     city='',
                                     title='',
                                     university='',
                                     department='',
                                     country=cols[3],
                                     is_instructor=True) 
                egitup.save()
                print "olustu"
                print cols[4].rstrip()
            except:
                print "olusmadi"
                print cols[4].rstrip()
开发者ID:bluevoda,项目名称:ab-kurs-kayit,代码行数:32,代码来源:modelops.py

示例2: save

# 需要导入模块: from userprofile.models import UserProfile [as 别名]
# 或者: from userprofile.models.UserProfile import save [as 别名]
 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'],
                                                                 sex=self.cleaned_data['sex'],
                                                                 age=self.cleaned_data['age'],                                                                    
                                                                 origin=self.cleaned_data['origin'],
                                                                 ethnicity=self.cleaned_data['ethnicity'],
                                                                 disadvantaged=self.cleaned_data['disadvantaged'],
                                                                 employment_location=self.cleaned_data['employment_location'],
                                                                 position=self.cleaned_data['position'],
                                                                 password=self.cleaned_data['password1'],
                                                                 email=self.cleaned_data['email'],
                                                                 profile_callback=profile_callback)
     
     # Extending the user model with UserProfile
     new_profile = UserProfile(user = new_user, 
                               sex=self.cleaned_data['sex'],
                               age=self.cleaned_data['age'],
                               origin=self.cleaned_data['origin'],
                               ethnicity=self.cleaned_data['ethnicity'],
                               disadvantaged=self.cleaned_data['disadvantaged'],
                               employment_location=self.cleaned_data['employment_location'],
                               position=self.cleaned_data['position'])
     new_profile.save()
     return new_user
开发者ID:djredhand,项目名称:phtc,代码行数:37,代码来源:forms.py

示例3: save

# 需要导入模块: from userprofile.models import UserProfile [as 别名]
# 或者: from userprofile.models.UserProfile import save [as 别名]
 def save(self, commit=True):
     if not commit:
         raise NotImplementedError("Can't create User and UserProfile without database save")
     user = super(UserCreateForm, self).save(commit=True)
     user_profile = UserProfile(user=user, first_name=self.cleaned_data['first_name'], second_name = self.cleaned_data['second_name'], status=True, latitude = self.cleaned_data['latitude'], longitude = self.cleaned_data['longitude'], timestamp=datetime.datetime.now())
     user_profile.save()
     return user, user_profile
开发者ID:suchareek,项目名称:wlasny,代码行数:9,代码来源:forms.py

示例4: user_registration

# 需要导入模块: from userprofile.models import UserProfile [as 别名]
# 或者: from userprofile.models.UserProfile import save [as 别名]
def user_registration(request):
    if request.user.is_authenticated():
        return redirect('/')

    form = RegisterForm(request.POST or None)

    if form.is_valid():
        user = form.save()
        user.set_password(user.password)
        user.save()
        profile = UserProfile()
        profile.user = user
        profile.save()
        send_mail(
            'Welcome to ' + DOMAIN + '!',
            'Someone try register on site ' + DOMAIN +
            '. To confirm registration visit this link ' + confirmation_link +
            '. If you aren\'t try to register than  just ignore this email.	''',
            '[email protected]',
            ['[email protected]'],
            fail_silently=False)
        return redirect('/')

    context = RequestContext(request)
    return render_to_response('userprofile/registration.html',
                              {'form': form}, context)
开发者ID:chizel,项目名称:os_dj,代码行数:28,代码来源:views.py

示例5: create_twitter_profile

# 需要导入模块: from userprofile.models import UserProfile [as 别名]
# 或者: from userprofile.models.UserProfile import save [as 别名]
def create_twitter_profile(id, oauth_token, oauth_token_secret, name):
    profile = UserProfile()
    profile.user_id = id
    profile.oauth_token = oauth_token
    profile.oauth_secret = oauth_token_secret
    profile.screen_name = name
    profile.save()
开发者ID:,项目名称:,代码行数:9,代码来源:

示例6: edit_profile

# 需要导入模块: from userprofile.models import UserProfile [as 别名]
# 或者: from userprofile.models.UserProfile import save [as 别名]
def edit_profile(request):
    context = RequestContext(request)

    try:
        user_profile = UserProfile.objects.get(user=request.user)
    except UserProfile.DoesNotExist:
        user_profile = UserProfile(user=request.user)

    if request.method == 'POST':
        edit_form = ProfileForm(request.POST)
        if edit_form.is_valid():
            data = edit_form.cleaned_data

            user_profile.full_name = data['full_name']
            user_profile.bio = data['bio']
            user_profile.save()

            return HttpResponseRedirect(
                reverse('userprofile.views.profile',
                        args=(),
                        kwargs={'username': request.user.username}))
        else:
            print edit_form.errors
    else:
        edit_form = ProfileForm({
            'full_name': user_profile.full_name,
            'bio': user_profile.bio
        })

    context_dict = {
        'edit_form': edit_form
    }

    return render_to_response('userprofile/edit.html', context_dict, context)
开发者ID:jatinshah,项目名称:alphatracker,代码行数:36,代码来源:views.py

示例7: createTestUser

# 需要导入模块: from userprofile.models import UserProfile [as 别名]
# 或者: from userprofile.models.UserProfile import save [as 别名]
def createTestUser(request):
    numberOfFriends = request.REQUEST['numfriends']
    response = dict()

    name = "test%d" % random.randint(1, 10000000)
    email = "%[email protected]" % name
    firstName = name
    lastName = name
    user = User(username=email, email=email, first_name=firstName,
                last_name=lastName, password=0)

    user.save()
    userProfile = UserProfile(user=user, device='ios')
    userProfile.save()

    numberOfFriends = int(numberOfFriends)
    friends = UserProfile.objects.all().order_by('-id')[:numberOfFriends]

    blockedFriends = userProfile.blockedFriends.all()
    for friend in friends:
        if friend not in friend.friends.all():
            friend.friends.add(userProfile)
            userProfile.friends.add(friend)

    friends = userProfile.friends.all()
    response['friends'] = list()
    for friend in friends:
        friendData = getUserProfileDetailsJson(friend)
        response['friends'].append(friendData)

    statusesResponse, newSince = getNewStatusesJsonResponse(userProfile, None, None, None)
    myStatusesResponse = getMyStatusesJsonResponse(userProfile)
    groupsData = getMyGroupsJsonResponse(userProfile)

    buddyupSettings = getSettingsData(userProfile)

    newSince = datetime.now().strftime(MICROSECOND_DATETIME_FORMAT)
    notifications = getNotificationsJson(userProfile)
    chatData = getNewChatsData(userProfile)

    response['success'] = True
    response['firstname'] = userProfile.user.first_name
    response['lastname'] = userProfile.user.last_name
    response['userid'] = userProfile.id
    response['facebookid'] = userProfile.facebookUID
    response['statuses'] = statusesResponse
    response['groups'] = groupsData
    response['mystatuses'] = myStatusesResponse
    response['chats'] = chatData
    response['newsince'] = newSince
    response['settings'] = buddyupSettings
    response['notifications'] = notifications
    response['favoritesnotifications'] = userProfile.favoritesNotifications

    return HttpResponse(json.dumps(response))
开发者ID:gmuresan,项目名称:buddyup-django-server,代码行数:57,代码来源:api_functions.py

示例8: register

# 需要导入模块: from userprofile.models import UserProfile [as 别名]
# 或者: from userprofile.models.UserProfile import save [as 别名]
def register(request):
    if request.method == 'POST':
        form = NewUserForm(request.POST)
        if form.is_valid():
            new_user = form.save()
            userprofile = UserProfile(user=new_user, steamURL=form.cleaned_data["steamURL"])
            userprofile.save()
            return HttpResponseRedirect("/inventory")
    else:
        form = NewUserForm()
    return render(request, "registration/register.html", {
        'form': form,
    })
开发者ID:carlinhus,项目名称:steam-api,代码行数:15,代码来源:views.py

示例9: save

# 需要导入模块: from userprofile.models import UserProfile [as 别名]
# 或者: from userprofile.models.UserProfile import save [as 别名]
 def save(self, commit=True):
     if not commit:
         raise NotImplementedError("Can't create User and UserProfile without database save")
     user = super(UserCreateForm, self).save(commit=True)
     user_profile = UserProfile(
         user = user,
         latitude = self.cleaned_data['latitude'],
         longitude = self.cleaned_data['longitude'],
         points = 0,
         rank_points = 0,
         avatar = self.cleaned_data['avatar'])
     user_profile.save()
     return user, user_profile
开发者ID:ibiss,项目名称:breaking,代码行数:15,代码来源:forms.py

示例10: createInst

# 需要导入模块: from userprofile.models import UserProfile [as 别名]
# 或者: from userprofile.models.UserProfile import save [as 别名]
	def createInst(self,postrequest,numofinst):
		insts=[]
		uprof=UserProfileOPS()
		for i in xrange(numofinst):
			n_str=str(i)+'-'
			upass=uprof.generatenewpass() # uretilen parola olusturulan kullaniciya gonderilecek.
			inst=User(first_name=postrequest[n_str+'first_name'],last_name=postrequest[n_str+'last_name'],
						email=postrequest[n_str+'email'],username=postrequest[n_str+'email'],password=upass)
			inst.save()
			instprof=UserProfile(job=postrequest[n_str+'job'],title=postrequest[n_str+'title'],
                        organization=postrequest[n_str+'organization'],is_instructor=True,
						user=inst)
			instprof.save()
			insts.append(instprof)
		return insts
开发者ID:unicod3,项目名称:ab-kurs-kayit,代码行数:17,代码来源:coursesubops.py

示例11: test_submit_success

# 需要导入模块: from userprofile.models import UserProfile [as 别名]
# 或者: from userprofile.models.UserProfile import save [as 别名]
    def test_submit_success(self):
        uprofile = UserProfile(user=self.user, token='randomtoken')
        uprofile.save()

        response = self.client.get(
            reverse('collector:bookmark', args=(self.user.username,)) + "?" +
            "&".join(
                key + '=' + value for key, value in {
                    'url': 'http://www.moto-net.com/rss_actu.xml',
                    'from': 'me',
                    'source': 'all',
                    'token': 'randomtoken',
                }.items()
            ))
        self.assertEqual(response.status_code, 202)
开发者ID:EvaSDK,项目名称:collectr,代码行数:17,代码来源:tests.py

示例12: post

# 需要导入模块: from userprofile.models import UserProfile [as 别名]
# 或者: from userprofile.models.UserProfile import save [as 别名]
 def post(self, request, *args, **kwargs):
     form = RegistrationForm(request.POST)
     if form.is_valid():
         user = User.objects.create_user(
             username=form.cleaned_data['username'],
             email=form.cleaned_data['email'],
             password=form.cleaned_data['password'],
             first_name=form.cleaned_data['first_name'],
             last_name=form.cleaned_data['last_name'])
         user.save()
         userprofile = UserProfile(user=user, organizacion=request.user.get_profile().organizacion)
         userprofile.save()
         return HttpResponseRedirect('/accounts/register_success/')
     else:
         return render_to_response('register.html', {'form': form}, context_instance=RequestContext(request))
开发者ID:hnejadi,项目名称:shoppingplanner,代码行数:17,代码来源:views.py

示例13: save

# 需要导入模块: from userprofile.models import UserProfile [as 别名]
# 或者: from userprofile.models.UserProfile import save [as 别名]
    def save(self, commit=True):
        user = super(MyRegistrationForm, self).save(commit=False)
        user.email = self.cleaned_data['email']
        user.set_password(self.cleaned_data['password1'])
        profile = UserProfile(user=user)

        profile.user = user
        profile.user.self_description = "self_description"
        profile.user.line_of_work = "line_of_work"
        profile.user.hobbies = "hobbies"
        profile.user.owns_car = "owns_car"
        profile.user.vehicle_model = "vehicle_model"

        if commit:
            user.save()
            profile.save()

        return user
开发者ID:cryanperkins,项目名称:PoolRyde,代码行数:20,代码来源:forms.py

示例14: show_avatar

# 需要导入模块: from userprofile.models import UserProfile [as 别名]
# 或者: from userprofile.models.UserProfile import save [as 别名]
def show_avatar(value):
    '''
    显示头像
    '''
    if value.is_authenticated:
        try:
            UserProfile.objects.get(user=value)
            #user不是超级用户但是已经注册
            avatar = UserProfile.objects.get(user=value).picture
        except UserProfile.DoesNotExist:
            #user是超级用户或第三方用户但是没有注册
            newuser = UserProfile(
                        user_id = value.id,
                        width_field = 100,
                        height_field = 100
                    )
            newuser.save()
            avatar = newuser.picture
        return avatar.url
开发者ID:lalahahaane,项目名称:cx-blog,代码行数:21,代码来源:myfilters.py

示例15: edit_user

# 需要导入模块: from userprofile.models import UserProfile [as 别名]
# 或者: from userprofile.models.UserProfile import save [as 别名]
def edit_user(request, id=None):
    if id:
        action = "edit"
        userprofile = get_object_or_404(UserProfile, id=id)
        user = userprofile.user
        initial = { 'username':user.username,
                    'name':userprofile.name,
                    'password':"",
                    'email':user.email,
                    'phone_number':userprofile.phone_number,
                    'info':userprofile.info,
                    'is_staff':user.is_staff,
                  }
    else:
        action = "add"
        userprofile = None
        initial = None
    if request.POST:
        form = UserForm(request.POST, instance=userprofile)
        if form.is_valid():
            if userprofile:
                user = userprofile.user
            else:
                userprofile = UserProfile()
                user = User()
                userprofile.user = user
                
            userprofile.user.username = form.cleaned_data['username']
            userprofile.name = form.cleaned_data['name']
            userprofile.user.email = form.cleaned_data['email']
            userprofile.phone_number = form.cleaned_data['phone_number']
            userprofile.info = form.cleaned_data['info']
            userprofile.user.is_staff = form.cleaned_data['is_staff']
            if form.cleaned_data['password']:
                userprofile.user.set_password(form.cleaned_data['password'])
            user.save()
            userprofile.user = user
            userprofile.save()
            request.user.message_set.create(message="User '%s' was %sed." % (userprofile.name, action))
            return HttpResponseRedirect("/user/manage/")
    else:
        form = UserForm(initial=initial, instance=userprofile)
    return render_to_response_context(request, 'userprofile/manage/edit.html', {'form':form, 'action':action})
开发者ID:Joeboy,项目名称:django-sharestuff,代码行数:45,代码来源:views.py


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