本文整理匯總了Python中server.models.User.is_staff方法的典型用法代碼示例。如果您正苦於以下問題:Python User.is_staff方法的具體用法?Python User.is_staff怎麽用?Python User.is_staff使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類server.models.User
的用法示例。
在下文中一共展示了User.is_staff方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_is_staff
# 需要導入模塊: from server.models import User [as 別名]
# 或者: from server.models.User import is_staff [as 別名]
def test_is_staff(self):
self.setup_course()
random_user = User(name=self.studentA['name'], email=self.studentA['email'])
db.session.add(random_user)
db.session.commit()
self.assertTrue(self.staff1.is_staff())
self.assertTrue(self.admin.is_staff())
self.assertFalse(self.user1.is_staff())
self.assertFalse(random_user.is_staff())
示例2: authenticate
# 需要導入模塊: from server.models import User [as 別名]
# 或者: from server.models.User import is_staff [as 別名]
def authenticate(self, username=None, password=None):
login_valid = (settings.ADMIN_LOGIN == username)
pwd_valid = check_password(password, settings.ADMIN_PASSWORD)
if login_valid and pwd_valid:
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
# Create a new user. Note that we can set password
# to anything, because it won't be checked; the password
# from settings.py will.
user = User(username=username, password='get from settings.py')
user.is_staff = True
user.is_superuser = True
user.save()
return user
return None