stranck-dev #20

Merged
drew merged 11 commits from stranck-dev into drew-dev 2024-03-02 15:34:56 +00:00
5 changed files with 83 additions and 31 deletions
Showing only changes of commit c6bc9c65ac - Show all commits

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 *
@ -83,3 +84,18 @@ 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

@ -6,12 +6,24 @@ ROOM_ERROR_TYPES = {
'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",
"ROOM_UNCONFIRM_TEXT": {
'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>", '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" '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."

View File

@ -13,6 +13,7 @@
<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: