Use version info for owned & wishlisted board games
This commit is contained in:
parent
fde850d13a
commit
6f5436e653
2 changed files with 16 additions and 22 deletions
|
|
@ -123,8 +123,6 @@ def convert_xml_to_boardgame(boardgame_xml: ET.Element) -> boardgame_classes.Boa
|
|||
|
||||
def convert_collection_xml_to_owned_boardgame(boardgame_extra_info: boardgame_classes.BoardGame, collection_boardgame_xml: ET.Element) -> boardgame_classes.BoardGame:
|
||||
|
||||
boardgame_type = collection_boardgame_xml.get('subtype')
|
||||
|
||||
price_paid = collection_boardgame_xml.find('privateinfo').get('pricepaid')
|
||||
if price_paid == '':
|
||||
price_paid = 0.0
|
||||
|
|
@ -152,13 +150,14 @@ def convert_collection_xml_to_owned_boardgame(boardgame_extra_info: boardgame_cl
|
|||
|
||||
boardgame_extra_info.owned_info = owned_info
|
||||
|
||||
# if boardgame_type == "boardgameexpansion":
|
||||
# expansion_boardgame_dict = {
|
||||
# "boardgame_id" : boardgame_extra_info.id,
|
||||
# "expansion_for" : boardgame_extra_info.expansion_for
|
||||
# }
|
||||
# expansion_info = boardgame_classes.ExpansionInfo.model_validate(expansion_boardgame_dict)
|
||||
# boardgame_extra_info.expansion_info = expansion_info
|
||||
boardgame_version_info = collection_boardgame_xml.find('version')
|
||||
|
||||
if boardgame_version_info != None:
|
||||
boardgame_extra_info_item = boardgame_version_info.find('item')
|
||||
boardgame_extra_info.name = collection_boardgame_xml.find('name').text if boardgame_extra_info_item.find('name') != None else boardgame_extra_info.name
|
||||
boardgame_extra_info.image_url = boardgame_extra_info_item.find('image').text if boardgame_extra_info_item.find('image') != None else boardgame_extra_info.image_url
|
||||
boardgame_extra_info.thumbnail_url = boardgame_extra_info_item.find('thumbnail').text if boardgame_extra_info_item.find('thumbnail') != None else boardgame_extra_info.thumbnail_url
|
||||
boardgame_extra_info.year_published = boardgame_extra_info_item.find('yearpublished').get('value') if boardgame_extra_info_item.find('yearpublished') != None else boardgame_extra_info.year_published
|
||||
|
||||
boardgame = boardgame_extra_info
|
||||
|
||||
|
|
@ -166,8 +165,6 @@ def convert_collection_xml_to_owned_boardgame(boardgame_extra_info: boardgame_cl
|
|||
|
||||
def convert_collection_xml_to_wishlist_boardgame(boardgame_extra_info: boardgame_classes.BoardGame, collection_boardgame_xml: ET.Element) -> boardgame_classes.BoardGame:
|
||||
|
||||
boardgame_type = collection_boardgame_xml.get('subtype')
|
||||
|
||||
wishlist_priority = collection_boardgame_xml.find('status').get('wishlistpriority')
|
||||
|
||||
wishlist_boardgame_dict = {
|
||||
|
|
@ -178,17 +175,14 @@ def convert_collection_xml_to_wishlist_boardgame(boardgame_extra_info: boardgame
|
|||
|
||||
boardgame_extra_info.wishlist_info = wishlist_info
|
||||
|
||||
# boardgame_dict = {
|
||||
# **boardgame_extra_info.__dict__,
|
||||
# **wishlist_boardgame_dict
|
||||
# }
|
||||
boardgame_version_info = collection_boardgame_xml.find('version')
|
||||
|
||||
# match boardgame_type:
|
||||
# case "boardgame":
|
||||
# boardgame = boardgame_classes.WishlistBoardGame(**boardgame_dict)
|
||||
# case "boardgameexpansion":
|
||||
# boardgame_dict['expansion_for'] = boardgame_extra_info.expansion_for
|
||||
# boardgame = boardgame_classes.WishlistBoardGameExpansion(**boardgame_dict)
|
||||
if boardgame_version_info != None:
|
||||
boardgame_extra_info_item = boardgame_version_info.find('item')
|
||||
boardgame_extra_info.name = collection_boardgame_xml.find('name').text if boardgame_extra_info_item.find('name') != None else boardgame_extra_info.name
|
||||
boardgame_extra_info.image_url = boardgame_extra_info_item.find('image').text if boardgame_extra_info_item.find('image') != None else boardgame_extra_info.image_url
|
||||
boardgame_extra_info.thumbnail_url = boardgame_extra_info_item.find('thumbnail').text if boardgame_extra_info_item.find('thumbnail') != None else boardgame_extra_info.thumbnail_url
|
||||
boardgame_extra_info.year_published = boardgame_extra_info_item.find('yearpublished').get('value') if boardgame_extra_info_item.find('yearpublished') != None else boardgame_extra_info.year_published
|
||||
|
||||
boardgame = boardgame_extra_info
|
||||
|
||||
|
|
|
|||
|
|
@ -125,4 +125,4 @@ def test_retrieve_game_order_statistic():
|
|||
|
||||
default_statistic_test(returned_statistic)
|
||||
assert type(returned_statistic.result) == list
|
||||
assert type(returned_statistic.result[0]) == boardgame_classes.BoardGame
|
||||
assert type(returned_statistic.result[0]) == boardgame_classes.BoardGamePublic
|
||||
Loading…
Reference in a new issue