Compare commits
No commits in common. "1e6b400b2c4b337e16bedd2ddeef7d16e933c57e" and "938bc683833a7ca239997ec97a96a46c13029738" have entirely different histories.
1e6b400b2c
...
938bc68383
2
app.py
2
app.py
|
@ -55,7 +55,7 @@ async def handleException(request, exception):
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
if statusCode == 403:
|
if statusCode == 403:
|
||||||
await clear_session(r)
|
clear_session(r)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,6 @@ async def send_unconfirm_message(room_order, orders):
|
||||||
issues_html += "</ul>"
|
issues_html += "</ul>"
|
||||||
|
|
||||||
for member in orders:
|
for member in orders:
|
||||||
if(member.status != 'canceled'):
|
|
||||||
plain_body = EMAILS_TEXT["ROOM_UNCONFIRM_TEXT"]['plain'].format(member.name, room_order.room_name, issues_plain)
|
plain_body = EMAILS_TEXT["ROOM_UNCONFIRM_TEXT"]['plain'].format(member.name, room_order.room_name, issues_plain)
|
||||||
html_body = render_email_template(EMAILS_TEXT["ROOM_UNCONFIRM_TITLE"], EMAILS_TEXT["ROOM_UNCONFIRM_TEXT"]['html'].format(member.name, room_order.room_name, issues_html))
|
html_body = render_email_template(EMAILS_TEXT["ROOM_UNCONFIRM_TITLE"], EMAILS_TEXT["ROOM_UNCONFIRM_TEXT"]['html'].format(member.name, room_order.room_name, issues_html))
|
||||||
plain_text = MIMEText(plain_body, "plain")
|
plain_text = MIMEText(plain_body, "plain")
|
||||||
|
|
7
ext.py
7
ext.py
|
@ -20,10 +20,6 @@ class Order:
|
||||||
|
|
||||||
self.time = time()
|
self.time = time()
|
||||||
self.data = data
|
self.data = data
|
||||||
if(len(self.data['positions']) == 0):
|
|
||||||
for fee in data['fees']:
|
|
||||||
if(fee['fee_type'] == "cancellation"):
|
|
||||||
self.data['status'] = 'c'
|
|
||||||
self.status = {'n': 'pending', 'p': 'paid', 'e': 'expired', 'c': 'canceled'}[self.data['status']]
|
self.status = {'n': 'pending', 'p': 'paid', 'e': 'expired', 'c': 'canceled'}[self.data['status']]
|
||||||
self.secret = data['secret']
|
self.secret = data['secret']
|
||||||
|
|
||||||
|
@ -223,8 +219,7 @@ class Order:
|
||||||
# del self.answers[i]['options']
|
# del self.answers[i]['options']
|
||||||
# del self.answers[i]['option_identifiers']
|
# del self.answers[i]['option_identifiers']
|
||||||
|
|
||||||
ans = [] if self.status == "canceled" else self.answers
|
res = await pretixClient.patch(f'orderpositions/{self.position_id}/', json={'answers': self.answers}, expectedStatusCodes=None)
|
||||||
res = await pretixClient.patch(f'orderpositions/{self.position_id}/', json={'answers': ans}, expectedStatusCodes=None)
|
|
||||||
|
|
||||||
if res.status_code != 200:
|
if res.status_code != 200:
|
||||||
e = res.json()
|
e = res.json()
|
||||||
|
|
|
@ -3,16 +3,15 @@ ROOM_ERROR_TYPES = {
|
||||||
'unpaid': "Somebody in your room has not paid for their reservation, yet.",
|
'unpaid': "Somebody in your room has not paid for their reservation, yet.",
|
||||||
'type_mismatch': "A member in your room has a ticket for a different type of room capacity. This happens when users swap their room types with others, without abandoning the room.",
|
'type_mismatch': "A member in your room has a ticket for a different type of room capacity. This happens when users swap their room types with others, without abandoning the room.",
|
||||||
'daily': "Some member in your room has a Daily ticket. These tickets do not include a hotel reservation.",
|
'daily': "Some member in your room has a Daily ticket. These tickets do not include a hotel reservation.",
|
||||||
'capacity_mismatch': "The number of people in your room mismatches your type of ticket.",
|
'capacity_mismatch': "The number of people in your room mismatches your type of ticket."
|
||||||
'canceled': "Someone in your room canceled his booking and it was removed from your room."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EMAILS_TEXT = {
|
EMAILS_TEXT = {
|
||||||
"ROOM_UNCONFIRM_TITLE": "Your room got unconfirmed",
|
"ROOM_UNCONFIRM_TITLE": "Your room got unconfirmed",
|
||||||
"ROOM_UNCONFIRM_TEXT": {
|
"ROOM_UNCONFIRM_TEXT": {
|
||||||
'html': "Hello <b>{0}</b><br>We had to <b>unconfirm or change</b> your room <i>'{1}'</i> due to the following issues:<br></p>{2}<br><p>Please contact your room's owner or contact our support for further informations at <a href=\"https://furizon.net/contact/\"> https://furizon.net/contact/</a>.<br>Thank you.<br><br><a class=\"link\" style=\"background-color: #1095c1; color: #fff;\" href=\"https://reg.furizon.net/manage/welcome\">Manage booking</a>",
|
'html': "Hello <b>{0}</b><br>We had to <b>unconfirm</b> your room <i>'{1}'</i> due to the following issues:<br></p>{2}<br><p>Please contact your room's owner or contact our support for further informations at <a href=\"https://furizon.net/contact/\"> https://furizon.net/contact/</a>.<br>Thank you.<br><br><a class=\"link\" style=\"background-color: #1095c1; color: #fff;\" href=\"https://reg.furizon.net/manage/welcome\">Manage booking</a>",
|
||||||
|
|
||||||
'plain': "Hello {0}\nWe had to unconfirm or change your room '{1}' due to the following issues:\n{2}\nPlease contact your room's owner or contact our support for further informations at https://furizon.net/contact/.\nThank you\n\nTo manage your booking: https://reg.furizon.net/manage/welcome"
|
'plain': "Hello {0}\nWe had to unconfirm your room '{1}' due to the following issues:\n{2}\nPlease contact your room's owner or contact our support for further informations at https://furizon.net/contact/.\nThank you\n\nTo manage your booking: https://reg.furizon.net/manage/welcome"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
41
utils.py
41
utils.py
|
@ -164,17 +164,6 @@ async def unconfirm_room_by_order(order, room_members=None, throw=True, request=
|
||||||
await p.edit_answer('room_confirmed', "False")
|
await p.edit_answer('room_confirmed', "False")
|
||||||
await p.send_answers()
|
await p.send_answers()
|
||||||
|
|
||||||
async def remove_members_from_room(order, removeMembers):
|
|
||||||
didSomething = False
|
|
||||||
for member in removeMembers:
|
|
||||||
if (member in order.room_members):
|
|
||||||
order.room_members.remove(member)
|
|
||||||
didSomething = True
|
|
||||||
if(didSomething):
|
|
||||||
await order.edit_answer("room_members", ','.join(order.room_members))
|
|
||||||
await order.send_answers()
|
|
||||||
return didSomething
|
|
||||||
|
|
||||||
async def validate_rooms(request, rooms, om):
|
async def validate_rooms(request, rooms, om):
|
||||||
logger.info('Validating rooms...')
|
logger.info('Validating rooms...')
|
||||||
if not om: om = request.app.ctx.om
|
if not om: om = request.app.ctx.om
|
||||||
|
@ -182,7 +171,6 @@ async def validate_rooms(request, rooms, om):
|
||||||
# rooms_to_unconfirm is the room that MUST be unconfirmed, room_with_errors is a less strict set containing all rooms with kind-ish errors
|
# rooms_to_unconfirm is the room that MUST be unconfirmed, room_with_errors is a less strict set containing all rooms with kind-ish errors
|
||||||
rooms_to_unconfirm = []
|
rooms_to_unconfirm = []
|
||||||
room_with_errors = []
|
room_with_errors = []
|
||||||
remove_members = []
|
|
||||||
|
|
||||||
# Validate rooms
|
# Validate rooms
|
||||||
for order in rooms:
|
for order in rooms:
|
||||||
|
@ -207,12 +195,10 @@ async def validate_rooms(request, rooms, om):
|
||||||
# Get confirmed rooms that fail validation
|
# Get confirmed rooms that fail validation
|
||||||
failed_confirmed_rooms = list(filter(lambda fr: (fr[0].room_confirmed == True), rooms_to_unconfirm))
|
failed_confirmed_rooms = list(filter(lambda fr: (fr[0].room_confirmed == True), rooms_to_unconfirm))
|
||||||
|
|
||||||
didSomething = False
|
|
||||||
|
|
||||||
if len(failed_confirmed_rooms) == 0:
|
if len(failed_confirmed_rooms) == 0:
|
||||||
logger.info('[ROOM VALIDATION] No rooms to unconfirm.')
|
logger.info('[ROOM VALIDATION] No rooms to unconfirm.')
|
||||||
else:
|
return
|
||||||
didSomething = True
|
|
||||||
logger.info(f"[ROOM VALIDATION] Trying to unconfirm {len(failed_confirmed_rooms)} rooms...")
|
logger.info(f"[ROOM VALIDATION] Trying to unconfirm {len(failed_confirmed_rooms)} rooms...")
|
||||||
|
|
||||||
# Try unconfirming them
|
# Try unconfirming them
|
||||||
|
@ -225,18 +211,6 @@ async def validate_rooms(request, rooms, om):
|
||||||
if UNCONFIRM_ROOMS_ENABLE:
|
if UNCONFIRM_ROOMS_ENABLE:
|
||||||
await unconfirm_room_by_order(order, member_orders, False, None, om)
|
await unconfirm_room_by_order(order, member_orders, False, None, om)
|
||||||
|
|
||||||
for r in rooms_to_unconfirm:
|
|
||||||
order = r[0]
|
|
||||||
removeMembers = r[3]
|
|
||||||
if len(removeMembers) > 0:
|
|
||||||
logger.warning(f"[ROOM VALIDATION] [REMOVING] Removing members '{','.join(removeMembers)}' from room {order.code}")
|
|
||||||
|
|
||||||
if UNCONFIRM_ROOMS_ENABLE:
|
|
||||||
didSomething |= await remove_members_from_room(order, removeMembers)
|
|
||||||
if(r not in failed_confirmed_rooms): failed_confirmed_rooms.append(r)
|
|
||||||
|
|
||||||
|
|
||||||
if(didSomething):
|
|
||||||
logger.info(f"[ROOM VALIDATION] Sending unconfirm notice to room members...")
|
logger.info(f"[ROOM VALIDATION] Sending unconfirm notice to room members...")
|
||||||
sent_count = 0
|
sent_count = 0
|
||||||
# Send unconfirm notice via email
|
# Send unconfirm notice via email
|
||||||
|
@ -255,10 +229,9 @@ async def validate_rooms(request, rooms, om):
|
||||||
async def check_room(request, order, om=None):
|
async def check_room(request, order, om=None):
|
||||||
room_errors = []
|
room_errors = []
|
||||||
room_members = []
|
room_members = []
|
||||||
remove_members = []
|
|
||||||
use_cached = request == None
|
use_cached = request == None
|
||||||
if not om: om = request.app.ctx.om
|
if not om: om = request.app.ctx.om
|
||||||
if not order or not order.room_id or order.room_id != order.code: return (order, False, room_members, remove_members)
|
if not order or not order.room_id or order.room_id != order.code: return (order, False, room_members)
|
||||||
|
|
||||||
# This is not needed anymore you buy tickets already
|
# This is not needed anymore you buy tickets already
|
||||||
#if quotas.get_left(len(order.room_members)) == 0:
|
#if quotas.get_left(len(order.room_members)) == 0:
|
||||||
|
@ -277,11 +250,7 @@ async def check_room(request, order, om=None):
|
||||||
room_errors.append((res.code, 'room_id_mismatch'))
|
room_errors.append((res.code, 'room_id_mismatch'))
|
||||||
allOk = False
|
allOk = False
|
||||||
|
|
||||||
if res.status == 'canceled':
|
if res.status != 'paid':
|
||||||
room_errors.append((res.code, 'canceled'))
|
|
||||||
remove_members.append(res.code)
|
|
||||||
allOk = False
|
|
||||||
elif res.status != 'paid':
|
|
||||||
room_errors.append((res.code, 'unpaid'))
|
room_errors.append((res.code, 'unpaid'))
|
||||||
|
|
||||||
if res.bed_in_room != bed_in_room:
|
if res.bed_in_room != bed_in_room:
|
||||||
|
@ -301,4 +270,4 @@ async def check_room(request, order, om=None):
|
||||||
if order.room_confirmed:
|
if order.room_confirmed:
|
||||||
allOk = False
|
allOk = False
|
||||||
order.set_room_errors(room_errors)
|
order.set_room_errors(room_errors)
|
||||||
return (order, allOk, room_members, remove_members)
|
return (order, allOk, room_members)
|
Loading…
Reference in New Issue