Implement template-switching.

Point testing subdomain to port 1111.
Fix busted <div>
This commit is contained in:
Sage Vaillancourt 2022-09-28 00:39:44 +00:00
parent 4ce13cad00
commit 1b32206a23
4 changed files with 26 additions and 9 deletions

View File

@ -1,3 +1,7 @@
undercover.cafe testing.undercover.cafe {
reverse_proxy :1111
}
reverse_proxy :8080 undercover.cafe {
reverse_proxy :8080
}

View File

@ -63,9 +63,9 @@ class CLForm(Form):
"My name is {\\username}. I'm excited for the opportunity to work as " "My name is {\\username}. I'm excited for the opportunity to work as "
"{\\jobAndPronoun} with your company. I think my {\\skillTypes} knowledge " "{\\jobAndPronoun} with your company. I think my {\\skillTypes} knowledge "
"of {\\mySkills} could contribute well to your team.\n\n" "of {\\mySkills} could contribute well to your team.\n\n"
"I am passionate about what I do, and I think we would work well together.\n\n" "I am passionate about what I do, and I think we would work well together.\n\n"
"Thank you for your consideration." "Thank you for your consideration."
) )
) )
@ -116,11 +116,22 @@ def index_get():
if len(letters) > 0: if len(letters) > 0:
letter_names = [(i + 1, letter.title) for i, letter in enumerate(letters)] letter_names = [(i + 1, letter.title) for i, letter in enumerate(letters)]
form.letterName.choices = letter_names form.letterName.choices = letter_names
# TODO: Load this data more dynamically
# I.e. use a dictionary instead of explicitly-defined fields
data = json.loads(letters[0].contents)
form.letterName.data = 1 form.letterName.data = 1
selected_letter = request.args.get('letter_name')
if selected_letter:
for i, letter in enumerate(letters):
if letter.title == selected_letter:
form.letterName.data = i + 1
break
# TODO: Load this data more dynamically
# I.e. use a dictionary instead of explicitly-defined fields
data = json.loads(letters[form.letterName.data - 1].contents)
# Ensures default value is set
form.letterName.process_data(form.letterName.data)
form.company.data = data['company'] form.company.data = data['company']
form.body.data = data['body'] form.body.data = data['body']
form.closingText.data = data['closingText'] form.closingText.data = data['closingText']
@ -254,3 +265,4 @@ def generate_pdf():
return resp return resp
return render_index(form=form) return render_index(form=form)

View File

@ -19,10 +19,11 @@
{{ error }} {{ error }}
</div> </div>
{% endif %} {% endif %}
<div <div>
{% block content %} {% block content %}
{{ content }} {{ content }}
{% endblock content %} {% endblock content %}
</div>
</body> </body>
</html> </html>

View File

@ -62,7 +62,7 @@
<form method=post id="letter-form"> <form method=post id="letter-form">
<dl> <dl>
{% if username %} {% if username %}
{{ render_field(form.letterName) }} {{ render_field(form.letterName, onchange="window.location = '/?letter_name=' + this.options[this.value - 1].label") }}
{% endif %} {% endif %}
{{ render_field(form.username) }} {{ render_field(form.username) }}
{{ render_field(form.company) }} {{ render_field(form.company) }}