removed code duplication
This commit is contained in:
parent
8b65b704da
commit
08848ddc5b
|
@ -24,29 +24,23 @@ def show_match(tournament_id, match_id):
|
|||
participants = list()
|
||||
for opponent in match['opponents']:
|
||||
participant = toornament.get_participant(tournament_id, opponent['participant']['id'])
|
||||
generate_multilink = False
|
||||
if 'summoner_name' in participant['lineup'][0]['custom_fields']:
|
||||
summoner_names = list()
|
||||
for player in participant['lineup']:
|
||||
summoner_names.append(player['custom_fields']['summoner_name'])
|
||||
multilink_params = {
|
||||
'query': ','.join(summoner_names)
|
||||
}
|
||||
participant['opgg_multilink'] = urllib.parse.urlencode(multilink_params)
|
||||
generate_multilink = True
|
||||
elif 'beschwoerername' in participant['lineup'][0]['custom_fields']:
|
||||
for idx, _ in enumerate(participant['lineup']):
|
||||
participant['lineup'][idx]['custom_fields']['summoner_name'] = \
|
||||
participant['lineup'][0]['custom_fields']
|
||||
summoner_names = list()
|
||||
for player in participant['lineup']:
|
||||
summoner_names.append(player['custom_fields']['summoner_name'])
|
||||
multilink_params = {
|
||||
'query': ','.join(summoner_names)
|
||||
}
|
||||
participant['opgg_multilink'] = urllib.parse.urlencode(multilink_params)
|
||||
generate_multilink = True
|
||||
elif participant['lineup'][0]['custom_fields'] == {}:
|
||||
for idx, _ in enumerate(participant['lineup']):
|
||||
participant['lineup'][idx]['custom_fields']['summoner_name'] = \
|
||||
participant['lineup'][idx]['name']
|
||||
generate_multilink = True
|
||||
else:
|
||||
for idx, _ in enumerate(participant['lineup']):
|
||||
participant['lineup'][idx]['custom_fields']['summoner_name'] = 'N/V'
|
||||
if generate_multilink:
|
||||
summoner_names = list()
|
||||
for player in participant['lineup']:
|
||||
summoner_names.append(player['custom_fields']['summoner_name'])
|
||||
|
@ -54,8 +48,5 @@ def show_match(tournament_id, match_id):
|
|||
'query': ','.join(summoner_names)
|
||||
}
|
||||
participant['opgg_multilink'] = urllib.parse.urlencode(multilink_params)
|
||||
else:
|
||||
for idx, _ in enumerate(participant['lineup']):
|
||||
participant['lineup'][idx]['custom_fields']['summoner_name'] = 'N/V'
|
||||
participants.append(participant)
|
||||
return render_template('match.html', match=match, participants=participants, tournament=tournament)
|
||||
|
|
Loading…
Reference in New Issue