mirror of
https://github.com/arcan1s/ffxivbis.git
synced 2025-04-25 01:37:17 +00:00
some cleanup
This commit is contained in:
parent
082022dee7
commit
14c1e4842c
@ -57,22 +57,23 @@ class BiSHtmlView(BiSBaseView, PlayerBaseView):
|
||||
return wrap_invalid_param(required, data)
|
||||
|
||||
try:
|
||||
method = data.get('method')
|
||||
player_id = PlayerId.from_pretty_name(data.get('player')) # type: ignore
|
||||
method = data.getone('method')
|
||||
player_id = PlayerId.from_pretty_name(data.getone('player')) # type: ignore
|
||||
|
||||
if method == 'post':
|
||||
required = ['action', 'piece']
|
||||
if any(param not in data for param in required):
|
||||
return wrap_invalid_param(required, data)
|
||||
self.bis_post(data.get('action'), player_id, # type: ignore
|
||||
Piece.get({'piece': data.get('piece'), 'is_tome': data.get('is_tome', False)})) # type: ignore
|
||||
is_tome = (data.getone('is_tome', None) == 'on')
|
||||
self.bis_post(data.getone('action'), player_id, # type: ignore
|
||||
Piece.get({'piece': data.getone('piece'), 'is_tome': is_tome})) # type: ignore
|
||||
|
||||
elif method == 'put':
|
||||
required = ['bis']
|
||||
if any(param not in data for param in required):
|
||||
return wrap_invalid_param(required, data)
|
||||
|
||||
self.bis_put(player_id, data.get('bis')) # type: ignore
|
||||
self.bis_put(player_id, data.getone('bis')) # type: ignore
|
||||
|
||||
except Exception as e:
|
||||
self.request.app.logger.exception('could not manage bis')
|
||||
|
@ -58,9 +58,10 @@ class LootHtmlView(LootBaseView, PlayerBaseView):
|
||||
return wrap_invalid_param(required, data)
|
||||
|
||||
try:
|
||||
player_id = PlayerId.from_pretty_name(data.get('player')) # type: ignore
|
||||
self.loot_post(data.get('action'), player_id, # type: ignore
|
||||
Piece.get({'piece': data.get('piece'), 'is_tome': data.get('is_tome', False)})) # type: ignore
|
||||
player_id = PlayerId.from_pretty_name(data.getone('player')) # type: ignore
|
||||
is_tome = (data.getone('is_tome', None) == 'on')
|
||||
self.loot_post(data.getone('action'), player_id, # type: ignore
|
||||
Piece.get({'piece': data.getone('piece'), 'is_tome': is_tome})) # type: ignore
|
||||
|
||||
except Exception as e:
|
||||
self.request.app.logger.exception('could not manage loot')
|
||||
|
@ -39,7 +39,7 @@ class LootSuggestHtmlView(LootBaseView, PlayerBaseView):
|
||||
return wrap_invalid_param(required, data)
|
||||
|
||||
try:
|
||||
piece = Piece.get({'piece': data.get('piece'), 'is_tome': data.get('is_tome', True)})
|
||||
piece = Piece.get({'piece': data.getone('piece'), 'is_tome': data.getone('is_tome', False)})
|
||||
players = self.loot_put(piece)
|
||||
item_values = {'piece': piece.name, 'is_tome': getattr(piece, 'is_tome', True)}
|
||||
|
||||
@ -54,8 +54,10 @@ class LootSuggestHtmlView(LootBaseView, PlayerBaseView):
|
||||
'suggest': [
|
||||
{
|
||||
'player': player.pretty_name,
|
||||
'loot_count_bis': player.loot_count_bis,
|
||||
'is_required': 'yes' if player.is_required else 'no',
|
||||
'loot_count': player.loot_count,
|
||||
'loot_count_bis': player.loot_count_bis,
|
||||
'loot_count_total': player.loot_count_total
|
||||
}
|
||||
for player in players
|
||||
]
|
||||
|
@ -39,7 +39,7 @@ class PlayerHtmlView(PlayerBaseView):
|
||||
'job': player.job.name,
|
||||
'nick': player.nick,
|
||||
'loot_count_bis': player.loot_count_bis,
|
||||
'loot_count': player.loot_count,
|
||||
'loot_count_total': player.loot_count_total,
|
||||
'priority': player.priority
|
||||
}
|
||||
for player in counters
|
||||
@ -55,9 +55,9 @@ class PlayerHtmlView(PlayerBaseView):
|
||||
return wrap_invalid_param(required, data)
|
||||
|
||||
try:
|
||||
action = data.get('action')
|
||||
priority = data.get('priority', 0)
|
||||
link = data.get('bis', None)
|
||||
action = data.getone('action')
|
||||
priority = data.getone('priority', 0)
|
||||
link = data.getone('bis', None)
|
||||
self.player_post(action, Job[data['job'].upper()], data['nick'], link, priority) # type: ignore
|
||||
|
||||
except Exception as e:
|
||||
|
@ -42,14 +42,14 @@ class UsersHtmlView(LoginBaseView):
|
||||
return wrap_invalid_param(required, data)
|
||||
|
||||
try:
|
||||
action = data.get('action')
|
||||
username = str(data.get('username'))
|
||||
action = data.getone('action')
|
||||
username = str(data.getone('username'))
|
||||
|
||||
if action == 'add':
|
||||
required = ['password', 'permission']
|
||||
if any(param not in data for param in required):
|
||||
return wrap_invalid_param(required, data)
|
||||
await self.create_user(username, data.get('password'), data.get('permission')) # type: ignore
|
||||
await self.create_user(username, data.getone('password'), data.getone('permission')) # type: ignore
|
||||
elif action == 'remove':
|
||||
await self.remove_user(username)
|
||||
else:
|
||||
|
@ -41,6 +41,7 @@ class PlayerId:
|
||||
|
||||
@dataclass
|
||||
class PlayerIdWithCounters(PlayerId):
|
||||
is_required: bool
|
||||
priority: int
|
||||
loot_count: int
|
||||
loot_count_bis: int
|
||||
@ -68,7 +69,7 @@ class Player:
|
||||
return PlayerId(self.job, self.nick)
|
||||
|
||||
def player_id_with_counters(self, piece: Union[Piece, Upgrade, None]) -> PlayerIdWithCounters:
|
||||
return PlayerIdWithCounters(self.job, self.nick, self.priority,
|
||||
return PlayerIdWithCounters(self.job, self.nick, self.is_required(piece), self.priority,
|
||||
abs(self.loot_count(piece)), abs(self.loot_count_bis(piece)),
|
||||
abs(self.loot_count_total(piece)), abs(self.bis_count_total(piece)))
|
||||
|
||||
|
@ -24,7 +24,9 @@
|
||||
<table id="result">
|
||||
<tr>
|
||||
<th>player</th>
|
||||
<th>bis pieces looted</th>
|
||||
<th>is required</th>
|
||||
<th>these pieces looted</th>
|
||||
<th>total bis pieces looted</th>
|
||||
<th>total pieces looted</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@ -32,8 +34,10 @@
|
||||
{% for player in suggest %}
|
||||
<tr>
|
||||
<td class="include_search">{{ player.player|e }}</td>
|
||||
<td>{{ player.loot_count_bis|e }}</td>
|
||||
<td>{{ player.is_required|e }}</td>
|
||||
<td>{{ player.loot_count|e }}</td>
|
||||
<td>{{ player.loot_count_bis|e }}</td>
|
||||
<td>{{ player.loot_count_total|e }}</td>
|
||||
<td>
|
||||
<form action="/loot" method="post">
|
||||
<input name="player" id="player" type="hidden" value="{{ player.player|e }}"/>
|
||||
|
@ -28,7 +28,7 @@
|
||||
<tr>
|
||||
<th>nick</th>
|
||||
<th>job</th>
|
||||
<th>bis pieces looted</th>
|
||||
<th>total bis pieces looted</th>
|
||||
<th>total pieces looted</th>
|
||||
<th>priority</th>
|
||||
<th></th>
|
||||
@ -39,7 +39,7 @@
|
||||
<td class="include_search">{{ player.nick|e }}</td>
|
||||
<td class="include_search">{{ player.job|e }}</td>
|
||||
<td>{{ player.loot_count_bis|e }}</td>
|
||||
<td>{{ player.loot_count|e }}</td>
|
||||
<td>{{ player.loot_count_total|e }}</td>
|
||||
<td>{{ player.priority|e }}</td>
|
||||
<td>
|
||||
<form action="/party" method="post">
|
||||
|
Loading…
Reference in New Issue
Block a user