本文整理汇总了Python中models.Game.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Game.delete方法的具体用法?Python Game.delete怎么用?Python Game.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Game
的用法示例。
在下文中一共展示了Game.delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_points_multiple_games
# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import delete [as 别名]
def test_points_multiple_games(self):
game1 = Game(
#tournament = self.tournament1,
time = self.time,
location = self.location,
teamA=self.team1,
teamB=self.team2,
score_teamA=3,
score_teamB=1,
)
game2 = Game(
#tournament = self.tournament1,
time = self.time,
location = self.location,
teamA=self.team1,
teamB=self.team2,
score_teamA=1,
score_teamB=1,
)
game1.save()
game2.save()
self.assertEquals(self.team1.points, 4)
self.assertEquals(self.team2.points, 1)
game1.delete()
game2.delete()
示例2: save_product
# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import delete [as 别名]
def save_product(product_info, imgs_no_downloand):
from models import GameImage, PricesGame, Game
import requests
prices = None
imgs_downloand = None
game = None
try:
if 'gift' not in product_info:
product_info['gift'] = None
if 'stock' not in product_info:
from product import STOCK_CHOICE
product_info['stock'] = STOCK_CHOICE.get('reserva')
if 'pegi' not in product_info:
product_info['pegi'] = None
if not Game.objects.filter(Q(name=product_info['title']) &
Q(plataform=product_info['platform'])).exists():
imgs_downloand = []
if imgs_no_downloand:
for img in imgs_no_downloand:
filename = get_filename(img)
request_imagen = requests.get(img)
if request_imagen.status_code is 200:
image = GameImage(name=product_info['title'])
image.save_image(filename, request_imagen.content)
imgs_downloand.append(image)
product_info['imagenes'] = imgs_downloand if imgs_downloand else None
img = product_info['src']
filename = get_filename(img)
request = requests.get(img)
if request.status_code is 200:
image = GameImage(name=product_info['title'][:15])
image.save_image("main." + filename.split('.')[1], request.content)
product_info['imagen'] = image
else:
product_info['imagen'] = None
prices = PricesGame()
prices.add_price(product_info)
product_info['prices'] = prices
game = Game()
game.add_game(product_info)
else:
prices = PricesGame()
prices.add_price(product_info)
product_info['prices'] = prices
game = Game.objects.get(Q(name=product_info['title'])&Q(plataform=product_info['platform']))
game.prices.add(prices)
except Exception:
if prices:
prices.delete()
if 'imagen' in product_info:
product_info['imagen'].delete()
if imgs_downloand:
for imagen in imgs_downloand:
imagen.delete()
if game:
game.delete()
示例3: test_points_winner2
# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import delete [as 别名]
def test_points_winner2(self):
game = Game(
#tournament = self.tournament1,
time = self.time,
location = self.location,
teamA=self.team1,
teamB=self.team2,
score_teamA=1,
score_teamB=3,
)
game.save()
self.assertEquals(game.is_finished, True)
self.assertEquals(self.team1.points, 0)
self.assertEquals(self.team2.points, 3)
game.delete()