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


Python UserModel.save方法代码示例

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


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

示例1: create_inactive_user

# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import save [as 别名]
    def create_inactive_user(self, site, new_user=None, send_email=True, request=None, **user_info):
        """
        Create a new, inactive ``User``, generate a
        ``RegistrationProfile`` and email its activation key to the
        ``User``, returning the new ``User``.

        By default, an activation email will be sent to the new
        user. To disable this, pass ``send_email=False``.
        Additionally, if email is sent and ``request`` is supplied,
        it will be passed to the email template.

        """
        if new_user == None:
            password = user_info.pop('password')
            new_user = UserModel()(**user_info)
            new_user.set_password( password )
        new_user.is_active = True
        new_user.save()
        
        #user_for_choice = Student(student_text = new_user.username)
        #user_for_choice.save()

        registration_profile = self.create_profile(new_user)

        if send_email:
            registration_profile.send_activation_email(site, request)

        return new_user
开发者ID:York-Lee,项目名称:recommendation-letter,代码行数:30,代码来源:models.py

示例2: create_inactive_user

# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import save [as 别名]
    def create_inactive_user(self, username, email, password,
                             site, send_email=True, request=None):

        """
        Create a new, inactive ``User``, generate a
        ``RegistrationProfile`` and email its activation key to the
        ``User``, returning the new ``User``.

        By default, an activation email will be sent to the new
        user. To disable this, pass ``send_email=False``.
        Additionally, if email is sent and ``request`` is supplied,
        it will be passed to the email template.

        """

        new_user = UserModel().objects.create_user(username, email, password)
        new_user.is_active = False
        new_user.save()

        registration_profile = self.create_profile(new_user)
        #send_email = False
        if send_email:
            registration_profile.send_activation_email(site, request)

        return new_user
开发者ID:tnbt27,项目名称:Registration_Profile_Search_boilerplate,代码行数:27,代码来源:models.py

示例3: test_users_can_fill_out_registration_form_and_create_profile

# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import save [as 别名]
    def test_users_can_fill_out_registration_form_and_create_profile(self):
        # Tired of Twitter, Facebook, and Instagram Brad has luckily heard
        # about the new social network on the block so he visits the website in
        # his browser
        self.browser.get(self.live_server_url + reverse('home'))

        # He notices that the title mentions TSN (so much cooler than Twitter
        # or Facebook) AND the page welcomes him to the site
        self.assertIn('TSN', self.browser.title)
        header_text = self.browser.find_element_by_tag_name('h1').text
        self.assertIn('Welcome', header_text)

        # He sees a link telling him to Register and he clicks it
        self.browser.find_element_by_id('register').click()

        # He winds up on a brand new page
        register_url = self.browser.current_url
        self.assertIn('/accounts/register', register_url)

        # Brad fills out the form on this page to create an account with TSN
        # and presses enter
        for name, value in [('first_name', 'Brad'),
                            ('last_name', 'Pitt'),
                            ('username', 'brad'),
                            ('email', '[email protected]'),
                            ('password1', 'bradiscool'),
                            ('password2', 'bradiscool\t\n')]:
            self.browser.find_element_by_name(name).send_keys(value)

        # He finds himself on another page telling him to activate his account
        p_text = self.browser.find_element_by_tag_name('p').text
        self.assertEquals('Please check your email to complete the registration process.', p_text)

        # After activating, he goes to the login page and logs in
        brad = UserModel().objects.get(username='brad')
        brad.is_active = True
        brad.save()
        self.browser.get(self.live_server_url + reverse('auth_login'))
        self.browser.find_element_by_name('username').send_keys('brad')
        self.browser.find_element_by_name('password').send_keys('bradiscool\t\n')

        # He is then immediately redirected to a page asking him to create a
        # profile
        self.browser.implicitly_wait(3)
        self.assertIn('profile/create', self.browser.current_url)

        # He provides his birthday and his gender
        self.browser.find_element_by_name('birthday').send_keys('12/18/1963')
        self.browser.find_element_by_name('gender').send_keys('M\t\n')

        # He is now on the homepage again, this time he sees a post box
        self.browser.implicitly_wait(3)
        self.assertEqual(self.live_server_url + reverse('home'), self.browser.current_url)
        self.assertIn('new_post', self.browser.page_source)
开发者ID:jackieaskins,项目名称:The-Social-Network,代码行数:56,代码来源:test_new_user_access.py

示例4: register

# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import save [as 别名]
    def register(self, request, **cleaned_data):
        username, email, password, first_name, last_name = cleaned_data['username'], cleaned_data['email'], cleaned_data['password1'], cleaned_data['first_name'], cleaned_data['last_name']
        theuser = UserModel().objects.create_user(username = username,
            password = password,
            email = email,
            first_name = first_name,
            last_name = last_name
        )
        theuser.save()
        
        profile = UserProfile(user = theuser, location = cleaned_data['location'], career = cleaned_data['career'])
        profile.save()
        #(username, email, password, first_name, last_name)

        new_user = authenticate(username=username, password=password)
        login(request, new_user)
        signals.user_registered.send(sender=self.__class__,
                                     user=new_user,
                                     request=request)
        return new_user
开发者ID:junyangchen,项目名称:bixplorer,代码行数:22,代码来源:views.py

示例5: create_inactive_user

# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import save [as 别名]
    def create_inactive_user(self, username, email, password,
                             site, send_email=True):
        """
        Create a new, inactive ``User``, generate a
        ``RegistrationProfile`` and email its activation key to the
        ``User``, returning the new ``User``.

        By default, an activation email will be sent to the new
        user. To disable this, pass ``send_email=False``.

        """
        new_user = UserModel().objects.create_user(username, email, password)
        new_user.is_active = False
        new_user.save()

        registration_profile = self.create_profile(new_user)

        if send_email:
            registration_profile.send_activation_email(site)

        return new_user
开发者ID:jimblanc,项目名称:django-registration,代码行数:23,代码来源:models.py


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