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

Python profile.Profile类代码示例

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

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



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

示例1: create_profile

  def create_profile(cls, email=None, password=None, beta_tester=True,
                     is_admin=False, is_manager=False, is_editor=False,
                     activated=True, account=None):
    # TODO: Move this into a top level function (testing.create_profile)
    # Use defaults if anything here is missing.
    UserModel = cls.get_auth().store.user_model

    if not email:
      # Generate an e-mail that should be unique...
      email = '%s-%s' % (UserModel.query().count(), cls.DEFAULT_EMAIL)
    password = password or cls.DEFAULT_PASSWORD

    # Create the auth.user_model.
    ok, user = UserModel.create_user(email, password_raw=password)

    if not ok:
      raise Exception('Error creating auth.User: %s' % email)

    if not account:
      account = cls.create_account()

    # Create the profile.
    profile = Profile(name=cls.DEFAULT_PROFILE_NAME, is_admin=is_admin,
                      is_manager=is_manager, is_editor=is_editor,
                      email=email, beta_tester=beta_tester,
                      activated=activated, auth_user_id=user.key.id(),
                      timezone='UTC', parent=account)
    profile.put()

    # Return the profile (we can get everything else with that)
    return profile
开发者ID:carylF,项目名称:Caryl-Ford,代码行数:31,代码来源:testing.py


示例2: get

    def get(self, artist_id):
        # artist_id may be a profile_unique_name or an application_user_id
        profile_obj = Profile.get_profile_by_profile_unique_name(artist_id)
        if profile_obj is not None:
            application_user_id = profile_obj.application_user_id
            user_obj = User.get_user_by_application_user_id(application_user_id)
            if user_obj is None:
                # TODO : All profiles should have a user associated with them. Log or handle the event where there is no User associated with a profile.
                # There is no user associated with the profile!
                pass
        else:
            user_obj = User.get_user_by_application_user_id(artist_id)
            if user_obj is not None:
                profile_obj = Profile.get_profile_by_application_user_id(user_obj.application_user_id)

        if user_obj is not None:
            self.template_values['user_exists'] = True
            self.template_values['artist_name'] = user_obj.first_name + ' ' + user_obj.last_name
            if profile_obj is not None:
                self.template_values['profile_unique_name'] = profile_obj.profile_unique_name
                if profile_obj.bio is not None and not re.match(r"^\s*$", profile_obj.bio):
                    self.template_values['profile_bio'] = profile_obj.bio
                if profile_obj.profile_picture is not None:
                    self.template_values['profile_picture'] = profile_obj.profile_picture
            art_objs = Art.get_art(user_obj.application_user_id)
            art_list = list()
            for art_obj in art_objs:
                art_list.append({'art_obj': art_obj})
            self.template_values['art_list'] = art_list
            self.template_values['artist_image_count'] = len(self.template_values['art_list'])
        else:
            self.template_values['user_exists'] = False

        template = self.get_template('templates/artist_content.html')
        self.response.write(template.render(self.template_values))
开发者ID:peterjirak,项目名称:sweetvisionart2,代码行数:35,代码来源:artist.py


示例3: get

    def get(self, blip_key=None):
        blip = Blip.get(blip_key)
        if blip is None:
            return self.error(404)
        login_user = self.get_current_user()
        if blip.meeting and not blip.meeting.has_member(login_user):
            return self.error(401)
        user = blip.user
        _, profile = Profile.get_or_create_from_user(user)

        is_self = user == login_user

        has_followed = False
        if not is_self:
            has_followed = Follow.gql('WHERE from_user = :1 AND to_user = :2',
                                      login_user, user).get() is not None            

        followers = Follow.who_subscribe_you(user)
        follower_profiles = []
        for f in followers:
            c, p = Profile.get_or_create_from_user(f.from_user)
            follower_profiles.append(p)
        followees = Follow.your_subscribers(user)
        followee_profiles = []
        for f in followees:
            c, p = Profile.get_or_create_from_user(f.to_user)
            followee_profiles.append(p)


        return self.render('blip_item.html', locals())
开发者ID:superisaac,项目名称:status-engine,代码行数:30,代码来源:blip.py


示例4: get

    def get(self):
        user = self.get_current_user()
        created, profile = Profile.get_or_create_from_user(user)

        followers = Follow.who_subscribe_you(user)
        follower_profiles = []
        for f in followers:
            c, p = Profile.get_or_create_from_user(f.from_user)
            follower_profiles.append(p)
        followees = Follow.your_subscribers(user)
        followee_profiles = []
        for f in followees:
            c, p = Profile.get_or_create_from_user(f.to_user)
            followee_profiles.append(p)
        try:
            page = int(self.request.get('page', '1'))
        except ValueError:
            page = 1

        pagesize = settings.BLIP_PAGE_SIZE
        paginator = SimplePaginator(BlipLink.qs_for_user(user),
                                    page, pagesize)
        blips = each_profiles(paginator.object_list, field='author')
        is_self = True
        return self.render('home.html', locals())
开发者ID:superisaac,项目名称:status-engine,代码行数:25,代码来源:profile.py


示例5: test_signup_page_flow

  def test_signup_page_flow(self):
    # Check that things are empty
    self.assertLength(0, Profile.all())

    # Sign up with the form
    response = self.app.post(self.uri_for('signup'), self.SIGNUP_DATA)
    self.assertRedirects(response, self.uri_for('dashboard', tour=''))

    # Check that we are actually logged in
    response = self.app.get(response.location)
    self.assertLoggedIn()

    # Check that one of everything was created
    self.assertLength(1, Profile.all())

    profile = Profile.all().get()

    # Check the basic data
    self.assertEqual(self.SIGNUP_DATA['email'], profile.email)
    self.assertEqual(self.SIGNUP_DATA['name'], profile.name)

    # Logout and log back in to test that the password works
    self.logout()
    response = self.login(self.SIGNUP_DATA['email'],
                          self.SIGNUP_DATA['password'])
    self.assertRedirects(response, self.uri_for('dashboard'))
开发者ID:carylF,项目名称:Caryl-Ford,代码行数:26,代码来源:test_signup.py


示例6: test_signup_sends_welcome_email

  def test_signup_sends_welcome_email(self):
    # Sign up successfully
    response = self.app.post(self.uri_for('signup'), self.SIGNUP_DATA)
    self.assertRedirects(response, self.uri_for('dashboard', tour=''))

    # Check that a profile was created
    profile = Profile.get_by_email(self.SIGNUP_DATA['email'])
    self.assertIsNotNone(profile)

    # Check that a mail-sending task is in the queue
    tasks = self.taskqueue_stub.GetTasks('mail')
    self.assertLength(1, tasks)

    # Run the task (it should be a deferred call) and check that an e-mail
    # is sent
    task, = tasks
    deferred.run(base64.b64decode(task['body']))
    messages = self.mail_stub.get_sent_messages()
    self.assertLength(1, messages)

    message, = messages
    self.assertEqual('"%s" <%s>' % (profile.name, profile.email), message.to)
    self.assertEqual('Welcome to Daily Meeting!', message.subject)
    self.assertEqual('"Daily Meeting" <[email protected]>',
                     message.sender)
    self.assertEqual('"Daily Meeting Support" <[email protected]>',
                     message.reply_to)
    activation_key = Profile.all().get().activation_key
    activation_url = self.uri_for('profile.activate', k=activation_key)
    self.assertIn(activation_url, message.body.decode())
    self.assertIn(activation_url, message.html.decode())
开发者ID:carylF,项目名称:Caryl-Ford,代码行数:31,代码来源:test_signup.py


示例7: test_signup_with_existing_email

  def test_signup_with_existing_email(self):
    response = self.app.post(self.uri_for('signup'), self.SIGNUP_DATA)
    self.assertRedirects(response)
    self.assertLength(1, Profile.all())

    response = self.app.post(self.uri_for('signup'), self.SIGNUP_DATA)
    self.assertOk(response)
    self.assertLength(1, Profile.all())

    email_field = response.pyquery('input#email')
    self.assertLength(1, email_field)
    self.assertNotEqual('', email_field.attr['data-error'])
开发者ID:carylF,项目名称:Caryl-Ford,代码行数:12,代码来源:test_signup.py


示例8: test_forgot_password_post_only_has_homepage_login_form

 def test_forgot_password_post_only_has_homepage_login_form(self):
   params = {'email': '[email protected]'}
   self.assertIsNone(Profile.get_by_email(params['email']))
   response = self.app.post(self.uri_for('forgot-password'), params)
   self.assertOk(response)
   self.assertTemplateUsed('forgot_password.haml')
   self.assertLength(1, response.pyquery('form#login-form'))
开发者ID:carylF,项目名称:Caryl-Ford,代码行数:7,代码来源:test_forgot_password.py


示例9: test_forgot_password_post_sends_email

  def test_forgot_password_post_sends_email(self):
    self.assertNotLoggedIn()
    profile = self.create_profile()
    response = self.app.get(self.uri_for('forgot-password'))
    form = response.forms['forgot-password']
    form['email'] = profile.email
    response = form.submit()

    # Check the task was put on the mail queue.
    tasks = self.taskqueue_stub.get_filtered_tasks(queue_names='mail')
    self.assertIn('mail', tasks[0].headers['X-AppEngine-QueueName'])
    task, = tasks
    deferred.run(task.payload)
    messages = self.mail_stub.get_sent_messages()
    self.assertLength(1, messages)
    message, = messages
    profile = Profile.get(profile.key())

    # Reload profile to get new activation key.
    self.assertEqual('"%s" <%s>' % (profile.name, profile.email),
                     message.to)
    self.assertEqual(constants.FULL_NO_REPLY_EMAIL, message.sender)
    self.assertEqual(constants.FULL_SUPPORT_EMAIL, message.reply_to)
    self.assertIn(profile.activation_key, message.body.decode())
    self.assertIn(profile.activation_key, message.html.decode())

    recover_uri = self.uri_for('forgot-password', k=profile.activation_key)
    self.assertIn(recover_uri, message.body.decode())
    self.assertIn(recover_uri, message.html.decode())
开发者ID:carylF,项目名称:Caryl-Ford,代码行数:29,代码来源:test_forgot_password.py


示例10: login

    def login(self):
        error = None

        if self.request.method == "POST":
            email = self.request.POST.get("email", "").strip()
            password = self.request.POST.get("password", "").strip()

            user = Profile.get_by_email(email)
            if not user:
                error = "User not found"
            else:
                try:
                    self.auth.get_user_by_password(email, password)
                except auth.InvalidPasswordError:
                    error = "Invalid password!"
                except auth.InvalidAuthIdError:
                    error = "Unknown e-mail address!"

                if not user.beta_tester:
                    self.session.add_flash(value="Please ensure you are cleared for beta testing.", level="error")
                    return self.redirect_to("login")

        if self.get_current_profile():
            redirect = self.request.get("redirect")
            return self.redirect(redirect or self.uri_for("home"))
        else:
            return self.render_to_response("login.haml", {"error": error})
开发者ID:carylF,项目名称:agrihack,代码行数:27,代码来源:login.py


示例11: verify_access

 def verify_access(self, *args):
   user = users.GetCurrentUser()
   if user:
     profile = Profile.gql("WHERE user = :1", user)
     current_profile = profile.get()
     if role == current_profile.role:
       handler_method(self, *args)
       return
   self.response.out.write('<html><head></head><body>Access denied</body></html>')
开发者ID:ciriarte,项目名称:laundry,代码行数:9,代码来源:util.py


示例12: post

 def post(self):
     user = self.get_current_user()
     created, profile = Profile.get_or_create_from_user(user)
     self.errors = []
     try:
         self.validate(profile)
     except Exception, e:
         self.errors = [str(e)]
         return self.get()
开发者ID:superisaac,项目名称:status-engine,代码行数:9,代码来源:profile.py


示例13: delete

  def delete(self, id):
    editor = Profile.get_by_id(int(id))
    if not editor or not editor.is_editor:
      self.session.add_flash(messages.EDITOR_NOT_FOUND, level='error')
      return self.redirect_to('editors.list')

    editor.delete()
    self.session.add_flash(messages.EDITOR_DELETE_SUCCESS)
    return self.redirect_to('editors.list')
开发者ID:carylF,项目名称:Caryl-Ford,代码行数:9,代码来源:editor.py


示例14: test_forgot_password_post_resets_activation_key

  def test_forgot_password_post_resets_activation_key(self):
    profile = self.create_profile()
    old_activation_key = profile.activation_key

    params = {'email': profile.email}
    response = self.app.post(self.uri_for('forgot-password'), params)
    self.assertOk(response)
    profile = Profile.get(profile.key())
    self.assertNotEqual(old_activation_key, profile.activation_key)
开发者ID:carylF,项目名称:Caryl-Ford,代码行数:9,代码来源:test_forgot_password.py


示例15: get

  def get(self):	
	path = os.path.join(os.path.dirname(__file__),
	                    '../views/admin/index.html')
	
	template_values = {
		'name': self.__class__.__name__,
		'profiles': Profile.all(),
	}
	
	self.response.out.write(template.render(path, template_values))
开发者ID:ciriarte,项目名称:laundry,代码行数:10,代码来源:admin.py


示例16: validate

    def validate(self, email, password):
        if not email_pattern.match(email):
            raise Exception("Email format is not right")

        if not password or not email:
            raise Exception("Password and email cannot be empty")

        profile = Profile.gql('WHERE user_email=:1', email).get()
        if profile:
            raise Exception("This email is already occupied.")
开发者ID:superisaac,项目名称:status-engine,代码行数:10,代码来源:auth.py


示例17: get

	def get(self):
		user = users.get_current_user()
		if user:
		  profile = Profile.gql("WHERE user = :1", user).get()
		  if not profile:
		    self.redirect("/profiles/new")
		    return
		  self.redirect("/dashboard")
		else:
		  self.redirect(users.create_login_url(self.request.uri))
开发者ID:ciriarte,项目名称:laundry,代码行数:10,代码来源:home.py


示例18: get

    def get(self, meeting_key=None, user_name=None):
        login_user = self.get_current_user()
        m = Meeting.get(meeting_key)
        if m is None:
            return self.error(404)
        if m.creator != login_user:
            return self.error(401)

        profile = Profile.gql('WHERE nickname = :1', user_name).get()
        m.delete_member(profile.get_user())
        return self.redirect_back()
开发者ID:superisaac,项目名称:status-engine,代码行数:11,代码来源:meeting.py


示例19: create

  def create(self):
    form = ProfileForm(self.request.POST)

    if self.request.method == 'POST' and form.validate():
      name = ' '.join([form.first_name.data,
                       form.last_name.data])

      # Create the webapp2_extras.auth user.
      model = self.auth.store.user_model
      ok, user = model.create_user(form.data['email'],
                                   password_raw=form.data['password'])

      if not ok:
        self.session.add_flash(messages.EDITOR_CREATE_ERROR,
                               level='error')
        return self.redirect_to('editors.list')

      # Create the profile.
      profile = Profile(name=name,
                        email=form.data['email'],
                        is_editor=True,
                        auth_user_id=user.key.id())
      profile.put()

      # Force reload of profile object
      Profile.get(profile.key())

      self.session.add_flash(messages.EDITOR_CREATE_SUCCESS)
      return self.redirect_to('editors.list')

    return self.render_to_response('editors/form.haml', {'form': form})
开发者ID:carylF,项目名称:Caryl-Ford,代码行数:31,代码来源:editor.py


示例20: update

  def update(self, id):
    editor = Profile.get_by_id(int(id))
    if not editor or not editor.is_editor:
      self.session.add_flash(messages.EDITOR_NOT_FOUND, level='error')
      self.redirect_to('editors.list')

    form = ProfileUpdateForm(self.request.POST, obj=editor)
    form.user_id = editor.key().id()

    if self.request.method == 'GET':
      names = editor.name.split(' ')
      form.first_name.data = names[0]
      form.last_name.data = names[1]

    form.profile_id = editor.key().id()

    if self.request.method == 'POST' and form.validate():
      # Access to the user model is only needed in this section.
      user = editor.get_auth_user()
      editor.name = ' '.join([form.first_name.data, form.last_name.data])

      if form.email.data != editor.email:
        user.auth_ids.remove(editor.email)
        user.auth_ids.append(form.email.data)
        editor.email = form.email.data

      if form.password.data:
        user.password = security.generate_password_hash(form.password.data,
                                                        length=12)

      editor.put()
      user.put()

      # Force reload of profile object
      Profile.get(editor.key())
      self.session.add_flash(messages.EDITOR_UPDATE_SUCCESS)

      return self.redirect_to('editors.list')

    return self.render_to_response('editors/form.haml', {'form': form})
开发者ID:carylF,项目名称:Caryl-Ford,代码行数:40,代码来源:editor.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python project.Project类代码示例发布时间:2022-05-27
下一篇:
Python private_key.PrivateKey类代码示例发布时间: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