Added remind propic feature for admins

This commit is contained in:
Stranck 2024-02-29 11:41:49 +01:00
parent 5b66a58399
commit c6bc9c65ac
5 changed files with 83 additions and 31 deletions

View File

@ -1,4 +1,5 @@
from sanic import response, redirect, Blueprint, exceptions from sanic import response, redirect, Blueprint, exceptions
from email_util import send_missing_propic_message
from room import unconfirm_room_by_order from room import unconfirm_room_by_order
from config import * from config import *
from utils import * from utils import *
@ -82,4 +83,19 @@ async def rename_room(request, code, order:Order):
await dOrder.edit_answer("room_name", name) await dOrder.edit_answer("room_name", name)
await dOrder.send_answers() await dOrder.send_answers()
return redirect(f'/manage/nosecount') return redirect(f'/manage/nosecount')
@bp.get('/propic/remind')
async def propic_remind_missing(request, order:Order):
await clear_cache(request, order)
orders = request.app.ctx.om.cache.values()
order: Order
for order in orders:
missingPropic = order.propic is None
missingFursuitPropic = order.is_fursuiter and order.propic_fursuiter is None
if(missingPropic or missingFursuitPropic):
# print(f"{order.code}: prp={missingPropic} fpr={missingFursuitPropic} - {order.name}")
await send_missing_propic_message(order, missingPropic, missingFursuitPropic)
return redirect(f'/manage/admin')

View File

@ -54,6 +54,13 @@ async def sendEmail(message : MIMEMultipart):
smptSender.sendmail(message['From'], message['to'], message.as_string()) smptSender.sendmail(message['From'], message['to'], message.as_string())
sslLock.release() sslLock.release()
def render_email_template(title = "", body = ""):
tpl = Environment(loader=FileSystemLoader("tpl"), autoescape=False).get_template('email/comunication.html')
return str(tpl.render(title=title, body=body))
async def send_unconfirm_message(room_order, orders): async def send_unconfirm_message(room_order, orders):
memberMessages = [] memberMessages = []
@ -72,8 +79,8 @@ async def send_unconfirm_message(room_order, orders):
issues_html += "</ul>" issues_html += "</ul>"
for member in orders: for member in orders:
plain_body = 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(ROOM_UNCONFIRM_TITLE, 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")
html_text = MIMEText(html_body, "html") html_text = MIMEText(html_body, "html")
message = MIMEMultipart("alternative") message = MIMEMultipart("alternative")
@ -89,6 +96,22 @@ async def send_unconfirm_message(room_order, orders):
for message in memberMessages: for message in memberMessages:
await sendEmail(message) await sendEmail(message)
def render_email_template(title = "", body = ""): async def send_missing_propic_message(order, missingPropic, missingFursuitPropic):
tpl = Environment(loader=FileSystemLoader("tpl"), autoescape=False).get_template('email/comunication.html') t = []
return str(tpl.render(title=title, body=body)) if(missingPropic): t.append("your propic")
if(missingFursuitPropic): t.append("your fursuit's badge")
missingText = " and ".join(t)
plain_body = EMAILS_TEXT["MISSING_PROPIC_TEXT"]['plain'].format(order.name, missingText)
html_body = render_email_template(EMAILS_TEXT["MISSING_PROPIC_TITLE"], EMAILS_TEXT["MISSING_PROPIC_TEXT"]['html'].format(order.name, missingText))
plain_text = MIMEText(plain_body, "plain")
html_text = MIMEText(html_body, "html")
message = MIMEMultipart("alternative")
message.attach(plain_text)
message.attach(html_text)
message['Subject'] = f"[{EMAIL_SENDER_NAME}] You haven't uploaded your badges yet!"
message['From'] = f'{EMAIL_SENDER_NAME} <{EMAIL_SENDER_MAIL}>'
message['To'] = f"{order.name} <{order.email}>"
await sendEmail(message)

View File

@ -1,30 +1,42 @@
ROOM_ERROR_TYPES = { ROOM_ERROR_TYPES = {
'room_id_mismatch': "There's a member in your room that is actually in another room, too. Please contact us as soon as possible in order to fix this issue.", 'room_id_mismatch': "There's a member in your room that is actually in another room, too. Please contact us as soon as possible in order to fix this issue.",
'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."
} }
ROOM_UNCONFIRM_TITLE = "Your room got unconfirmed" EMAILS_TEXT = {
ROOM_UNCONFIRM_TEXT = { "ROOM_UNCONFIRM_TITLE": "Your room got unconfirmed",
'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>", "ROOM_UNCONFIRM_TEXT": {
'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" '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 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"
},
"MISSING_PROPIC_TITLE": "You haven't uploaded your badges yet!",
"MISSING_PROPIC_TEXT": {
'html': "Hello <b>{0}</b><br>We noticed you still have to <b>upload {1}</b>!<br>Please enter your booking page at <a href=\"https://reg.furizon.net/manage/welcome\"> https://reg.furizon.net/manage/welcome</a> and <b>upload them</b> under the <i>\"Badge Customization\"</i> section.<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 noticed you still have to upload {1}!\nPlease enter your booking page at https://reg.furizon.net/manage/welcome and upload them under the \"Badge Customization\" section.\nThank you."
},
} }
NOSECOUNT = { NOSECOUNT = {
'filters': { 'filters': {
'capacity': "Here are some furs that share your room type and don't have a confirmed room." 'capacity': "Here are some furs that share your room type and don't have a confirmed room."
} }
} }
LOCALES = { LOCALES = {
'shuttle_link': { 'shuttle_link': {
'en': 'Book now', 'en': 'Book now',
'it': 'Prenota ora' 'it': 'Prenota ora'
}, },
'shuttle_link_url': { 'shuttle_link_url': {
'en': 'https://visitfiemme.regiondo.com/furizon?_ga=2.129644046.307369854.1705325023-235291123.1705325023', 'en': 'https://visitfiemme.regiondo.com/furizon?_ga=2.129644046.307369854.1705325023-235291123.1705325023',
'it': 'https://experience.visitfiemme.it/furizon' 'it': 'https://experience.visitfiemme.it/furizon'
} }
} }

View File

@ -9,10 +9,11 @@
</picture> </picture>
</header> </header>
<!-- Quick controls --> <!-- Quick controls -->
<h2>Admin panel</h2> <h2>Admin panel</h2>
<a href="/manage/admin/cache/clear" role="button" title="Reload the orders' data and the re-sync items' indexes from pretix">Clear cache</a> <a href="/manage/admin/cache/clear" role="button" title="Reload the orders' data and the re-sync items' indexes from pretix">Clear cache</a>
<a href="/manage/nosecount" role="button" title="Shortcut to the nosecount's admin data">Manage rooms</a> <a href="/manage/nosecount" role="button" title="Shortcut to the nosecount's admin data">Manage rooms</a>
<a href="/manage/admin/room/verify" role="button" title="Will unconfirm rooms that fail the default check. Useful when editing answers from Pretix">Verify Rooms</a> <a href="/manage/admin/room/verify" role="button" title="Will unconfirm rooms that fail the default check. Useful when editing answers from Pretix">Verify Rooms</a>
<a href="/manage/admin/propic/remind" role="button" title="Will remind via mail all people who event uploaded a badge to do it">Remind badge upload</a>
<hr> <hr>
</main> </main>

View File

@ -151,7 +151,7 @@ async def get_people_in_room_by_code(request, code, om=None):
await om.update_cache() await om.update_cache()
return filter(lambda rm: rm.room_id == code, om.cache.values()) return filter(lambda rm: rm.room_id == code, om.cache.values())
async def unconfirm_room_by_order(order, room_members:[]=None, throw=True, request=None, om=None): async def unconfirm_room_by_order(order, room_members=None, throw=True, request=None, om=None):
if not om: om = request.app.ctx.om if not om: om = request.app.ctx.om
if not order.room_confirmed: if not order.room_confirmed:
if throw: if throw:
@ -216,7 +216,7 @@ async def validate_rooms(request, rooms, om):
order = rtu[0] order = rtu[0]
member_orders = rtu[2] member_orders = rtu[2]
try: try:
await send_unconfirm_message (order, member_orders) await send_unconfirm_message(order, member_orders)
sent_count += len(member_orders) sent_count += len(member_orders)
except Exception as ex: except Exception as ex:
if EXTRA_PRINTS: logger.exception(str(ex)) if EXTRA_PRINTS: logger.exception(str(ex))