本文整理汇总了Python中models.account.Account.query方法的典型用法代码示例。如果您正苦于以下问题:Python Account.query方法的具体用法?Python Account.query怎么用?Python Account.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.account.Account
的用法示例。
在下文中一共展示了Account.query方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import query [as 别名]
def get(self):
self._require_admin()
self.template_values['memcache_stats'] = memcache.get_stats()
# Gets the 5 recently created users
users = Account.query().order(-Account.created).fetch(5)
self.template_values['users'] = users
# Retrieves the number of pending suggestions
video_suggestions = Suggestion.query().filter(Suggestion.review_state == Suggestion.REVIEW_PENDING).count()
self.template_values['video_suggestions'] = video_suggestions
# version info
try:
fname = os.path.join(os.path.dirname(__file__), '../../version_info.json')
with open(fname, 'r') as f:
data = json.loads(f.read().replace('\r\n', '\n'))
self.template_values['git_branch_name'] = data['git_branch_name']
self.template_values['build_time'] = data['build_time']
commit_parts = re.split("[\n]+", data['git_last_commit'])
self.template_values['commit_hash'] = commit_parts[0].split(" ")
self.template_values['commit_author'] = commit_parts[1]
self.template_values['commit_date'] = commit_parts[2]
self.template_values['commit_msg'] = commit_parts[3]
except Exception, e:
logging.warning("version_info.json parsing failed: %s" % e)
pass
示例2: get
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import query [as 别名]
def get(self):
self._require_admin()
self.template_values['memcache_stats'] = memcache.get_stats()
self.template_values['databasequery_stats'] = {
'hits': sum(filter(None, [memcache.get(key) for key in DatabaseQuery.DATABASE_HITS_MEMCACHE_KEYS])),
'misses': sum(filter(None, [memcache.get(key) for key in DatabaseQuery.DATABASE_MISSES_MEMCACHE_KEYS]))
}
# Gets the 5 recently created users
users = Account.query().order(-Account.created).fetch(5)
self.template_values['users'] = users
self.template_values['suggestions_count'] = Suggestion.query().filter(
Suggestion.review_state == Suggestion.REVIEW_PENDING).count()
# version info
try:
fname = os.path.join(os.path.dirname(__file__), '../../version_info.json')
with open(fname, 'r') as f:
data = json.loads(f.read().replace('\r\n', '\n'))
self.template_values['git_branch_name'] = data['git_branch_name']
self.template_values['build_time'] = data['build_time']
commit_parts = re.split("[\n]+", data['git_last_commit'])
self.template_values['commit_hash'] = commit_parts[0].split(" ")
self.template_values['commit_author'] = commit_parts[1]
self.template_values['commit_date'] = commit_parts[2]
self.template_values['commit_msg'] = commit_parts[3]
except Exception, e:
logging.warning("version_info.json parsing failed: %s" % e)
pass
示例3: get
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import query [as 别名]
def get(self):
self._require_admin()
users = Account.query().order(Account.created).fetch(10000)
self.template_values.update({
"users": users,
})
path = os.path.join(os.path.dirname(__file__), '../../templates/admin/user_list.html')
self.response.out.write(template.render(path, self.template_values))
示例4: post
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import query [as 别名]
def post(self):
self._require_admin()
user_email = self.request.get('email')
if not user_email:
self.abort(404)
users = Account.query(Account.email == user_email).fetch()
if not users:
self.abort(404)
user = users[0]
self.redirect('/admin/user/edit/{}'.format(user.key.id()))
示例5: send_event_reminders
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import query [as 别名]
def send_event_reminders(key):
event = key.get()
accounts = Account.query().get()
client = TwilioRestClient(strings.ACCOUNT_SID, strings.AUTH_TOKEN)
response_body = response.get_response(response_strings.EVENT_REMINDER, response_strings.VAR_SUMMARY,
response_strings.VAR_TIME, response_strings.VAR_DESCRIPTION)
for account in accounts:
client.messages.create(to=account.phone, from_=strings.SERVICE_NUMBER, body=response_body)
示例6: get
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import query [as 别名]
def get(self):
self._require_admin()
users = Account.query(Account.permissions != None).fetch()
self.template_values.update({
"users": users,
"permissions": AccountPermissions.permissions,
})
path = os.path.join(os.path.dirname(__file__), '../../templates/admin/user_permissions_list.html')
self.response.out.write(template.render(path, self.template_values))
示例7: post
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import query [as 别名]
def post(self, auth_id):
self._require_admin()
auth = ApiAuthAccess.get_by_id(auth_id)
auth_types_enum = []
if self.request.get('allow_edit_teams'):
auth_types_enum.append(AuthType.EVENT_TEAMS)
if self.request.get('allow_edit_matches'):
auth_types_enum.append(AuthType.EVENT_MATCHES)
if self.request.get('allow_edit_rankings'):
auth_types_enum.append(AuthType.EVENT_RANKINGS)
if self.request.get('allow_edit_alliances'):
auth_types_enum.append(AuthType.EVENT_ALLIANCES)
if self.request.get('allow_edit_awards'):
auth_types_enum.append(AuthType.EVENT_AWARDS)
if self.request.get('allow_edit_match_video'):
auth_types_enum.append(AuthType.MATCH_VIDEO)
if self.request.get('owner', None):
owner = Account.query(Account.email == self.request.get('owner')).fetch()
owner_key = owner[0].key if owner else None
else:
owner_key = None
if self.request.get('expiration', None):
expiration = datetime.strptime(self.request.get('expiration'), '%Y-%m-%d')
else:
expiration = None
if not auth:
auth = ApiAuthAccess(
id=auth_id,
description=self.request.get('description'),
owner=owner_key,
expiration=expiration,
secret=''.join(random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits) for _ in range(64)),
event_list=[ndb.Key(Event, event_key.strip()) for event_key in self.request.get('event_list_str').split(',')],
auth_types_enum=auth_types_enum,
)
else:
auth.description = self.request.get('description')
auth.event_list = event_list=[ndb.Key(Event, event_key.strip()) for event_key in self.request.get('event_list_str').split(',')]
auth.auth_types_enum = auth_types_enum
auth.owner = owner_key
auth.expiration = expiration
auth.put()
self.redirect("/admin/api_auth/manage")
示例8: get
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import query [as 别名]
def get(self):
# Validate that request came from Twilio service.
validator = RequestValidator(strings.AUTH_TOKEN)
url = self.request.url
url = url.replace("http", "https")
signature = self.request.headers.get("X-Twilio-Signature", "")
if not validator.validate(url, {}, signature):
logging.warn("Request did not come from Twilio.")
self.response.status = 403
return
phone = self.request.get("From", None)
account = Account.query().filter(Account.phone == phone).get()
# Sending messages separately, send empty TwiML for now.
twiml = twilio.twiml.Response()
response = get_response(response_strings.CALL_HELLO, response_strings.VAR_NAME)
if account and account.first:
response = response.replace(response_strings.VAR_NAME, account.first)
else:
response = response.replace(response_strings.VAR_NAME, "")
twiml.addSay(response)
tracks = [
"better_things",
"dare",
"enchanted",
"makes_me_wonder",
"the_reeling",
"viva_la_vida"
]
track_num = random.randint(0, len(tracks) - 1)
twiml.addPlay(self.request.application_url + "/static/mp3/" + tracks[track_num] + ".mp3")
response = get_response(response_strings.CALL_GOODBYE)
twiml.addSay(response)
twiml.addHangup()
self.response.write(twiml)
示例9: get
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import query [as 别名]
def get(self):
# Validate that request came from Twilio service.
validator = RequestValidator(strings.AUTH_TOKEN)
url = self.request.url
url = url.replace("http", "https")
signature = self.request.headers.get("X-Twilio-Signature", "")
if not validator.validate(url, {}, signature):
logging.warn("Request did not come from Twilio.")
self.response.status = 403
return
# Sending messages separately, send empty TwiML for now.
twiml = twilio.twiml.Response()
self.response.write(twiml)
twilio_client = TwilioRestClient(strings.ACCOUNT_SID, strings.AUTH_TOKEN)
phone = self.request.get("From", None)
account = Account.query().filter(Account.phone == phone).get()
if account is None:
account = create.controller(self.request)
was_command = False
if not account.state_locked:
was_command = command.controller(self.request, account)
if not was_command:
if account.state == account_model.STATE_ONBOARD:
onboard.controller(self.request, account)
elif account.state == account_model.STATE_DELETE:
delete.controller(self.request, account)
else:
response = get_response(response_strings.NO_MATCH, response_strings.VAR_NAME)
response = response.replace(response_strings.VAR_NAME, account.first)
twilio_client.messages.create(to=account.phone, from_=strings.SERVICE_NUMBER, body=response)