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