本文整理汇总了Python中core.models.User.query方法的典型用法代码示例。如果您正苦于以下问题:Python User.query方法的具体用法?Python User.query怎么用?Python User.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.models.User
的用法示例。
在下文中一共展示了User.query方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: actualizar_registro
# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import query [as 别名]
def actualizar_registro(cls, documento, nombres, apellidos,
usuario, clave, role, rutas):
existe_documento = cls.existe_documento(documento)
if existe_documento and usuario:
u = User.query(User.documento == documento).get()
u.nombres = nombres
u.apellidos = apellidos
if clave:
u.clave_hash = User.make_pw_hash(usuario, clave)
elif u.usuario != usuario and not cls.existe_usuario(usuario) and clave:
u.clave_hash = User.make_pw_hash(usuario, clave)
u.usuario = usuario
u.role = role
u.put()
rutasEliminar = cls.query_all_rutas(u.key)
if rutasEliminar:
for r in rutasEliminar:
if r.usuario.get().usuario == u.usuario:
r.key.delete()
if rutas:
for rut in rutas:
ruta_key = ndb.Key(urlsafe=rut)
rta = ruta_key.get()
nueva_ruta = UserRuta(ruta=rta.key, usuario=u.key)
nueva_ruta.put()
return ["alert-success", "La actualización ha sido exitoso"]
else:
return ["alert-danger", "No se pudo completar la actualización"]
示例2: existe_usuario
# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import query [as 别名]
def existe_usuario(cls, usuario):
if usuario:
if User.query(User.usuario == usuario).fetch():
return True
else:
return False
else:
return False
示例3: existe_documento
# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import query [as 别名]
def existe_documento(cls, documento):
if documento:
if User.query(User.documento == documento).fetch():
return True
else:
return False
else:
return False
示例4: initialise_db
# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import query [as 别名]
def initialise_db():
# Create an ancestor for all of our Posts to ensure consistency when manipulating Posts
blog_instance = Blog.query().get()
if not blog_instance:
blog_instance = Blog()
blog_instance.put()
# Create Users
if not User.query().fetch():
User(
username='admin',
password='admin' # TODO - obfuscate this
).put()
示例5: authenticate
# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import query [as 别名]
def authenticate(request, username=None, password=None):
"""
Authenticate User, create Session token and return it's value in a Cookie
:param username [STRING]
:param password [PASSWORD]
:return: 200 or 403
"""
user = User.query(User.username == username, User.password == password).get()
if user:
response = render_to_response(ADMIN_PAGE, {})
response.set_cookie(AUTH_COOKIE_KEY, log_user_in(), max_age=SESSION_EXPIRY)
return response
else:
return HttpResponseForbidden()
示例6: has_children
# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import query [as 别名]
def has_children(cls, key):
key = ndb.Key(urlsafe=key)
kind = key.kind()
children = 0
if kind == 'Ciudad':
children += Ruta.query(Ruta.ciudad == key).count()
elif kind == 'Ruta':
children += Abono.query(Abono.ruta == key).count()
children += Cliente.query(Cliente.ruta == key).count()
children += Credito.query(Credito.ruta == key).count()
children += Transaccion.query(Transaccion.ruta == key).count()
children += User.query(User.ruta == key).count()
elif kind == 'Cliente':
pass
elif kind == 'Credito':
pass
return True if children > 0 else False
示例7: query_all
# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import query [as 别名]
def query_all(cls, admin=False):
if admin:
usuarios = User.query().fetch()
else:
usuarios = User.query(User.activo == True).fetch()
return usuarios