当前位置: 首页>>代码示例>>Python>>正文


Python User.all方法代码示例

本文整理汇总了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'])
开发者ID:opendatapress,项目名称:open_data_press,代码行数:27,代码来源:test_session.py

示例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/>'))
开发者ID:giveme168,项目名称:braavos,代码行数:62,代码来源:email_signals.py

示例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)
开发者ID:giveme168,项目名称:braavos,代码行数:57,代码来源:performance.py

示例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)
开发者ID:giveme168,项目名称:braavos,代码行数:14,代码来源:completion.py

示例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())
开发者ID:jpsimons,项目名称:manglebracket,代码行数:15,代码来源:workspace.py

示例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)
开发者ID:peej,项目名称:to.uri.st,代码行数:30,代码来源:homepage.py

示例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()])
开发者ID:giveme168,项目名称:braavos,代码行数:33,代码来源:out.py

示例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()
开发者ID:marceloandriolli,项目名称:featuren,代码行数:9,代码来源:users.py

示例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()
开发者ID:Trinovantes,项目名称:Steam-Screenshots,代码行数:32,代码来源:ifttt.py

示例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))
开发者ID:detcherry,项目名称:capturio,代码行数:62,代码来源:post_capturio_confirmation.py

示例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)
开发者ID:aviatorBeijing,项目名称:ptpy,代码行数:28,代码来源:board.py

示例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')
开发者ID:podgib,项目名称:oxfordpubcrawl,代码行数:9,代码来源:admin.py

示例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
开发者ID:peej,项目名称:to.uri.st,代码行数:34,代码来源:controller.py

示例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()
开发者ID:detcherry,项目名称:capturio,代码行数:33,代码来源:status_capturio.py

示例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
开发者ID:Cloudxtreme,项目名称:python-ircd,代码行数:29,代码来源:who.py


注:本文中的models.user.User.all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。