本文整理汇总了Python中securesync.models.FacilityUser.get_or_initialize方法的典型用法代码示例。如果您正苦于以下问题:Python FacilityUser.get_or_initialize方法的具体用法?Python FacilityUser.get_or_initialize怎么用?Python FacilityUser.get_or_initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类securesync.models.FacilityUser
的用法示例。
在下文中一共展示了FacilityUser.get_or_initialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_test
# 需要导入模块: from securesync.models import FacilityUser [as 别名]
# 或者: from securesync.models.FacilityUser import get_or_initialize [as 别名]
def load_test(request, nusers=None):
global n_users_created
if not n_users_created or n_users_created < int(request.GET.get("nusers", 1)): # default 1, as before
# It's either the first time, or time to add more
# Make sure there's a facility
if not Facility.objects.count():
fac = Facility.objects.create(name="fac")
fac = Facility.objects.all()[0]
# Loop over all needed students
while n_users_created < int(request.GET.get("nusers", 1)):
n_users_created += 1
unpw = "s%d" % n_users_created
user = FacilityUser.get_or_initialize(username=unpw, facility=fac)
user.set_password(unpw)
user.save()
return {
"pct_videos": request.GET.get("pct_videos", 0.9),
"pct_logout": request.GET.get("pct_logout", 0.0),
"nusers": n_users_created,
}