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


Python models.User類代碼示例

本文整理匯總了Python中streetsign_server.models.User的典型用法代碼示例。如果您正苦於以下問題:Python User類的具體用法?Python User怎麽用?Python User使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: test_one_user_group_write_and_publish

    def test_one_user_group_write_and_publish(self):
        f = Feed(name='123')
        f.save()

        u = User(passwordhash='123')
        u.save()

        g = Group(name='usergroup')
        g.save()
        g.set_users([u.id])

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [])
        self.assertEqual(f.author_groups(), [])
        self.assertEqual(f.publisher_groups(), [])

        self.assertFalse(f.user_can_write(u))
        self.assertFalse(f.user_can_publish(u))

        f.grant('Write', group=g)
        f.grant('Publish', group=g)

        f = Feed.get(id=f.id)

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [])
        self.assertEqual(f.author_groups(), [g])
        self.assertEqual(f.publisher_groups(), [g])

        self.assertTrue(f.user_can_write(u))
        self.assertTrue(f.user_can_publish(u))
開發者ID:Fivebread,項目名稱:streetsign,代碼行數:31,代碼來源:test_models_feed.py

示例2: test_admin_can_delete_user

    def test_admin_can_delete_user(self):
        self.login(ADMINNAME, ADMINPASS)
        resp = self.post_delete_request()
        self.assertEqual(resp.status_code, 200)

        with self.assertRaises(User.DoesNotExist):
            User.get(id=self.user2.id)
開發者ID:Fivebread,項目名稱:streetsign,代碼行數:7,代碼來源:test_views_users_and_auth.py

示例3: test_one_user_group_read_only

    def test_one_user_group_read_only(self):
        f = Feed(name='123')
        f.save()

        u = User(passwordhash='123')
        u.save()

        g = Group(name='usergroup')
        g.set_users([u.id])
        g.save()

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [])
        self.assertEqual(f.author_groups(), [])
        self.assertEqual(f.publisher_groups(), [])

        self.assertFalse(f.user_can_write(u))
        self.assertFalse(f.user_can_publish(u))

        f.grant('Read', group=g)

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [])
        self.assertEqual(f.author_groups(), [])
        self.assertEqual(f.publisher_groups(), [])

        self.assertFalse(f.user_can_write(u))
        self.assertFalse(f.user_can_publish(u))
開發者ID:Fivebread,項目名稱:streetsign,代碼行數:28,代碼來源:test_models_feed.py

示例4: test_user_with_no_perms

    def test_user_with_no_perms(self):
        u = User(passwordhash='123')
        f = Feed()

        u.save()
        f.save()

        self.assertEqual(u.writeable_feeds(), [])
開發者ID:Fivebread,項目名稱:streetsign,代碼行數:8,代碼來源:test_models_user.py

示例5: test_admin_needs_password_to_create_user

    def test_admin_needs_password_to_create_user(self):
        with self.assertRaises(User.DoesNotExist):
            User.get(loginname="user2")

        self.login(ADMINNAME, ADMINPASS)
        resp = self.post_create_request()
        self.assertIn("You need to enter your current password", resp.data)

        with self.assertRaises(User.DoesNotExist):
            User.get(loginname="user2")
開發者ID:Fivebread,項目名稱:streetsign,代碼行數:10,代碼來源:test_views_users_and_auth.py

示例6: test_admin_can_create_user

    def test_admin_can_create_user(self):
        # should not yet exist:
        with self.assertRaises(User.DoesNotExist):
            User.get(loginname="user2")

        self.login(ADMINNAME, ADMINPASS)
        resp = self.post_create_request(currpass=ADMINPASS)
        self.assertEqual(resp.status_code, 200)

        User.get(loginname="user2")
開發者ID:Fivebread,項目名稱:streetsign,代碼行數:10,代碼來源:test_views_users_and_auth.py

示例7: test_user_with_one_feed

    def test_user_with_one_feed(self):
        u = User(passwordhash='123')
        f = Feed()

        u.save()
        f.save()

        f.grant('Write', user=u)

        self.assertEqual(u.writeable_feeds(), [f])
開發者ID:Fivebread,項目名稱:streetsign,代碼行數:10,代碼來源:test_models_user.py

示例8: test_new_user_passwords_must_match

    def test_new_user_passwords_must_match(self):
        with self.assertRaises(User.DoesNotExist):
            User.get(loginname="user2")

        self.login(ADMINNAME, ADMINPASS)
        resp = self.post_create_request(currpass=ADMINPASS,
                                        newpass='stuff',
                                        conf_newpass='42')
        self.assertIn("Passwords don't match", resp.data)

        with self.assertRaises(User.DoesNotExist):
            User.get(loginname="user2")
開發者ID:Fivebread,項目名稱:streetsign,代碼行數:12,代碼來源:test_views_users_and_auth.py

示例9: test_cannot_have_empty_password

    def test_cannot_have_empty_password(self):
        with self.assertRaises(User.DoesNotExist):
            User.get(loginname="user2")

        self.login(ADMINNAME, ADMINPASS)
        resp = self.post_create_request(currpass=ADMINPASS,
                                        newpass='',
                                        conf_newpass='')
        self.assertIn("Cannot Save", resp.data)
        self.assertIn("passwordhash", resp.data)

        with self.assertRaises(User.DoesNotExist):
            User.get(loginname="user2")
開發者ID:Fivebread,項目名稱:streetsign,代碼行數:13,代碼來源:test_views_users_and_auth.py

示例10: test_admin_can_unset_admin

    def test_admin_can_unset_admin(self):
        self.assertFalse(self.user.is_admin)
        self.user.is_admin = True
        self.user.save()

        usernow = User.get(id=self.user.id)
        self.assertTrue(usernow.is_admin)

        self.login(ADMINNAME, ADMINPASS)
        resp = self.post_update_request(userid=self.user.id, is_admin=False)

        usernow = User.get(id=self.user.id)
        self.assertFalse(usernow.is_admin)
開發者ID:Fivebread,項目名稱:streetsign,代碼行數:13,代碼來源:test_views_users_and_auth.py

示例11: setUp

    def setUp(self):
        super(BasicUsersTestCase, self).setUp()
        self.user = User(loginname=USERNAME,
                         emailaddress='[email protected]',
                         is_admin=False)
        self.user.set_password(USERPASS)
        self.user.save()


        self.admin = User(loginname=ADMINNAME,
                          emailaddress='[email protected]',
                          is_admin=True)
        self.admin.set_password(ADMINPASS)
        self.admin.save()
開發者ID:Fivebread,項目名稱:streetsign,代碼行數:14,代碼來源:test_views_users_and_auth.py

示例12: test_user_with_one_feed_via_group

    def test_user_with_one_feed_via_group(self):
        u = User(passwordhash='123')
        g = Group(name='group_with_a_name')
        f = Feed()

        u.save()
        f.save()
        g.save()

        g.set_users([u.id])

        f.grant('Write', group=g)

        self.assertEqual(u.writeable_feeds(), [f])
開發者ID:Fivebread,項目名稱:streetsign,代碼行數:14,代碼來源:test_models_user.py

示例13: test_admin_can_make_admin_with_on

    def test_admin_can_make_admin_with_on(self):
        self.assertFalse(self.user.is_admin)
        self.login(ADMINNAME, ADMINPASS)
        resp = self.post_update_request(userid=self.user.id, is_admin="on")

        usernow = User.get(id=self.user.id)
        self.assertTrue(usernow.is_admin)
開發者ID:Fivebread,項目名稱:streetsign,代碼行數:7,代碼來源:test_views_users_and_auth.py

示例14: group

def group(groupid):
    ''' edit one user group. '''

    try:
        thisgroup = Group.get(id=groupid)
    except:
        flash('Invalid group ID')
        return redirect(request.referrer if request.referrer else '/')

    if request.method == 'POST':
        if request.form.get('action', 'none') == 'delete':
            UserGroup.delete().where(UserGroup.group == thisgroup).execute()
            thisgroup.delete_instance()
            flash('group:'+ thisgroup.name +' deleted.')
            return redirect(url_for('users_and_groups'))

        if request.form.get('action', 'none') == 'update':
            thisgroup.name = request.form.get('groupname', thisgroup.name)
            thisgroup.save()

            groupusers = request.form.getlist('groupusers')
            thisgroup.set_users(groupusers)
            flash('saved')

    return render_template('group.html', group=thisgroup, allusers=User.select())
開發者ID:Fivebread,項目名稱:streetsign,代碼行數:25,代碼來源:users_and_auth.py

示例15: test_one_user_publish

    def test_one_user_publish(self):
        f = Feed(name='123')
        f.save()

        u = User(passwordhash='123')
        u.save()

        f.grant('Publish', user=u)

        self.assertEqual(f.authors(), [])
        self.assertEqual(f.publishers(), [u])
        self.assertEqual(f.author_groups(), [])
        self.assertEqual(f.publisher_groups(), [])

        self.assertFalse(f.user_can_write(u))
        self.assertTrue(f.user_can_publish(u))
開發者ID:Fivebread,項目名稱:streetsign,代碼行數:16,代碼來源:test_models_feed.py


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