本文整理匯總了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