wip - wizard review page

This commit is contained in:
Andrea Carulli 2024-05-15 18:02:38 +02:00
parent b968a78aa5
commit 13e5217601
3 changed files with 59 additions and 14 deletions

View File

@ -123,28 +123,31 @@ async def room_wizard(request, order:Order):
},
'B':{
'type': 'new',
'room_type': 5,
'to_add': ['B', 'a', 'c']
}
}
result_map = {}
# Fill already existing rooms
for room_order in incomplete_orders.items():
room = room_order.value
room = room_order[1]
to_add = []
missing_slots = room.room_person_no - len(room.room_members)
for i in enumerate(missing_slots):
for i in range(missing_slots):
compatible_roomates = {key:value for key,value in roomless_orders.items() if value.bed_in_room == room.bed_in_room}
if len(compatible_roomates.items()) == 0: break
# Try picking a roomate that's from the same country and room type
country = room.country.lower()
roomless_by_country = {key:value for key,value in compatible_roomates.items() if value.country.lower() == country}
if len(roomless_by_country.items()) > 0:
code_to_add = roomless_by_country.keys()[0]
code_to_add = list(roomless_by_country.keys())[0]
to_add.append(code_to_add)
del roomless_orders[code_to_add]
else:
# If not, add first roomless there is
code_to_add = compatible_roomates.keys()[0]
code_to_add = list(compatible_roomates.keys())[0]
to_add.append(code_to_add)
del roomless_orders[code_to_add]
result_map[room.code] = {
@ -152,15 +155,33 @@ async def room_wizard(request, order:Order):
'to_add': to_add
}
# Create additional rooms
while len(roomless_orders.items()) > 0:
room = list(roomless_orders.items())[0][1]
to_add = []
missing_slots = room.room_person_no - len(room.room_members)
for i in range(missing_slots):
compatible_roomates = {key:value for key,value in roomless_orders.items() if value.bed_in_room == room.bed_in_room}
if len(compatible_roomates.items()) == 0: break
# Try picking a roomate that's from the same country and room type
country = room.country.lower()
roomless_by_country = {key:value for key,value in compatible_roomates.items() if value.country.lower() == country}
if len(roomless_by_country.items()) > 0:
code_to_add = list(roomless_by_country.keys())[0]
to_add.append(code_to_add)
del roomless_orders[code_to_add]
else:
# If not, add first roomless there is
code_to_add = list(compatible_roomates.keys())[0]
to_add.append(code_to_add)
del roomless_orders[code_to_add]
result_map[room.code] = {
'type': 'new',
'room_type': room.bed_in_room,
'to_add': to_add
}
print ('Incomplete orders')
for order in incomplete_orders.values():
print(f'{order.code} - {order.bed_in_room}')
print ('Roomless')
for order in roomless_orders.values():
print(f'{order.code} - {order.bed_in_room}')
return redirect(f'/manage/admin')
tpl = request.app.ctx.tpl.get_template('wizard.html')
return html(tpl.render(order=order, orders=orders, data=result_map))
@bp.get('/propic/remind')
async def propic_remind_missing(request, order:Order):

View File

@ -7,7 +7,7 @@
<div aria-hidden="true" class="propic-border-animation"></div>
</div>
{% endif %}
{% if current and current.isAdmin () and (not current.code == order.code )%}
{% if current and current.isAdmin () and (not current.code == order.code ) and not nologin %}
<a class="control-login-as" href="/manage/admin/loginas/{{order.code}}">
{% endif %}
<img alt="{{order.ans('fursona_name') if order.ans('fursona_name') else 'A user'}}'s profile picture" src="{{imgSrc}}" class="absolute propic {{(('propic-' + order.sponsorship) if not effects else '') if order.sponsorship else 'propic-base'}}"/>

24
tpl/wizard.html Normal file
View File

@ -0,0 +1,24 @@
{% extends "base.html" %}
{% block title %}Admin panel{% endblock %}
{% block main %}
<main class="container">
<script src="/res/scripts/wizardManager.js"></script>
<header>
<picture>
<source srcset="/res/furizon.png" media="(prefers-color-scheme:dark)">
<img src="/res/furizon-light.png" style="height:4rem;text-align:center;">
</picture>
</header>
<!--order = current order login
orders = all non confirmed rooms orders
data = assigned rooms -->
<h2>Review rooms</h2>
<hr>
{% for room in data.items() %}
{%with room_order = orders[room[0]] %}
{% endwith %}
{% endfor %}
</main>
{% endblock %}