本文整理汇总了Python中streetsign_server.models.User类的典型用法代码示例。如果您正苦于以下问题:Python User类的具体用法?Python User怎么用?Python User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: test_normal_user_cannot_unset_admin
def test_normal_user_cannot_unset_admin(self):
self.login(USERNAME, USERPASS)
resp = self.post_update_request(userid=self.admin.id, is_admin=False)
self.assertEqual(resp.status_code, 403)
adminnow = User.get(id=self.admin.id)
self.assertEqual(adminnow.is_admin, True)
开发者ID:Fivebread,项目名称:streetsign,代码行数:8,代码来源:test_views_users_and_auth.py
示例17: test_emailaddress_must_be_valid
def test_emailaddress_must_be_valid(self):
self.login(USERNAME, USERPASS)
resp = self.post_update_request(emailaddress='BANANA!!!!')
self.assertIn('not a valid emailaddress', resp.data)
usernow = User.get(id=self.user.id)
self.assertEqual(usernow.emailaddress, '[email protected]')
开发者ID:Fivebread,项目名称:streetsign,代码行数:8,代码来源:test_views_users_and_auth.py
示例18: test_admin_can_set_groups
def test_admin_can_set_groups(self):
g1 = self.create_group('g1')
self.assertEqual(self.user.groups(), [])
self.login(ADMINNAME, ADMINPASS)
self.post_update_request(userid=self.user.id, groups=[g1.id])
usernow = User.get(id=self.user.id)
self.assertEqual(usernow.groups(), [g1])
开发者ID:Fivebread,项目名称:streetsign,代码行数:10,代码来源:test_views_users_and_auth.py
示例19: test_cannot_set_own_groups
def test_cannot_set_own_groups(self):
g1 = self.create_group('g1')
self.assertEqual(self.user.groups(), [])
self.login(USERNAME, USERPASS)
self.post_update_request(userid=self.user.id, groups=[g1.id])
usernow = User.get(id=self.user.id)
self.assertEqual(usernow.groups(), [])
开发者ID:Fivebread,项目名称:streetsign,代码行数:10,代码来源:test_views_users_and_auth.py
示例20: feedpage
def feedpage(feedid):
''' the back end settings for one feed. '''
try:
feed = Feed.get(id=feedid)
user = user_session.get_user()
except user_session.NotLoggedIn:
user = User()
except:
flash('invalid feed id! (' + str(feedid) + ')')
return redirect(url_for('feeds'))
if request.method == 'POST':
if not user_session.logged_in():
flash("You're not logged in!")
return redirect(url_for('feeds'))
if not user.is_admin:
flash('Sorry! Only Admins can change these details.')
return redirect(request.referrer)
action = request.form.get('action', 'none')
if action == 'edit':
feed.name = request.form.get('title', feed.name).strip()
inlist = request.form.getlist
feed.post_types = ', '.join(inlist('post_types'))
feed.set_authors(by_id(User, inlist('authors')))
feed.set_publishers(by_id(User, inlist('publishers')))
feed.set_author_groups(by_id(Group, inlist('author_groups')))
feed.set_publisher_groups(by_id(Group, inlist('publisher_groups')))
feed.save()
flash('Saved')
elif action == 'delete':
for post in feed.posts:
post_type_module = post_types.load(post.type)
delete_post_and_run_callback(post, post_type_module)
feed.delete_instance(True, True) # cascade/recursive delete.
flash('Deleted')
return redirect(url_for('feeds'))
return render_template('feed.html',
feed=feed,
user=user,
all_posttypes=post_types.types(),
allusers=User.select(),
allgroups=Group.select()
)
开发者ID:Fivebread,项目名称:streetsign,代码行数:54,代码来源:feeds_and_posts.py
注:本文中的streetsign_server.models.User类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论