Exemplo n.º 1
0
    def post(self):
        if self.form.is_valid():
            em_address = self.form.elements.email_address.value
            user_obj = orm_User.reset_password(em_address)
            if user_obj:
                if send_reset_password_email(user_obj):
                    session_user.add_message(
                        'notice',
                        'An email with a link to reset your password has been sent.'
                    )
                else:
                    session_user.add_message(
                        'error',
                        'An error occurred while sending the notification email. Your '
                        'password has not been reset.'
                    )
                url = current_url(root_only=True)
                redirect(url)
            else:
                session_user.add_message(
                    'error',
                    'Did not find a user with email address: %s' % em_address
                )
        elif self.form.is_submitted():
            # form was submitted, but invalid
            self.form.assign_user_errors()

        self.default()
Exemplo n.º 2
0
 def default(self):
     return current_url()
Exemplo n.º 3
0
 def test_currenturl(self):
     assert current_url(host_only=True) == 'http://localhost/'
Exemplo n.º 4
0
def test_currenturl():
    # call test_currenturl() with a fake request setup.  current_url()
    # depends on a correct environment being setup and would not work
    # otherwise.
    assert current_url(host_only=True) == 'http://localhost/'
Exemplo n.º 5
0
 def form_on_cancel(self):
     session_user.add_message('notice', 'no changes made to your profile')
     redirect(current_url(root_only=True))
Exemplo n.º 6
0
 def test_qs_replace_new(self):
     env = create_environ("/news/list?page=5&perpage=10", "http://localhost:8080/")
     self.assertEqual('http://localhost:8080/news/list?page=1&perpage=10',
                      current_url(environ=env, qs_replace={'page': 1, 'foo': 'bar'}))
     self.assertEqual('http://localhost:8080/news/list?foo=bar&page=1&perpage=10',
                      current_url(environ=env, qs_update={'page': 1, 'foo': 'bar'}))
Exemplo n.º 7
0
    def test_arguments(self):
        env = create_environ("/news/list?param=foo", "http://localhost:8080/script")
        self.assertEqual('http://localhost:8080/script/news/list?param=foo',
                         current_url(environ=env))
        self.assertEqual('http://localhost:8080/script/',
                         current_url(environ=env, root_only=True))
        self.assertEqual('http://localhost:8080/',
                         current_url(environ=env, host_only=True))
        self.assertEqual('http://localhost:8080/script/news/list',
                         current_url(environ=env, strip_querystring=True))
        self.assertEqual('/script/news/list?param=foo',
                         current_url(environ=env, strip_host=True))
        self.assertEqual('http://localhost:8080/script/news/list?param=foo',
                         current_url(environ=env, https=False))
        self.assertEqual('http://localhost:8080/script/',
                         current_url(environ=env, root_only=True, https=False))
        self.assertEqual('http://localhost:8080/',
                         current_url(environ=env, host_only=True, https=False))
        self.assertEqual('http://localhost:8080/script/news/list',
                         current_url(environ=env, strip_querystring=True, https=False))
        self.assertEqual('/script/news/list?param=foo',
                         current_url(environ=env, strip_host=True, https=False))

        env = create_environ("/news/list?param=foo", "https://localhost:8080/script")
        self.assertEqual('https://localhost:8080/script/news/list?param=foo',
                         current_url(environ=env))
        self.assertEqual('https://localhost:8080/script/',
                         current_url(environ=env, root_only=True))
        self.assertEqual('https://localhost:8080/', current_url(environ=env, host_only=True))
        self.assertEqual('https://localhost:8080/script/news/list',
                         current_url(environ=env, strip_querystring=True))
        self.assertEqual('/script/news/list?param=foo', current_url(environ=env, strip_host=True))
        self.assertEqual('https://localhost:8080/script/news/list?param=foo',
                         current_url(environ=env, https=True))
        self.assertEqual('https://localhost:8080/script/',
                         current_url(environ=env, root_only=True, https=True))
        self.assertEqual('https://localhost:8080/',
                         current_url(environ=env, host_only=True, https=True))
        self.assertEqual('https://localhost:8080/script/news/list',
                         current_url(environ=env, strip_querystring=True, https=True))
        self.assertEqual('/script/news/list?param=foo',
                         current_url(environ=env, strip_host=True, https=True))
        self.assertEqual('/script/', current_url(root_only=True, strip_host=True, environ=env))

        env = create_environ("/news/list?param=foo", "http://localhost:8080/")
        self.assertEqual('http://localhost:8080/news/list?param=foo', current_url(environ=env))
        self.assertEqual('http://localhost:8080/', current_url(environ=env, root_only=True))
        self.assertEqual('http://localhost:8080/', current_url(environ=env, host_only=True))
        self.assertEqual('http://localhost:8080/news/list',
                         current_url(environ=env, strip_querystring=True))
        self.assertEqual('/news/list?param=foo', current_url(environ=env, strip_host=True))
        self.assertEqual('http://localhost:8080/news/list?param=foo',
                         current_url(environ=env, https=False))
        self.assertEqual('http://localhost:8080/',
                         current_url(environ=env, root_only=True, https=False))
        self.assertEqual('http://localhost:8080/',
                         current_url(environ=env, host_only=True, https=False))
        self.assertEqual('http://localhost:8080/news/list',
                         current_url(environ=env, strip_querystring=True, https=False))
        self.assertEqual('/news/list?param=foo',
                         current_url(environ=env, strip_host=True, https=False))
        self.assertEqual('/', current_url(root_only=True, strip_host=True, environ=env))
Exemplo n.º 8
0
 def default(self):
     return current_url()
Exemplo n.º 9
0
 def test_currenturl(self):
     assert current_url(host_only=True) == 'http://localhost/'
Exemplo n.º 10
0
def test_currenturl():
    # call test_currenturl() with a fake request setup.  current_url()
    # depends on a correct environment being setup and would not work
    # otherwise.
    assert current_url(host_only=True) == 'http://localhost/'