本文整理汇总了Python中models.user.User.all方法的典型用法代码示例。如果您正苦于以下问题:Python User.all方法的具体用法?Python User.all怎么用?Python User.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.user.User
的用法示例。
在下文中一共展示了User.all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_oauth2callback_path_succeeds_for_existing_user
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all [as 别名]
def test_oauth2callback_path_succeeds_for_existing_user(self):
google_api.httplib2.Http = MockHttp
# Create dummy user
now = datetime.now()
user = User(profile_slug='dummy_user', google_id='12345', created_at=now, last_login_at=now, modified_at=now)
user.put()
num_users = User.all().count()
response = main.app.get_response('/auth/oauth2callback?code=abc123')
# Ensure existing user record has been updated with info from Google (data/user_info.json)
user = User.get_by_google_id('12345')
self.assertEqual(num_users, User.all().count())
self.assertEqual(user.google_birthday, '0000-01-01')
self.assertEqual(user.google_email, '[email protected]')
self.assertEqual(user.google_gender, 'male')
self.assertEqual(user.google_locale, 'en-GB')
self.assertEqual(user.google_name, 'Dummy User')
self.assertEqual(user.google_picture_url, 'https://lh3.googleusercontent.com/photo.jpg')
# Ensure correct response
self.assertEqual(response.status_int, 302)
self.assertTrue('Location' in response.headers)
self.assertTrue('http://localhost/' in response.headers['Location'])
示例2: back_money_apply
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all [as 别名]
def back_money_apply(sender, apply_context):
order = apply_context['order']
num = apply_context['num']
type = apply_context['type']
if type == 'invoice':
s_title = u'项目回款信息-返点发票信息'
elif type == 'end':
s_title = u'项目回款完成'
elif type == 'no_end':
s_title = u'回款状态变为未完成'
else:
s_title = u'项目回款信息'
if num == -1:
s_title = u'坏账项目'
if order.__tablename__ in ['searchAd_bra_client_order', 'searchAd_bra_rebate_order']:
to_users = order.direct_sales + order.agent_sales + \
[order.creator, g.user] + order.leaders
else:
to_users = order.direct_sales + order.agent_sales + User.contracts() + \
[order.creator, g.user] + order.leaders + User.medias()
if 3 in order.locations:
to_users += [k for k in User.all()
if k.email.find('chenjingjing') >= 0]
if 1 in order.locations:
to_users += [k for k in User.all()
if k.email.find('weizhaoting') >= 0]
if order.__tablename__ == 'bra_client_order':
title = u"【新媒体订单-合同流程】- %s" % (order.name)
elif order.__tablename__ == 'bra_client_medium_order':
title = u"【直签媒体订单-合同流程】- %s" % (order.name)
elif order.__tablename__ == 'bra_framework_order':
title = u"【框架订单-合同流程】- %s" % (order.name)
elif order.__tablename__ == 'bra_douban_order':
title = u"【直签豆瓣订单-合同流程】- %s" % (order.name)
elif order.__tablename__ == 'searchAd_bra_client_order':
title = u"【效果业务普通订单-合同流程】- %s" % (order.name)
elif order.__tablename__ == 'bra_searchAd_framework_order':
title = u"【效果业务框架订单-合同流程】- %s" % (order.name)
elif order.__tablename__ == 'searchad_bra_rebate_order':
title = u"【效果业务返点订单-合同流程】- %s" % (order.name)
else:
title = u"【合同流程】- %s" % (order.name)
url = mail.app.config['DOMAIN'] + order.info_path()
body = u"""
<h3 style="color:red;">流程状态: %s
回款详情:
本次回款金额: %s
已回款完成比例: %s %%
订单链接地址: %s</h3>
<p><h4>订单信息:</h4>
%s</p>
<p>by %s</p>
""" % (s_title, str(num), order.back_money_percent, url, order.email_info, g.user.name)
flash(u'已发送邮件给%s' % (','.join(_get_active_user_name(to_users))), 'info')
_insert_person_notcie(to_users, title, body)
send_html_mail(title, recipients=_get_active_user_email(
to_users), body=body.replace('\n', '<br/>'))
示例3: update
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all [as 别名]
def update(pid):
performance = Performance.get(pid)
if g.user.is_searchad_member() and (not g.user.is_admin()) and (not g.user.is_super_leader()):
users = [u for u in User.all() if u.is_search_saler and u.is_active()]
else:
users = [u for u in User.all() if u.is_out_saler and u.is_active()]
huabei_users = [u for u in users if u.location == TEAM_LOCATION_HUABEI]
huadong_users = [u for u in users if u.location == TEAM_LOCATION_HUADONG]
huanan_users = [u for u in users if u.location == TEAM_LOCATION_HUANAN]
if request.method == 'POST':
year = int(request.values.get('year', datetime.datetime.now().year))
q_month = request.values.get('q_month', 'Q1')
t_money = float(request.values.get('t_money', 0))
user_moneys = {}
if performance.location == TEAM_LOCATION_HUABEI:
for k in huabei_users:
u_money = float(request.values.get('money_' + str(k.id), 0))
user_moneys[str(k.id)] = u_money
elif performance.location == TEAM_LOCATION_HUADONG:
for k in huadong_users:
u_money = float(request.values.get('money_' + str(k.id), 0))
user_moneys[str(k.id)] = u_money
elif performance.location == TEAM_LOCATION_HUANAN:
for k in huanan_users:
u_money = float(request.values.get('money_' + str(k.id), 0))
user_moneys[str(k.id)] = u_money
try:
performance.year = year
performance.q_month = q_month
performance.t_money = t_money
performance.create_time = datetime.date.today()
performance.creator = g.user
performance.save()
performance.performance_user_money.delete()
for k, v in user_moneys.iteritems():
PerformanceUser.add(
user=User.get(int(k)),
money=float(v),
performance=performance,
year=year,
q_month=q_month,
create_time=datetime.date.today()
)
flash(u'%s%s销售计划修改成功' % (str(year), q_month), 'success')
return redirect(url_for('account_performance.update', pid=pid))
except:
flash(u'已存在改季度销售计划', 'danger')
return redirect(url_for('account_performance.update', pid=pid))
return tpl('/account/performance/update.html', huabei_users=huabei_users,
huadong_users=huadong_users, huanan_users=huanan_users,
performance=performance)
示例4: index
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all [as 别名]
def index():
if not (g.user.is_super_leader() or g.user.is_finance()):
return abort(404)
if g.user.is_searchad_member() and (not g.user.is_admin()) and (not g.user.is_super_leader()):
users = [u for u in User.all() if u.is_search_saler]
else:
users = [u for u in User.all() if u.is_out_saler]
huabei_users = [u for u in users if u.location == TEAM_LOCATION_HUABEI]
huadong_users = [u for u in users if u.location == TEAM_LOCATION_HUADONG]
huanan_users = [u for u in users if u.location == TEAM_LOCATION_HUANAN]
return tpl('/account/completion/index.html', huabei_users=huabei_users,
huadong_users=huadong_users, huanan_users=huanan_users)
示例5: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all [as 别名]
def get(self, filename):
user_record = None
user = users.get_current_user()
if user:
user_record = User.all().filter("google_id =", user.user_id()).get()
if not user_record:
user_record = User.all().filter("email =", "[email protected]").get()
if not user_record:
user_record = User(email="[email protected]", anonymous=True).put()
real_filename = "odt_documents/%s.odt" % filename
wk = create_workspace(user_record, open(real_filename).read(), "%s.doc" % filename, True)
self.redirect("/workspace/%i" % wk.key().id())
示例6: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all [as 别名]
def get(self, type = 'html'):
recent = Attraction.all()
recent.filter("next =", None)
recent.order("-datetime")
popular = Attraction.all()
popular.filter("next =", None)
popular.order("-rating")
users = User.all()
users.order("-activity")
template_values = {
'recent': recent.fetch(10),
'popular': popular.fetch(5),
'users': users.fetch(5),
'service': '/home.atom',
'opensearch': '/home.search'
}
for attraction in template_values['recent']:
attraction.thumbnail = self.convertFlickrUrl(attraction.picture, 's')
for attraction in template_values['popular']:
attraction.thumbnail = self.convertFlickrUrl(attraction.picture, 's')
self.output('home', type, template_values)
示例7: outs
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all [as 别名]
def outs():
user_id = int(request.values.get('user_id', 0))
page = int(request.values.get('p', 1))
status = int(request.values.get('status', 0))
start = request.values.get('start', '')
end = request.values.get('end', '')
outs = [
k for k in Out.all() if k.status > 0]
if start and end:
start_time = datetime.datetime.strptime(start, "%Y-%m-%d %H:%M")
end_time = datetime.datetime.strptime(end, "%Y-%m-%d %H:%M")
outs = [k for k in outs if k.start_time >=
start_time and k.start_time < end_time]
if status:
outs = [k for k in outs if k.status == status]
if user_id:
outs = [k for k in outs if k.creator.id == user_id]
outs = sorted(outs, key=lambda x: x.start_time, reverse=True)
if request.values.get('action') == 'excel':
return write_outs_excel(outs)
paginator = Paginator(outs, 50)
try:
outs = paginator.page(page)
except:
outs = paginator.page(paginator.num_pages)
return tpl('/account/out/outs.html', outs=outs, user_id=user_id, start=start,
title=u'所有外出报备列表', status=status,
params="&user_id=%s&start=%s&end=%s&status=%s" % (
user_id, start, end, status), end=end, page=page,
under_users=[{'uid': k.id, 'name': k.name} for k in User.all()])
示例8: users_list
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all [as 别名]
def users_list():
"""
Return all users
"""
users = User.all()
return users.serialize()
示例9: parseTriggerFields
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all [as 别名]
def parseTriggerFields(self):
if not self.request.body:
raise InvalidTriggerFieldsException()
body = json.loads(self.request.body)
if IFTTT_PARAM_TRIGGERFIELDS_KEY not in body:
raise InvalidTriggerFieldsException()
triggerFields = body[IFTTT_PARAM_TRIGGERFIELDS_KEY]
if not triggerFields or \
IFTTT_TRIGGER_FIELD_SHOW_SPOILERS_KEY not in triggerFields or \
IFTTT_TRIGGER_FIELD_SHOW_NSFW_KEY not in triggerFields:
raise InvalidTriggerFieldsException()
username = triggerFields[IFTTT_TRIGGER_FIELD_USERNAME_KEY]
show_spoilers = ('yes' == triggerFields[IFTTT_TRIGGER_FIELD_SHOW_SPOILERS_KEY])
show_nsfw = ('yes' == triggerFields[IFTTT_TRIGGER_FIELD_SHOW_NSFW_KEY])
# Create user if it doesn't already exist
self.user = User.all().filter('steam_username =', username).get()
if self.user is None:
if is_valid_username(username):
self.user = User(
steam_username = username,
steam_show_spoilers = show_spoilers,
steam_show_nsfw = show_nsfw
)
self.user.put()
else:
raise InvalidTriggerFieldsException()
示例10: saveUsertemp
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all [as 别名]
def saveUsertemp(self):
# We determine first if some user information was already in the database
user_query = User.all().filter("mail", self.usertemp.mail)
existingUser = user_query.get()
if(existingUser):
user = existingUser
user.label = self.usertemp.label
oldVcardRef = user.vcardRef
oldImageRef= user.imageRef
if(oldImageRef):
oldImageRefID = str(oldImageRef.key().id())
logging.info("User found: %s, %s" % (user.label, user.mail))
else:
user = User()
oldVcardRef = None
oldImageRef = None
user.label = self.usertemp.label
user.mail = self.usertemp.mail
if(self.usertemp.imageRef):
# We replace the old image Ref/ (or if not found) add the new image Ref
user.imageRef = self.usertemp.imageRef
# If there was an old image ref, we have to delete the image in the blobstore, in the Moodstocks DB and the reference in the Datastore
if(oldImageRef):
# We delete the image from Moodstocks DB
moodstocksHandler = Moodstocks()
moodstocksHandler.deleteObject(oldImageRefID)
# We delete the image in the blobstore
blobInfo = oldImageRef.blobKey
oldBlobKey = blobInfo.key()
blobstore.delete(oldBlobKey)
# We delete the existing image Ref
oldImageRef.delete()
if(self.usertemp.vcardRef):
# We replace the old vcard Ref/ (or if not found) by the new vcard Ref
user.vcardRef = self.usertemp.vcardRef
# If there was an old vcard ref, we have to delete it from to datastore
if(oldVcardRef):
oldVcardRef.delete()
user.put()
self.usertemp.delete()
path = None
if(user.imageRef):
if(user.vcardRef):
path = os.path.join(os.path.dirname(__file__), 'templates/post/all_set.html')
else:
path = os.path.join(os.path.dirname(__file__), 'templates/post/almost_set_vcard_missing.html')
else:
path = os.path.join(os.path.dirname(__file__), 'templates/post/almost_set_image_missing.html')
self.response.out.write(template.render(path, None))
示例11: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all [as 别名]
def get(self,key):
user = User()
categroy = Category()
user_keys = user.allKey()
category_keys = categroy.allKey()
_data_user = user.all(user_keys)
_data_category = categroy.all(category_keys)
data = {}
if key:
board = Board()
board.data = board.get(key)
data['title'] = board.data['title']
data['key'] = board.data['key']
data['user'] = board.data['user']
data['category'] = board.data['category']
data['createTime'] = board.data['createTime']
data['follow'] = board.data['follow']
else:
data['title'] = ''
data['key'] = ''
data['user'] = ''
data['category'] = ''
self.render('manager/board_new.html',data = data,data_user = _data_user,data_category = _data_category)
示例12: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all [as 别名]
def get(self):
users = User.all().run()
for u in users:
u.show_colleges = True
u.hide_visited = True
u.put()
self.response.out.write('success')
示例13: getUserObject
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all [as 别名]
def getUserObject(self, user = None):
from google.appengine.api import users
from models.user import User
if user == None:
user = users.get_current_user()
userId = self.getUserId(user)
if not userId:
return None
query = User.all()
query.filter("id =", userId)
userObject = query.get()
if userObject == None:
if type(user) == users.User:
userObject = User(
id = userId,
username = user.nickname().split('@')[0],
name = user.nickname().split('@')[0]
)
else:
userObject = User(
id = userId,
username = userId,
name = userId
)
userObject.put()
return userObject
示例14: receive
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all [as 别名]
def receive(self, message):
logging.info("[email protected] request")
self.mail = message
self.senderMail = None
self.existingUser = None
self.existingImage = None
self.responseMail = None
# We extract mail information with a regex
mailRegexMatch = re.search(r"[\w\-][\w\-\.][email protected][\w\-][\w\-\.]+[a-zA-Z]{1,4}", self.mail.sender)
self.senderMail = mailRegexMatch.group()
logging.info("Received a message from: " + self.senderMail)
# We look if this user is in our database
user_query = User.all().filter("mail", self.senderMail)
self.existingUser = user_query.get()
# We look if there is user and if the user provided an image
try:
imageRef = self.existingUser.imageRef
except:
imageRef = None
if imageRef:
logging.info("Image found")
blobKey = imageRef.blobKey
blobReader = blobstore.BlobReader(blobKey)
self.existingImage = blobReader.read()
self.sendResponseMail()
示例15: from_user
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all [as 别名]
def from_user(self, mask, o=None, *_):
# TODO: If the "o" parameter is passed only operators are returned
# according to the <mask> supplied.
# TODO: If there is a list of parameters supplied
# with a WHO message, a RPL_ENDOFWHO MUST be sent
# after processing each list item with <name> being
# the item.
resp = []
if Channel.exists(mask):
channel = Channel.get(mask)
for channel_user in channel.users:
resp.append(
RPL_WHOREPLY(self.actor, channel_user, str(channel))
)
else:
if mask == '0':
mask = '*'
parser = abnf.wildcard(mask)
for user in User.all():
# TODO: add check for servername
if any([abnf.parse(str, parser)
for str
in [user.hostname, user.realname, user.nickname]]):
resp.append(RPL_WHOREPLY(self.actor, user, mask))
#resp.append(RPL_ENDOFWHO(self.user, str(channel)))
return resp