UnderCover/undercover/templates/writing.jinja2

111 lines
3.7 KiB
Plaintext
Raw Normal View History

2022-09-23 18:55:45 -04:00
{% extends "base.jinja2" %}
{% from "_formhelpers.jinja2" import render_field, render_label, render_input %}
2022-09-23 18:55:45 -04:00
{% block title %}UnderCover{% endblock %}
2022-09-22 16:23:01 -04:00
2022-09-23 18:55:45 -04:00
{% block head %}
<script type="text/javascript">
2022-09-22 16:23:01 -04:00
window.onload = () => {
{% if letter_errors %}
window.scrollTo(0, document.body.scrollHeight);
{% endif %}
2022-09-22 16:23:01 -04:00
if (window.location.search.includes("reset=true")) {
2022-09-22 16:27:47 -04:00
window.history.pushState({}, document.title, window.location.pathname);
return;
}
2022-09-22 16:23:01 -04:00
decodeURIComponent(document.cookie).split(';').forEach(cookie => {
[id, value] = cookie.trim().split('=')
2022-09-23 09:22:27 -04:00
if (!id || !value) {
return
}
const e = document.getElementById(id)
if (e) {
e.value = value
}
})
}
2022-09-22 16:23:01 -04:00
const clearErrors = () => {
const e = document.getElementById('letter_errors')
2022-09-22 16:27:47 -04:00
e.parentNode.removeChild(e)
2022-09-22 16:23:01 -04:00
}
</script>
2022-09-23 18:55:45 -04:00
{% endblock head %}
2022-09-23 18:55:45 -04:00
{% block content %}
2022-09-23 14:14:06 -04:00
{% if username %}
<div class="user logged-in">
2022-09-24 08:47:33 -04:00
<p style="margin: 0 1em 0 0;">{{ username }}</p>
<form action="/logout">
<input class="black-white-button" style="margin: 0; padding: 0.4em;" type="submit" value="Logout">
</form>
</div>
{% else %}
<div class="user logged-out">
2022-09-24 08:47:33 -04:00
<p>You are working as a <strong>Guest</strong>.</p>
2022-09-23 15:14:24 -04:00
<form action="/login" method="post">
2022-09-24 08:47:33 -04:00
<div>
<input id="login" maxlength="32" minlength="4" name="login" type="text" placeholder="email">
<input id="password" maxlength="32" minlength="4" name="password" type="password" placeholder="password">
</div>
2022-09-24 08:47:33 -04:00
<div>
<input class="black-white-button" type="submit" value="Create Account" formaction="/create_account">
<input class="black-white-button" type="submit" value="Forgot Password" formaction="/reset">
2022-09-24 08:47:33 -04:00
<input class="white-black-button login-button" type="submit" value="Login">
</div>
</form>
</div>
2022-09-23 14:14:06 -04:00
{% endif %}
2022-09-22 16:23:01 -04:00
2022-09-23 09:22:27 -04:00
<form method=post id="letter-form">
<dl>
{% if username %}
<div class="field">
{{ render_label(form.letterName) }}
<div style="display: flex; flex-direction: row;">
{{ render_input(
form.letterName,
onchange="window.location = '/?letter_name=' + this.options[this.value - 1].label"
)
}}
<a href="/add_letter" class="black-white-button" style="aspect-ratio: 1 / 1; text-decoration: none; margin-left: 1em; text-align: center;">+</a>
</div>
</div>
{% endif %}
{{ render_field(form.username) }}
{{ render_field(form.company) }}
{{ render_field(form.jobAndPronoun) }}
{{ render_field(form.skillTypes) }}
{{ render_field(form.mySkills) }}
{{ render_field(form.body, 'class=bigtext') }}
{{ render_field(form.closingText) }}
</dl>
2022-09-22 16:23:01 -04:00
{% if letter_errors %}
<div id=letter_errors>
2022-09-22 16:23:01 -04:00
<h3>Your letter has errors.</h3>
<p>
There is likely a typo in one of your variables (the {\blabla} bits).<br>
Make sure each is spelled correctly, and has the correct brackets on either side
</p>
<p class=letter_errors>
{% for error in letter_errors %}
2022-09-22 16:23:01 -04:00
{{ error }}<br>
{% endfor %}
</p>
</div>
{% endif %}
2022-09-22 16:23:01 -04:00
2022-09-23 09:22:27 -04:00
<a href="javascript:void(0)"
class="wipe up-wipe"
{% if letter_errors %}
2022-09-23 09:22:27 -04:00
onclick="clearErrors();document.getElementById('letter-form').submit()"
{% else %}
onclick="document.getElementById('letter-form').submit()"
2022-09-22 16:23:01 -04:00
{% endif %}
2022-09-23 09:22:27 -04:00
>Generate PDF</a>
</form>
2022-09-23 18:55:45 -04:00
{% endblock content %}