• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.History类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.History的典型用法代码示例。如果您正苦于以下问题:Python History类的具体用法?Python History怎么用?Python History使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了History类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: new_game

    def new_game(self, request):
        """Creates a Game.
            Args:
            request: The NEW_GAME_REQUEST objects, which includes two players'
                names
            Returns:
                GameForm with created game
            Raises:
                endpoints.NotFoundException: If the user does not exist.
                endpoints.BadRequestException: If the game is created with one
                user.
        """
        user_x = User.query(User.name == request.user_name_x).get()
        user_o = User.query(User.name == request.user_name_o).get()
        if (not user_o) or (not user_x):
            raise endpoints.NotFoundException(
                    'A User with that name does not exist!')
        try:
            game = Game.new_game(user_x.key, user_o.key)
            history = History(game=game.key)
            history.put()
        except ValueError:
            raise endpoints.BadRequestException('Players should be '
                                                'different!')

        return game.to_form('Good luck playing TicTacToe!')
开发者ID:NadiiaLukianenko,项目名称:tictactoegame,代码行数:26,代码来源:api.py


示例2: post

    def post(self):
        isajax = self.request.get('isajax')
        phone = self.request.get('phone')
        msg = self.request.get('msg')
        contact_name = self.request.get('contact_name')

        user = users.get_current_user()
        email = user.email().lower()
        q = Token.query(Token.email == email)
        token = q.get()
        status = 100
        hist=''
        logging.debug(email + ' ' + phone + ' ' + msg + ' ' + contact_name)
        if token:
            status = 101
            if len(phone) and len(msg):
                status = 200
                hist = History(email=email, msg=msg, phone=phone, contact_name = contact_name)
                hist.put()
                airship.push({
                    "android": {
                         "extra": {"msgid": str(hist.key.id()), "phone": phone, "msg":msg}
                    }
                }, apids=[token.apid])
                id = hist.key.id()
                hist = hist.to_dict()
                hist['created']=hist['created'].isoformat();
                hist['id'] = id
                hist['type'] = 'sms'        
        self.response.out.write(json.dumps({'status':status, 'msg':hist}))
开发者ID:spicavigo,项目名称:onlinesms_server,代码行数:30,代码来源:hello_world.py


示例3: upload

def upload(request):
    if request.method == 'POST':
        form = SelfieForm(request.POST, request.FILES)
        if form.is_valid():
            instance = Selfie(photo=request.FILES['photo'])
            instance.user = request.user
            instance.info = form.cleaned_data["info"]
            instance.save()

            hist = History(selfie=instance, date=instance.pub_date, matches=0, score=1500)
            hist.save()

            img = Image.open(instance.photo.file)
            x1 = float(request.POST["x1"])
            x2 = float(request.POST["x2"])
            y1 = float(request.POST["y1"])
            y2 = float(request.POST["y2"])
            img.crop((x1, y1, x2, y2)).resize((640, 640)).save(instance.photo.file.file.name)

            print "new salfie: ", instance, "; anlisys result: ", instance.analyze()
            return HttpResponseRedirect(reverse('selfzone.panel:index'))
        return render(request, 'selfzone/uploadForm.html', {'form': form})
    else:
        form = SelfieForm()
        return render(request, 'selfzone/uploadForm.html', {'form': form})
开发者ID:cecco4,项目名称:selfzone_proj,代码行数:25,代码来源:views.py


示例4: addToHistory

    def addToHistory(self, song_instance, user_list):
        history_instance = History(
            Song=song_instance
        )
        history_instance.save()

        if user_list is not None and user_list.count() > 0:
            for user_instance in user_list.all():
                history_instance.User.add(user_instance)
开发者ID:rejahrehim,项目名称:jukebox,代码行数:9,代码来源:api.py


示例5: confirm_order

def confirm_order(request):
    cart=get_cart(request)
    history = History(id_user=request.user) 
    history.save() 
    for product in cart.id_products.all():
        product.quantity = product.quantity - 1
        history.id_product.add(product)
        product.save()
    history.save()
    cart.delete()    
    return redirect('home')
开发者ID:awpcourse,项目名称:onlineshop,代码行数:11,代码来源:views.py


示例6: get

 def get(self):
     contact_name = self.request.get('contact_name')    
     phone = self.request.get('phone')
     msg = self.request.get('msg')
     email = self.request.get("email",'').lower()
     hist = History(email=email, msg=msg, phone=phone, contact_name = contact_name, byme=False)
     hist.put()
     id = hist.key.id()
     hist = hist.to_dict()
     hist['created']=hist['created'].isoformat();
     hist['id'] = id
     hist['type'] = 'sms'  
     channel.send_message(email, json.dumps(hist))
     self.response.out.write(json.dumps({}))
开发者ID:spicavigo,项目名称:onlinesms_server,代码行数:14,代码来源:hello_world.py


示例7: smoke_on

def smoke_on(all_sensors, all_rules):
    smoke = True
    GPIO.output(4, 1)
    for sensor in all_sensors:
        if sensor.name == 'Smoke':
            sensor.open = True
            sensor.save()

    for rule in all_rules:
        if rule.rule_id == 6 and rule.is_enabled:
            msg = 'Smoke alarm was triggered!'
            Push.message(msg, channels=["Notifications"])
            history_item = History(Text=msg)
            history_item.save()
            message = sendgrid.Mail(to='[email protected]', subject='Allstate Hub Notification', html='', text=msg, from_email='[email protected]')
            status, mersg = sg.send(message)
开发者ID:mathur,项目名称:allstate_hub,代码行数:16,代码来源:app.py


示例8: get_game_history

 def get_game_history(self, request):
     """Returns all of the game history"""
     game = get_by_urlsafe(request.urlsafe_game_key, Game)
     if not game:
         raise endpoints.NotFoundException(
                 'A Game with that game key does not exist!')
     qry = History.query(History.game == game.key)
     return HistoryForms(items=[history.to_form() for history in qry])
开发者ID:halee9,项目名称:HangMan,代码行数:8,代码来源:api.py


示例9: get_game_history

	def get_game_history(self, request):
		"""Returns a history of all moves made in game."""
		game = get_by_urlsafe(request.urlsafe_game_key, Game)
		if game:
			history = History.query(ancestor=game.key).order(History.order)
			return HistoryForms(items=[move.to_form() for move in history])
		else:
			raise endpoints.NotFoundException("Game not found!")
开发者ID:afumagalli,项目名称:design-a-game,代码行数:8,代码来源:game.py


示例10: history

def history():
    gr = {}
    for r in History.all():
        d = r['date'].date()
        if not d in gr:
            gr[d] = []
        gr[d].append(r)
    return render_template('history.html', data=gr)
开发者ID:misterious-mister-x,项目名称:adverb-front,代码行数:8,代码来源:entry.py


示例11: crawl_user

def crawl_user(account):
    client = weibo.APIClient(app_key=settings.WEIBO_APPKEY, app_secret=settings.WEIBO_APPSECRET)
    client.set_access_token(account.access_token, 0)
    
    if settings.DEBUG:
        COUNT = 21
    else:
        COUNT = settings.WEIBO_API_MAX_COUNT
    id_func = lambda s:s.id 
    
    ##TODO: handle exception
    if not account.latest_status:
        all_statuses = client.statuses.home_timeline.get(count = COUNT).statuses
    else:
        statuses = client.statuses.home_timeline.get(since_id = account.latest_status.id, count = COUNT).statuses
        all_statuses = statuses
        
        while len(statuses) == COUNT:
            last_minid = min(map(id_func, statuses))
            ## The API will return the largest COUNT statuses whose id is larger than since_id
            ## so here is how we iterate to retrieve the entire set
            statuses = client.statuses.home_timeline.get(max_id = last_minid - 1, since_id = account.latest_status.id, count = COUNT).statuses
            all_statuses.extend(statuses)
            
    all_statuses.sort(key=id_func)
    ids = map(id_func, all_statuses)
    assert len(ids) == len(set(ids)) ## Sanity check: no duplicates in the list
    
    saved_statuses = map(store_status, all_statuses)
    for status in saved_statuses:
        ## If we encounter duplicated status, do not create history m2m again
        if not status.weiboaccount_set.exists():
            h = History()
            h.user = account
            h.status = status
            h.save()
    ## Move on if the status is 15 minutes old
    ## This is to deal with API sometimes having missing statuses in between (not even eventually consistent?!) 
    if saved_statuses:
        for i in reversed(range(len(saved_statuses))):
            if older_than(all_statuses[i].created_at, 15): 
                account.latest_status = saved_statuses[i]
                break
    account.save()
    return map(lambda s:s.id, saved_statuses)
开发者ID:xurubin,项目名称:WeiboObservatory,代码行数:45,代码来源:crawl.py


示例12: cancel_game

    def cancel_game(self, request):
        """ Cancels a game from it's urlsafe key """
        game = get_by_urlsafe(request.urlsafe_game_key, Game)
        if not game:
            raise endpoints.NotFoundException("Game not found")

        if not game.game_over and not game.canceled:
            game.canceled = True
            msg = "Game canceled"
            hist = History()
            hist.guess = "-1"
            hist.message = msg
            print hist
            game.history.append(hist)
            game.put()
            return game.to_form(msg)
        else:
            return game.to_form("You cannot cancel a game that is already over")
开发者ID:illusionalsagacity,项目名称:FSND-P4-Design-A-Game,代码行数:18,代码来源:api.py


示例13: get_game_history

 def get_game_history(self, request):
     """Return game history."""
     game = get_by_urlsafe(request.urlsafe_game_key, Game)
     if not game:
         raise endpoints.NotFoundException('Game not found!')
     histories = History.query(ancestor=game.key)
     histories = histories.order(History.turn)
     histories = histories.order(History.player_turn)
     return HistoryForms(items=[history.to_form() for history in histories])
开发者ID:seyfig,项目名称:BattleShip,代码行数:9,代码来源:api.py


示例14: testUpdatePoints

 def testUpdatePoints(self):
     Coin.add('points')
     Coin.add('gold')
     Formula.add('level-gold', definition='gold=10*{level}', owner=None)
     player = self._get_player()
     player.points = 82
     player.level_no = 1
     player.save()
     update_points(player, None)
     coins = History.user_coins(player.user)
     self.assertIn('gold', coins)
     self.assertEqual(coins['gold'], 20)
     player.points = 10
     player.save()
     update_points(player, None)
     coins = History.user_coins(player.user)
     self.assertIn('gold', coins)
     self.assertEqual(coins['gold'], 0)
开发者ID:AndreiRO,项目名称:wouso,代码行数:18,代码来源:tests.py


示例15: get_game_history

 def get_game_history(self, request):
     """Return the game history."""
     game = get_by_urlsafe(request.urlsafe_game_key, Game)
     if game:
         histories = History.query(History.game==game.key).order(History.datetime)
         # histories = History.query(History.game==game.key)            
         return HistoryForms(items = [history.to_form() for history in histories])
     else:
         raise endpoints.NotFoundException('Game not found!')
开发者ID:chinaq,项目名称:FSND-P4-Design-A-Game,代码行数:9,代码来源:api.py


示例16: test_user_points

    def test_user_points(self):
        coin = Coin.add('points')
        player = self._get_player()

        scoring.score_simple(player, 'points', 10)

        up = History.user_points(user=player.user)
        self.assertTrue('wouso' in up)
        self.assertTrue(coin.name in up['wouso'])
        self.assertEqual(up['wouso'][coin.name], 10)
开发者ID:PopAdi,项目名称:wouso,代码行数:10,代码来源:tests.py


示例17: handle

        def handle(self, message):
		tel=message.connection.identity
		msg=message.text.lower().split(" ")

		if History.objects.filter(tel_num=tel):				
			"""The phone number is known in our system """
			for q in History.objects.filter(tel_num=tel):	#We pass on each question that we have to ask to the user
				if(q.status==1):
                                        #The question has been asked to the user but the response is not yet registered.So the incoming text message is the response.
					q.reponse=message.text
					q.status=2
					q.save()
				if(q.status==0):
                                        #The question is not yet asked to the user. We have to ask it to him or to her
					q.status=1
					q.save()
					quest=q.question
					message.respond(" %s " %(quest))
					return True
			message.respond("CONGRATULATION! YOU ARE REGISTERED IN OUR SYSTEM !")	#All questions we have prepared to ask to that user for his/her registration have got response
			return True
		elif msg[0]=='joindre':	
			"""The phone number is not known in our system and the user ask for registration"""
			for q in Questions.objects.all():
                                #We put all questions that we will ask to him/her in the table "History"
				h=History(question=q.question,tel_num=tel,status=0)
				h.save()
			if History.objects.filter(tel_num=tel):
                                #The question(s) for registration are available
				message.respond("WELCOME TO RAPIDSMS!")
			else:
				"""The question(s) for registration are not available 
                and the user must try again later to ask for registration 
                """
				message.respond("SORY, TRY AGAIN LATER!")
                        return True
		else:
			"""The phone number is not known in our system and the 
			system must inform to the user the mesage to send if he/she 
			want to be registered """
			message.respond("SORY YOU ARE NOT REGISTERED! TO REGISTER YOURSELF SEND <JOINDRE> !")
			return True
开发者ID:j3andidier,项目名称:sendsms,代码行数:42,代码来源:app.py


示例18: history

def history(id):
    entry = None
    try:
        entry = History.get(id=id)
    except History.DoesNotExist:
        pass
    except ValueError:
        pass
    if entry is None or entry.user.id != current_user.id:
        abort(404)
    return render_template('history.html', entry=entry)
开发者ID:wodesuck,项目名称:printsrv,代码行数:11,代码来源:history.py


示例19: create_game

    def create_game(self, request):
        """create a new game """

        # look up initiating player
        slinger = Player.query(Player.player_id == request.player_id).get()

        if slinger is None:
            raise endpoints.BadRequestException(
                'specified player_id not found')

        # generate new game
        game_id = uniq_id()
        game = Game(game_id=game_id, player_id=slinger.player_id)
        game.put()

        # create game history for this game
        history = History(game=game.key)
        history.put()

        return game.to_message()
开发者ID:bschmoker,项目名称:highnoon,代码行数:20,代码来源:api.py


示例20: testUpdatePoints

    def testUpdatePoints(self):
        IntegerListSetting.get('level_limits').set_value("80 125 180 245 320 450")

        Coin.add('points')
        Coin.add('gold')
        Formula.add('level-gold', expression='gold=10*{level}', owner=None)
        player = self._get_player()
        player.points = 82
        player.level_no = 1
        player.save()
        update_points(player, None)
        coins = History.user_coins(player.user)
        self.assertIn('gold', coins)
        self.assertEqual(coins['gold'], 20)
        player.points = 10
        player.save()
        update_points(player, None)
        coins = History.user_coins(player.user)
        self.assertIn('gold', coins)
        self.assertEqual(coins['gold'], 0)
开发者ID:Sendroiu,项目名称:wouso,代码行数:20,代码来源:tests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Image类代码示例发布时间:2022-05-27
下一篇:
Python models.HDLog类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap