當前位置: 首頁>>代碼示例>>Python>>正文


Python Profile.get_by_email方法代碼示例

本文整理匯總了Python中models.profile.Profile.get_by_email方法的典型用法代碼示例。如果您正苦於以下問題:Python Profile.get_by_email方法的具體用法?Python Profile.get_by_email怎麽用?Python Profile.get_by_email使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.profile.Profile的用法示例。


在下文中一共展示了Profile.get_by_email方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_forgot_password_post_only_has_homepage_login_form

# 需要導入模塊: from models.profile import Profile [as 別名]
# 或者: from models.profile.Profile import get_by_email [as 別名]
 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,代碼行數:9,代碼來源:test_forgot_password.py

示例2: test_signup_sends_welcome_email

# 需要導入模塊: from models.profile import Profile [as 別名]
# 或者: from models.profile.Profile import get_by_email [as 別名]
  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,代碼行數:33,代碼來源:test_signup.py

示例3: login

# 需要導入模塊: from models.profile import Profile [as 別名]
# 或者: from models.profile.Profile import get_by_email [as 別名]
    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,代碼行數:29,代碼來源:login.py

示例4: test_signup_schedules_payment_create_call

# 需要導入模塊: from models.profile import Profile [as 別名]
# 或者: from models.profile.Profile import get_by_email [as 別名]
  def test_signup_schedules_payment_create_call(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)

    # There should be one task in the scheduler queue.
    tasks = self.taskqueue_stub.get_filtered_tasks(queue_names=['payment'])
    self.assertLength(1, tasks)

    # Verify the details about the task are correct.
    task, = tasks
    self.assertEqual(self.uri_for('payment.create'), task.url)
    self.assertEqual(str(profile.key()), task.extract_params()['profile_key'])
開發者ID:carylF,項目名稱:Caryl-Ford,代碼行數:19,代碼來源:test_signup.py

示例5: login

# 需要導入模塊: from models.profile import Profile [as 別名]
# 或者: from models.profile.Profile import get_by_email [as 別名]
  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 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:nardorb,項目名稱:OneStop,代碼行數:25,代碼來源:login.py

示例6: test_forgot_password_post_with_email_not_member

# 需要導入模塊: from models.profile import Profile [as 別名]
# 或者: from models.profile.Profile import get_by_email [as 別名]
 def test_forgot_password_post_with_email_not_member(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')
開發者ID:carylF,項目名稱:Caryl-Ford,代碼行數:8,代碼來源:test_forgot_password.py

示例7: forgot_password

# 需要導入模塊: from models.profile import Profile [as 別名]
# 或者: from models.profile.Profile import get_by_email [as 別名]
  def forgot_password(self):
    if self.get_current_profile():
      return self.redirect_to('home')

    key = self.request.get('k')
    if key:
      profile = Profile.get_by_activation_key(key)
    else:
      profile = None

    # GET request (either with or without an activation key and profile);
    # We should show either the form to send the recovery e-mail, or the
    # form to change your password.
    if self.request.method == 'GET':
      return self.render_to_response('forgot_password.haml',
                                     {'profile': profile})

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

      # POST request that had an activation key and a matching profile;
      # We should update their password, log them in, and redirect.
      if key and profile:
        # If we didn't submit a password, then start the process over.
        if not password:
          return self.redirect_to('forgot-password', k=key)

        # Set as activated (since they've confirmed their e-mail).
        profile.activated = True
        profile.put()

        # Change the password for the auth_user.
        user = self.auth.store.user_model.get_by_id(profile.auth_user_id)
        user.password = security.generate_password_hash(password, length=12)
        user.put()

        # Log the user in.
        user_id = user.key.id()
        self.auth._user = None
        self.auth.get_user_by_token(user_id, user.create_auth_token(user_id))

        # Redirect to the dashboard.
        return self.redirect_to('home')

      # POST request that didn't find a profile, but POST'ed an e-mail address;
      # We should send them a recovery e-mail.
      elif email and not profile:
        profile = Profile.get_by_email(email)
        if profile:
          profile.activation_key = None
          profile.put()
          context = {'profile': profile}
          self.send_mail(
              profile=profile, defer=True, context=context,
              subject='{0.PRODUCT_NAME} Password Recovery'.format(constants),
              template='emails/forgot_password.haml')
        return self.render_to_response('forgot_password.haml')

      # POST request that was missing something...
      # We should redirect back to start the process over.
      else:
        return self.redirect_to('forgot-password')
開發者ID:nardorb,項目名稱:OneStop,代碼行數:65,代碼來源:login.py

示例8: validate_email

# 需要導入模塊: from models.profile import Profile [as 別名]
# 或者: from models.profile.Profile import get_by_email [as 別名]
 def validate_email(self, field):
   profile = Profile.get_by_email(field.data)
   if profile and profile.key().id() != self.profile_id:
     raise ValidationError("Email already in use!")
開發者ID:carylF,項目名稱:Caryl-Ford,代碼行數:6,代碼來源:profile_update.py


注:本文中的models.profile.Profile.get_by_email方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。