wip - wizard review page
This commit is contained in:
parent
b968a78aa5
commit
13e5217601
45
admin.py
45
admin.py
|
@ -123,28 +123,31 @@ async def room_wizard(request, order:Order):
|
||||||
},
|
},
|
||||||
'B':{
|
'B':{
|
||||||
'type': 'new',
|
'type': 'new',
|
||||||
|
'room_type': 5,
|
||||||
'to_add': ['B', 'a', 'c']
|
'to_add': ['B', 'a', 'c']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result_map = {}
|
||||||
|
|
||||||
# Fill already existing rooms
|
# Fill already existing rooms
|
||||||
for room_order in incomplete_orders.items():
|
for room_order in incomplete_orders.items():
|
||||||
room = room_order.value
|
room = room_order[1]
|
||||||
to_add = []
|
to_add = []
|
||||||
missing_slots = room.room_person_no - len(room.room_members)
|
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}
|
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
|
if len(compatible_roomates.items()) == 0: break
|
||||||
# Try picking a roomate that's from the same country and room type
|
# Try picking a roomate that's from the same country and room type
|
||||||
country = room.country.lower()
|
country = room.country.lower()
|
||||||
roomless_by_country = {key:value for key,value in compatible_roomates.items() if value.country.lower() == country}
|
roomless_by_country = {key:value for key,value in compatible_roomates.items() if value.country.lower() == country}
|
||||||
if len(roomless_by_country.items()) > 0:
|
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)
|
to_add.append(code_to_add)
|
||||||
del roomless_orders[code_to_add]
|
del roomless_orders[code_to_add]
|
||||||
else:
|
else:
|
||||||
# If not, add first roomless there is
|
# 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)
|
to_add.append(code_to_add)
|
||||||
del roomless_orders[code_to_add]
|
del roomless_orders[code_to_add]
|
||||||
result_map[room.code] = {
|
result_map[room.code] = {
|
||||||
|
@ -152,15 +155,33 @@ async def room_wizard(request, order:Order):
|
||||||
'to_add': to_add
|
'to_add': to_add
|
||||||
}
|
}
|
||||||
# Create additional rooms
|
# 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')
|
tpl = request.app.ctx.tpl.get_template('wizard.html')
|
||||||
for order in incomplete_orders.values():
|
return html(tpl.render(order=order, orders=orders, data=result_map))
|
||||||
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')
|
|
||||||
|
|
||||||
@bp.get('/propic/remind')
|
@bp.get('/propic/remind')
|
||||||
async def propic_remind_missing(request, order:Order):
|
async def propic_remind_missing(request, order:Order):
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<div aria-hidden="true" class="propic-border-animation"></div>
|
<div aria-hidden="true" class="propic-border-animation"></div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% 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}}">
|
<a class="control-login-as" href="/manage/admin/loginas/{{order.code}}">
|
||||||
{% endif %}
|
{% 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'}}"/>
|
<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'}}"/>
|
||||||
|
|
|
@ -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 %}
|
Loading…
Reference in New Issue