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


Python User.create方法代码示例

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


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

示例1: test_get

# 需要导入模块: from qiita_db.user import User [as 别名]
# 或者: from qiita_db.user.User import create [as 别名]
    def test_get(self):
        response = self.get('/auth/verify/SOMETHINGHERE?email=test%40foo.bar')
        self.assertEqual(response.code, 200)

        User.create('[email protected]', 'Somesortofpass')
        response = self.get('/auth/verify/SOMETHINGHERE?email=new%40test.bar')
        self.assertEqual(response.code, 200)
开发者ID:antgonza,项目名称:qiita,代码行数:9,代码来源:test_auth_handlers.py

示例2: post

# 需要导入模块: from qiita_db.user import User [as 别名]
# 或者: from qiita_db.user.User import create [as 别名]
    def post(self):
        username = self.get_argument("email", "").strip().lower()
        password = self.get_argument("newpass", "")
        info = {}
        for info_column in ("name", "affiliation", "address", "phone"):
            hold = self.get_argument(info_column, None)
            if hold:
                info[info_column] = hold

        created = False
        try:
            created = User.create(username, password, info)
        except QiitaDBDuplicateError:
            msg = "Email already registered as a user"

        if created:
            info = created.info
            try:
                send_email(username, "QIITA: Verify Email Address", "Please "
                           "click the following link to verify email address: "
                           "%s/auth/verify/%s?email=%s"
                           % (qiita_config.base_url, info['user_verify_code'],
                              url_escape(username)))
            except:
                msg = ("Unable to send verification email. Please contact the "
                       "qiita developers at <a href='mailto:qiita-help"
                       "@gmail.com'>[email protected]</a>")
                self.redirect(u"/?level=danger&message=" + url_escape(msg))
                return
            self.redirect(u"/")
        else:
            error_msg = u"?error=" + url_escape(msg)
            self.redirect(u"/auth/create/" + error_msg)
开发者ID:DarcyMyers,项目名称:qiita,代码行数:35,代码来源:auth_handlers.py

示例3: test_create_user

# 需要导入模块: from qiita_db.user import User [as 别名]
# 或者: from qiita_db.user.User import create [as 别名]
    def test_create_user(self):
        user = User.create('[email protected]', 'password')
        self.assertEqual(user.id, '[email protected]')
        sql = "SELECT * from qiita.qiita_user WHERE email = '[email protected]'"
        obs = self.conn_handler.execute_fetchall(sql)
        self.assertEqual(len(obs), 1)
        obs = dict(obs[0])
        exp = {
            'password': '',
            'name': None,
            'pass_reset_timestamp': None,
            'affiliation': None,
            'pass_reset_code': None,
            'phone': None,
            'user_verify_code': '',
            'address': None,
            'user_level_id': 5,
            'email': '[email protected]'}
        self._check_correct_info(obs, exp)

        # make sure default analysis created
        sql = ("SELECT email, name, description, dflt FROM qiita.analysis "
               "WHERE email = '[email protected]'")
        obs = self.conn_handler.execute_fetchall(sql)
        exp = [['[email protected]', '[email protected]', 'dflt', True]]
        self.assertEqual(obs, exp)
开发者ID:mortonjt,项目名称:qiita,代码行数:28,代码来源:test_user.py

示例4: test_generate_reset_code

# 需要导入模块: from qiita_db.user import User [as 别名]
# 或者: from qiita_db.user.User import create [as 别名]
 def test_generate_reset_code(self):
     user = User.create('[email protected]', 'password')
     sql = "SELECT LOCALTIMESTAMP"
     before = self.conn_handler.execute_fetchone(sql)[0]
     user.generate_reset_code()
     after = self.conn_handler.execute_fetchone(sql)[0]
     sql = ("SELECT pass_reset_code, pass_reset_timestamp FROM "
            "qiita.qiita_user WHERE email = %s")
     obscode, obstime = self.conn_handler.execute_fetchone(
         sql, ('[email protected]',))
     self.assertEqual(len(obscode), 20)
     self.assertTrue(before < obstime < after)
开发者ID:DarcyMyers,项目名称:qiita,代码行数:14,代码来源:test_user.py

示例5: post

# 需要导入模块: from qiita_db.user import User [as 别名]
# 或者: from qiita_db.user.User import create [as 别名]
    def post(self):
        username = self.get_argument("email", "").strip().lower()
        password = self.get_argument("newpass", "")
        info = {}
        for info_column in ("name", "affiliation", "address", "phone"):
            hold = self.get_argument(info_column, None)
            if hold:
                info[info_column] = hold

        created = False
        try:
            created = User.create(username, password, info)
        except QiitaDBDuplicateError:
            msg = "Email already registered as a user"

        if created:
            info = created.info
            try:
                # qiita_config.base_url doesn't have a / at the end, but the
                # qiita_config.portal_dir has it at the beginning but not at
                # the end. This constructs the correct URL
                url = qiita_config.base_url + qiita_config.portal_dir
                send_email(username, "QIITA: Verify Email Address", "Please "
                           "click the following link to verify email address: "
                           "%s/auth/verify/%s?email=%s\n\nBy clicking you are "
                           "accepting our term and conditions: "
                           "%s/iframe/?iframe=qiita-terms"
                           % (url, info['user_verify_code'],
                              url_escape(username), url))
            except Exception:
                msg = ("Unable to send verification email. Please contact the "
                       "qiita developers at <a href='mailto:qiita-help"
                       "@gmail.com'>[email protected]</a>")
                self.redirect(u"%s/?level=danger&message=%s"
                              % (qiita_config.portal_dir, url_escape(msg)))
                return

            msg = ("<h3>User Successfully Created</h3><p>Your Qiita account "
                   "has been successfully created. An email has been sent to "
                   "the email address you provided. This email contains "
                   "instructions on how to activate your account.</p>"
                   "<p>If you don't receive your activation email within a "
                   "couple of minutes, check your spam folder. If you still "
                   "don't see it, send us an email at <a "
                   "href=\"mailto:[email protected]\">[email protected]"
                   "</a>.</p>")
            self.redirect(u"%s/?level=success&message=%s" %
                          (qiita_config.portal_dir, url_escape(msg)))
        else:
            error_msg = u"?error=" + url_escape(msg)
            self.redirect(u"%s/auth/create/%s"
                          % (qiita_config.portal_dir, error_msg))
开发者ID:antgonza,项目名称:qiita,代码行数:54,代码来源:auth_handlers.py

示例6: test_create_user_info

# 需要导入模块: from qiita_db.user import User [as 别名]
# 或者: from qiita_db.user.User import create [as 别名]
 def test_create_user_info(self):
     user = User.create('[email protected]', 'password', self.userinfo)
     self.assertEqual(user.id, '[email protected]')
     sql = "SELECT * from qiita.qiita_user WHERE email = '[email protected]'"
     obs = self.conn_handler.execute_fetchall(sql)
     self.assertEqual(len(obs), 1)
     obs = dict(obs[0])
     exp = {
         'password': '',
         'name': 'Dude',
         'affiliation': 'Nowhere University',
         'address': '123 fake st, Apt 0, Faketown, CO 80302',
         'phone': '111-222-3344',
         'pass_reset_timestamp': None,
         'pass_reset_code': None,
         'user_verify_code': '',
         'user_level_id': 5,
         'email': '[email protected]'}
     self._check_correct_info(obs, exp)
开发者ID:DarcyMyers,项目名称:qiita,代码行数:21,代码来源:test_user.py

示例7: test_create_user

# 需要导入模块: from qiita_db.user import User [as 别名]
# 或者: from qiita_db.user.User import create [as 别名]
 def test_create_user(self):
     user = User.create('[email protected]', 'password')
     self.assertEqual(user.id, '[email protected]')
     sql = "SELECT * from qiita.qiita_user WHERE email = '[email protected]'"
     obs = self.conn_handler.execute_fetchall(sql)
     self.assertEqual(len(obs), 1)
     obs = dict(obs[0])
     exp = {
         'password': '',
         'name': None,
         'pass_reset_timestamp': None,
         'affiliation': None,
         'pass_reset_code': None,
         'phone': None,
         'user_verify_code': '',
         'address': None,
         'user_level_id': 5,
         'email': '[email protected]'}
     self._check_correct_info(obs, exp)
开发者ID:DarcyMyers,项目名称:qiita,代码行数:21,代码来源:test_user.py

示例8: post

# 需要导入模块: from qiita_db.user import User [as 别名]
# 或者: from qiita_db.user.User import create [as 别名]
    def post(self):
        username = self.get_argument("username", "")
        password = self.get_argument("pass", "")
        info = {}
        for info_column in ("name", "affiliation", "address", "phone"):
            hold = self.get_argument(info_column, None)
            if hold:
                info[info_column] = hold

        created = User.create(username, password, info)

        if created:
            send_email(username, "FORGE: Verify Email Address", "Please click "
                       "the following link to verify email address: "
                       "http://forge-dev.colorado.edu/auth/verify/%s" % msg)
            self.redirect(u"/")
        else:
            error_msg = u"?error=" + url_escape(msg)
            self.redirect(u"/auth/create/" + error_msg)
开发者ID:teravest,项目名称:qiita,代码行数:21,代码来源:auth_handlers.py

示例9: test_create_user_bad_password

# 需要导入模块: from qiita_db.user import User [as 别名]
# 或者: from qiita_db.user.User import create [as 别名]
 def test_create_user_bad_password(self):
     with self.assertRaises(IncorrectPasswordError):
         User.create('[email protected]', '')
开发者ID:DarcyMyers,项目名称:qiita,代码行数:5,代码来源:test_user.py

示例10: test_create_user_bad_email

# 需要导入模块: from qiita_db.user import User [as 别名]
# 或者: from qiita_db.user.User import create [as 别名]
 def test_create_user_bad_email(self):
     with self.assertRaises(IncorrectEmailError):
         User.create('notanemail', 'password')
开发者ID:DarcyMyers,项目名称:qiita,代码行数:5,代码来源:test_user.py

示例11: test_create_user_duplicate

# 需要导入模块: from qiita_db.user import User [as 别名]
# 或者: from qiita_db.user.User import create [as 别名]
 def test_create_user_duplicate(self):
     with self.assertRaises(QiitaDBDuplicateError):
         User.create('[email protected]', 'password')
开发者ID:DarcyMyers,项目名称:qiita,代码行数:5,代码来源:test_user.py

示例12: test_create_user_non_existent_column

# 需要导入模块: from qiita_db.user import User [as 别名]
# 或者: from qiita_db.user.User import create [as 别名]
 def test_create_user_non_existent_column(self):
     self.userinfo["BADTHING"] = "FAIL"
     with self.assertRaises(QiitaDBColumnError):
         User.create('[email protected]', 'password', self.userinfo)
开发者ID:DarcyMyers,项目名称:qiita,代码行数:6,代码来源:test_user.py

示例13: test_create_user_column_not_allowed

# 需要导入模块: from qiita_db.user import User [as 别名]
# 或者: from qiita_db.user.User import create [as 别名]
 def test_create_user_column_not_allowed(self):
     self.userinfo["email"] = "FAIL"
     with self.assertRaises(QiitaDBColumnError):
         User.create('[email protected]', 'password', self.userinfo)
开发者ID:DarcyMyers,项目名称:qiita,代码行数:6,代码来源:test_user.py

示例14: setUp

# 需要导入模块: from qiita_db.user import User [as 别名]
# 或者: from qiita_db.user.User import create [as 别名]
 def setUp(self):
     StudyPerson.create('SomeDude', '[email protected]', 'some',
                        '111 fake street', '111-121-1313')
     User.create('[email protected]', 'password')
     self.config1 = CONFIG_1
     self.config2 = CONFIG_2
开发者ID:Jorge-C,项目名称:qiita,代码行数:8,代码来源:test_commands.py


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