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

Python models.create_profile函数代码示例

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

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



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

示例1: setUp

    def setUp(self):
        self.client = Client()
        self.locale = "en"

        django_user = User(username=self.test_username, email=self.test_email)
        self.user = create_profile(django_user)
        self.user.set_password(self.test_password)
        self.user.save()

        django_user2 = User(username=self.test_username2, email=self.test_email2)
        self.user2 = create_profile(django_user2)
        self.user2.set_password(self.test_password2)
        self.user2.save()

        self.course = course_model.create_course(
            **{
                "title": self.test_title,
                "hashtag": self.test_hashtag,
                "description": self.test_description,
                "language": "en",
                "organizer_uri": "/uri/users/testuser",
            }
        )
        content_model.update_content(
            self.course["about_uri"], "About", "This is the about content", "/uri/users/testuser"
        )
开发者ID:ralfepoisson,项目名称:lernanta,代码行数:26,代码来源:tests.py


示例2: setUp

    def setUp(self):
        self.client = Client()
        self.locale = 'en'

        django_user = User(
            username=self.test_username,
            email=self.test_email,
        )
        self.user = create_profile(django_user)
        self.user.set_password(self.test_password)
        self.user.save()
        
        django_user2 = User(
            username=self.test_username2,
            email=self.test_email2,
        )
        self.user2 = create_profile(django_user2)
        self.user2.set_password(self.test_password2)
        self.user2.save()


        self.course = course_model.create_course(
            **{
                "title": self.test_title,
                "hashtag": self.test_hashtag,
                "description": self.test_description,
                "language": "en",
                "organizer_uri": '/uri/users/testuser',
            }
        )
开发者ID:colus001,项目名称:lernanta,代码行数:30,代码来源:tests.py


示例3: setUp

    def setUp(self):
        self.locale = "en"
        django_user = User(username=self.test_username, email=self.test_email)
        self.user = create_profile(django_user)
        self.user.set_password(self.test_password)
        self.user.save()

        django_user_two = User(username="anotheruser", email="[email protected]")
        self.user_two = create_profile(django_user_two)
        self.user_two.set_password("testpassword")
        self.user_two.save()
        self.old_recaptcha_pubkey = settings.RECAPTCHA_PUBLIC_KEY
        self.old_recaptcha_privkey = settings.RECAPTCHA_PRIVATE_KEY
        settings.RECAPTCHA_PUBLIC_KEY, settings.RECAPTCHA_PRIVATE_KEY = "", ""
开发者ID:pselle,项目名称:lernanta,代码行数:14,代码来源:tests.py


示例4: setUp

    def setUp(self):
        self.locale = "en"

        django_user = User(username=self.test_username, email=self.test_email)
        self.user = create_profile(django_user)
        self.user.set_password(self.test_password)
        self.user.save()
开发者ID:p2pu,项目名称:lernanta,代码行数:7,代码来源:tests.py


示例5: authenticate

    def authenticate(self, **kwargs):
        """Authenticate the user based on an OpenID response."""
        # Require that the OpenID response be passed in as a keyword
        # argument, to make sure we don't match the username/password
        # calling conventions of authenticate.

        openid_response = kwargs.get('openid_response')
        if openid_response is None:
            return None

        if openid_response.status != SUCCESS:
            return None
        msg = 'Attempting to authenticate drupal user %s'
        log.debug(msg % openid_response.identity_url)

        try:
            UserOpenID.objects.get(
                claimed_id__exact=openid_response.identity_url)
            msg = 'Drupal openid user resgistered already: %s'
            log.debug(msg % openid_response.identity_url)
            return None
        except UserOpenID.DoesNotExist:
            drupal_user = drupal.get_openid_user(openid_response.identity_url)
            if drupal_user:
                username, email, full_name = drupal.get_user_data(drupal_user)
                try:
                    django_user = User(username=username[:30], email=email)
                    profile = create_profile(django_user, username=username)
                    profile.full_name = full_name
                    profile.save()
                    self.associate_openid(django_user, openid_response)
                    return django_user
                except IntegrityError:
                    return None
        return None
开发者ID:Acidburn0zzz,项目名称:lernanta,代码行数:35,代码来源:backends.py


示例6: setUp

    def setUp(self):
        self.client = Client()
        self.locale = 'en'
        django_user = User(
            username=self.test_username,
            email=self.test_email,
        )
        self.user = create_profile(django_user)
        self.user.set_password(self.test_password)
        self.user.save()

        self.project = Project(name='Reply Project',
            short_description='This project is to test replies',
            long_description='No really, its good',
        )
        self.project.save()
        
        participation = Participation(project=self.project,
            user=self.user, organizing=True)
        participation.save()
        
        self.page = Page(author=self.user,
            project=self.project,
            title='task title',
            sub_header='Tagline',
            content='Content',
            index=2)
        self.page.save()

        self.comment = PageComment()
        self.comment.page_object = self.page
        self.comment.scope_object = self.project
        self.comment.author = self.user
        self.comment.content = "blah blah"
        self.comment.save()
开发者ID:Astalaseven,项目名称:lernanta,代码行数:35,代码来源:tests.py


示例7: setUp

 def setUp(self):
     self.client = Client()
     self.locale = 'en'
     django_user = User(
         username=self.test_username,
         email=self.test_email,
     )
     self.user = create_profile(django_user)
     self.user.set_password(self.test_password)
     self.user.save()
     self.project = Project(name='My Cool Project',
         short_description='This project is awesome',
         long_description='No really, its good',
     )
     self.project.save()
     participation = Participation(project=self.project,
         user=self.user, organizing=True)
     participation.save()
     for i in xrange(3):
         page = Page(author=self.user,
             project=self.project,
             title='Old Title %s' % i,
             sub_header='Old Tagline %s' % i,
             content='Old Content %s' % i,
             index=2*(i+1))
         page.save()
开发者ID:JiaFeiX,项目名称:lernanta,代码行数:26,代码来源:tests.py


示例8: test_get_courses

    def test_get_courses(self):
        user = User(username='testuser99', email='[email protected]')
        user = create_profile(user)
        user.save()

        course = course_model.create_course(
            **{
                "title": "A test course",
                "hashtag": "ATC-1",
                "description": "This course is all about ABC",
                "language": "en",
                "organizer_uri": '/uri/user/testuser'
            }
        )
        
        course = course_model.create_course(
            **{
                "title": "A unique test course",
                "hashtag": "AUTC-1",
                "description": "This course is all about ABC",
                "language": "en",
                "organizer_uri": '/uri/user/testuser99'
            }
        )


        # get course by title
        courses = course_model.get_courses(title="A unique test course")
        self.assertEquals(len(courses), 1)

        # get course by user uri
        courses = course_model.get_courses(organizer_uri="/uri/user/testuser99")
        self.assertEquals(len(courses), 1)
开发者ID:Acidburn0zzz,项目名称:lernanta,代码行数:33,代码来源:tests.py


示例9: setUp

 def setUp(self):
     """Create data for testing."""
     for user in self.test_users:
         django_user = User(**user)
         user = create_profile(django_user)
         user.set_password('testpass')
         user.save()
     (self.user_one, self.user_two) = UserProfile.objects.all()
开发者ID:AndyHendy,项目名称:lernanta,代码行数:8,代码来源:tests.py


示例10: setUp

 def setUp(self):
     self.locale = "en"
     self.client = Client()
     django_user = User(username=self.test_username, email=self.test_email)
     self.user = create_profile(django_user)
     self.user.set_password(self.test_password)
     self.user.save()
     self.old_recaptcha_pubkey = settings.RECAPTCHA_PUBLIC_KEY
     self.old_recaptcha_privkey = settings.RECAPTCHA_PRIVATE_KEY
     settings.RECAPTCHA_PUBLIC_KEY, settings.RECAPTCHA_PRIVATE_KEY = "", ""
开发者ID:noamsu,项目名称:lernanta,代码行数:10,代码来源:tests.py


示例11: setUp

 def setUp(self):
     self.client = Client()
     self.locale = 'en'
     django_user = User(
         username=self.test_username,
         email=self.test_email,
     )
     self.user = create_profile(django_user)
     self.user.set_password(self.test_password)
     self.user.save()
开发者ID:Cyber-World-Uk-Ltd,项目名称:lernanta,代码行数:10,代码来源:tests.py


示例12: test_login_post_redirect

 def test_login_post_redirect(self):
     """Test that post requests are treated properly."""
     django_user = User(username="testuser", email="[email protected]")
     user = create_profile(django_user)
     user.set_password("testpass")
     user.save()
     response = self.client.get("/de-DE/login/")
     self.assertContains(response, "csrfmiddlewaretoken")
     response = self.client.post("/de-DE/login/", {"username": user.username, "password": "testpass"})
     self.assertRedirects(response, "/en/dashboard/", status_code=302, target_status_code=302)
开发者ID:Inkbug,项目名称:lernanta,代码行数:10,代码来源:tests.py


示例13: migrate

def migrate(login):
    """Migrates a drupal user given an username or email address."""
    drupal_user = get_user(login)
    if drupal_user:
        username, email, full_name = get_user_data(drupal_user)
        django_user = User(username=username[:30], email=email)
        from users.models import create_profile
        try:
            profile = create_profile(django_user, username=username)
            profile.password = drupal_user.password
            profile.save()
            return profile
        except IntegrityError, ex:
            log.error('migration of %s failed: %s' % (login, ex))
开发者ID:Acidburn0zzz,项目名称:lernanta,代码行数:14,代码来源:drupal.py


示例14: register

def register(request):
    """Present user registration form and handle registrations."""

    request = _process_redirect(request)

    if request.method == 'POST':
        form = forms.RegisterForm(data=request.POST)

        if form.is_valid():
            django_user = form.save(commit=False)
            user = create_profile(django_user)
            user.set_password(form.cleaned_data['password'])
            user.generate_confirmation_code()
            user.full_name = form.cleaned_data['full_name']
            user.preflang = form.cleaned_data['preflang']
            user.save()

            log.info(u"Registered new account for user (%s)", user)

            messages.success(request, _('Congratulations! Your user account '
                                        'was successfully created.'))
            path = reverse('users_confirm_registration', kwargs={
                'username': user.username,
                'token': user.confirmation_code,
            })
            url = request.build_absolute_uri(path)
            user.email_confirmation_code(url)
            msg = _('Thanks! We have sent an email to {0} with '
                    'instructions for completing your '
                    'registration.').format(user.email)
            messages.info(request, msg)
            response = login(request)
            request.session['send_registration_event'] = True
            return response
        else:
            messages.error(request, _('There are errors in this form. Please '
                                      'correct them and resubmit.'))
    else:
        form = forms.RegisterForm()

    redirect_field_value = request.session.get(
        REDIRECT_FIELD_NAME, reverse('dashboard'))

    return render_to_response('users/register.html', {
        'form': form,
        'domain': Site.objects.get_current().domain,
        'redirect_field_name': REDIRECT_FIELD_NAME,
        'redirect_field_value': urllib2.quote(redirect_field_value),
    }, context_instance=RequestContext(request))
开发者ID:JiaFeiX,项目名称:lernanta,代码行数:49,代码来源:views.py


示例15: test_login_post_redirect

 def test_login_post_redirect(self):
     """Test that post requests are treated properly."""
     django_user = User(
         username='testuser',
         email='[email protected]',
     )
     user = create_profile(django_user)
     user.set_password('testpass')
     user.save()
     response = self.client.get('/de-DE/login/')
     self.assertContains(response, 'csrfmiddlewaretoken')
     response = self.client.post('/de-DE/login/', {
         'username': user.username,
         'password': 'testpass',
     })
     self.assertRedirects(response, '/', status_code=302,
                          target_status_code=301)
开发者ID:AndyHendy,项目名称:lernanta,代码行数:17,代码来源:tests.py


示例16: register

def register(request):
    """Present user registration form and handle registrations."""

    if REDIRECT_FIELD_NAME in request.GET:
        request = _clean_redirect_url(request)
        request.session[REDIRECT_FIELD_NAME] = request.GET[REDIRECT_FIELD_NAME]

    if request.method == 'POST':
        form = forms.RegisterForm(data=request.POST)

        if form.is_valid():
            django_user = form.save(commit=False)
            user = create_profile(django_user)
            user.set_password(form.cleaned_data['password'])
            user.generate_confirmation_code()
            user.full_name = form.cleaned_data['full_name']
            user.preflang = form.cleaned_data['preflang']
            user.newsletter = form.cleaned_data['newsletter']
            user.save()

            log.info(u"Registered new account for user (%s)", user)

            messages.success(request, _('Congratulations! Your user account '
                                        'was successfully created.'))
            path = reverse('users_confirm_registration', kwargs={
                'username': user.username,
                'token': user.confirmation_code,
            })
            url = request.build_absolute_uri(path)
            user.email_confirmation_code(url)
            msg = _('Thanks! We have sent an email to {0} with '
                    'instructions for completing your '
                    'registration.').format(user.email)
            messages.info(request, msg)

            return http.HttpResponseRedirect(reverse('users_login'))
        else:
            messages.error(request, _('There are errors in this form. Please '
                                      'correct them and resubmit.'))
    else:
        form = forms.RegisterForm()
    return render_to_response('users/register.html', {
        'form': form,
    }, context_instance=RequestContext(request))
开发者ID:pselle,项目名称:lernanta,代码行数:44,代码来源:views.py


示例17: setUp

    def setUp(self):
        self.client = Client()
        self.locale = 'en'
        django_user = User(
            username=self.test_username,
            email=self.test_email,
        )
        self.user = create_profile(django_user)
        self.user.set_password(self.test_password)
        self.user.save()

        self.test_course = {
            "course_url": "http://p2pu.org/courses/1/", 
            "title": "Course title", 
            "description": "Short description", 
            "data_url": "", 
            "language": "en", 
            "thumbnail_url": "http://p2pu.org/media/image.png", 
            "tags": ["tag1", "tag2", "tag3"]
        }
开发者ID:Inkbug,项目名称:lernanta,代码行数:20,代码来源:tests.py


示例18: register

def register(request):
    """Present user registration form and handle registrations."""

    request = _process_redirect(request)

    if request.method == "POST":
        form = forms.RegisterForm(data=request.POST)

        if form.is_valid():
            django_user = form.save(commit=False)
            user = create_profile(django_user)
            user.set_password(form.cleaned_data["password"])
            user.generate_confirmation_code()
            user.full_name = form.cleaned_data["full_name"]
            user.preflang = form.cleaned_data["preflang"]
            user.newsletter = form.cleaned_data["newsletter"]
            user.save()

            log.info(u"Registered new account for user (%s)", user)

            messages.success(request, _("Congratulations! Your user account " "was successfully created."))
            path = reverse(
                "users_confirm_registration", kwargs={"username": user.username, "token": user.confirmation_code}
            )
            url = request.build_absolute_uri(path)
            user.email_confirmation_code(url)
            msg = _(
                "Thanks! We have sent an email to {0} with " "instructions for completing your " "registration."
            ).format(user.email)
            messages.info(request, msg)

            return http.HttpResponseRedirect(reverse("users_login"))
        else:
            messages.error(request, _("There are errors in this form. Please " "correct them and resubmit."))
    else:
        form = forms.RegisterForm()
    return render_to_response(
        "users/register.html",
        {"form": form, "domain": Site.objects.get_current().domain},
        context_instance=RequestContext(request),
    )
开发者ID:arlton2,项目名称:lernanta,代码行数:41,代码来源:views.py


示例19: setUp

    def setUp(self):
        self.client = Client()
        self.locale = "en"
        django_user = User(username=self.test_username, email=self.test_email)
        self.user = create_profile(django_user)
        self.user.set_password(self.test_password)
        self.user.save()

        self.project = Project(
            name="Reply Project",
            short_description="This project is to test replies",
            long_description="No really, its good",
        )
        self.project.save()

        participation = Participation(project=self.project, user=self.user, organizing=True)
        participation.save()

        self.page = Page(
            author=self.user, project=self.project, title="task title", sub_header="Tagline", content="Content", index=2
        )
        self.page.save()
开发者ID:josmas,项目名称:lernanta,代码行数:22,代码来源:tests.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python models.Profile类代码示例发布时间:2022-05-27
下一篇:
Python helpers.user_link函数代码示例发布时间: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