Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volunteer list #1300

Merged
merged 3 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def main():
def main_post():
honeypot_field = request.form.get("name")
email = request.form.get("email", "").strip()
list = request.form.get("list")

if request.form.get("list") not in app.config["LISTMONK_LISTS"]:
return raise_404()

if email == "":
return redirect(url_for(".main"))
Expand All @@ -68,7 +72,7 @@ def main_post():

response = requests.post(
app.config["LISTMONK_URL"] + "/api/public/subscription",
json={"email": email, "list_uuids": [app.config["LISTMONK_LIST_ID"]]},
json={"email": email, "list_uuids": [app.config["LISTMONK_LISTS"][list]]},
)

if response.status_code != 200:
Expand Down
16 changes: 14 additions & 2 deletions apps/base/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
although some legacy content remains here.
"""

from flask import abort, current_app as app, redirect, render_template, url_for
from flask import (
abort,
current_app as app,
redirect,
render_template,
render_template_string,
url_for,
)
from markdown import markdown
from os import path
from pathlib import Path
Expand Down Expand Up @@ -33,7 +40,12 @@ def render_markdown(source, **view_variables):
source = f.read()
(metadata, content) = source.split("---", 2)
metadata = parse_yaml(metadata)
content = Markup(markdown(content, extensions=["markdown.extensions.nl2br"]))
content = Markup(
markdown(
render_template_string(content),
extensions=["markdown.extensions.nl2br"],
)
)

view_variables.update(content=content, title=metadata["title"])
return render_template(page_template(metadata), **view_variables)
Expand Down
14 changes: 13 additions & 1 deletion apps/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pendulum

from main import db, external_url
from flask import session, abort, current_app as app
from flask import session, abort, current_app as app, render_template
from markupsafe import Markup
from flask.json import jsonify
from flask_login import login_user, current_user
Expand Down Expand Up @@ -145,6 +145,18 @@ def pretty_text(text):
text = "\n".join(f"<p>{para}</p>" for para in re.split(r"[\r\n]+", text))
return Markup(text)

@app_obj.context_processor
def contact_form_processor():
def contact_form(list):
"""Renders a contact form for the requested list."""
if list not in app_obj.config["LISTMONK_LISTS"]:
msg = f"The list '{list}' is not configured. Add it to your config file under LISTMONK_LISTS."
raise ValueError(msg)

return Markup(render_template("home/_mailing_list_form.html", list=list))

return {"contact_form": contact_form}


def create_current_user(email: str, name: str):
user = User(email, name)
Expand Down
5 changes: 4 additions & 1 deletion config/development-example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ TRANSFERWISE_ENVIRONMENT = "sandbox"
TRANSFERWISE_API_TOKEN = ""

LISTMONK_URL = "https://broadcast.emfcamp.org"
LISTMONK_LIST_ID = "e4f02d85-5f8f-458f-9f83-051edf25bfb0"
LISTMONK_LISTS = {
"main": "e4f02d85-5f8f-458f-9f83-051edf25bfb0",
"volunteer": "ee88b1a2-a9da-4235-9223-7e537a3a44cc"
}

MAIL_SERVER = "localhost"
MAIL_BACKEND = "console"
Expand Down
2 changes: 1 addition & 1 deletion templates/about/contact.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h3>Get Updates</h3>

<p>If you're interested in updates about EMF, follow us on
<a href="https://social.emfcamp.org/@emf">the Fediverse</a> or join our mailing list:</p>
{% include "home/_mailing_list_form.html" %}
{{ contact_form("main")}}

<h3>Community</h3>

Expand Down
5 changes: 5 additions & 0 deletions templates/about/volunteering.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ Running an event like EMF requires a huge amount of planning to make sure the ev

**We're looking for people to help organise the event**. If this is something that interests you [take a look at the list of roles we're looking to fill](/about/volunteer-roles).

We also have a mailing list where we periodically post about volunteer roles, to
subscribe fill out the form below:

{{ contact_form("volunteer") }}

## Helping out during the event

During the event, there are plenty of roles which need to be filled, from construction to cooking for volunteers.
Expand Down
5 changes: 4 additions & 1 deletion templates/home/_mailing_list_form.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<form method="post" class="form-inline" role="form" action="{{url_for('base.main')}}" id="mailing-list-form">
<input id="list" name="list" type="hidden" value="{{ list }}"/>
<div class="input-group">
<input id="email-field" type="email" class="form-control" placeholder="Enter email address" name="email"/>
{# This is a honeypot field to prevent bots signing up, it's hidden by CSS #}
Expand All @@ -8,4 +9,6 @@
</span>
</div>
</form>
<p><small>(We'll only use your details to contact you about future events.)</small></p>
{% if list == "main" %}
<p><small>(We'll only use your details to contact you about future events.)</small></p>
{% endif %}
2 changes: 1 addition & 1 deletion templates/home/before-sales.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
us on <a href="https://social.emfcamp.org/@emf">the Fediverse</a> or join our
mailing list:
</p>
{% include "home/_mailing_list_form.html" %}
{{contact_form("main")}}
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/home/cancelled-time-machine.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<a href="https://www.twitter.com/emfcamp">Twitter</a> or join our
mailing list:
</p>
{% include "home/_mailing_list_form.html" %}
{{contact_form("main")}}
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/home/cancelled.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<a href="https://www.twitter.com/emfcamp">Twitter</a> or join our
mailing list:
</p>
{% include "home/_mailing_list_form.html" %}
{{contact_form("main")}}
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/home/sales_block.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<a href="https://social.emfcamp.org/@emf">the Fediverse</a> or join our
mailing list for more updates:
</p>
{% include "home/_mailing_list_form.html" %}
{{contact_form("main")}}

{% elif SALES_STATE == 'sold-out' %}
<p>We&rsquo;re sorry to say EMF is sold out!
Expand Down
2 changes: 1 addition & 1 deletion templates/purchase/speakers.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</p>
<p>Please follow us <a href="https://social.emfcamp.org/@emf">the Fediverse</a> or
join our mailing list to be notified when more tickets are on sale:</p>
{% include "home/_mailing_list_form.html" %}
{{contact_form("main")}}
<p>We can't reserve any tickets, but if we accept your
{% if config['CFP'] %}
<a href="{{url_for('cfp.main')}}">talk, workshop, or installation proposal</a>,
Expand Down
2 changes: 1 addition & 1 deletion templates/purchase/tickets.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<p>Please follow us <a href="https://social.emfcamp.org/@emf">the Fediverse</a> or
join our mailing list to be notified when more tickets are on sale:</p>
{% include "home/_mailing_list_form.html" %}
{{contact_form("main")}}

<p>We can't reserve any tickets, but if we accept your
{% if config['CFP'] %}
Expand Down
2 changes: 1 addition & 1 deletion templates/subscribe.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h2>Subscribe to EMF event emails</h2>
<p>If you'd like to be infrequently notified about EMF events, please sign up to our newsletter.</p>

<div class="well">
{% include "home/_mailing_list_form.html" %}
{{contact_form("main")}}
</div>
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion templates/tickets/cutoff.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<p>If you're interested in updates on our next event,
please follow us <a href="https://social.emfcamp.org/@emf">the Fediverse</a> or
join our mailing list:</p>
{% include "home/_mailing_list_form.html" %}
{{contact_form("main")}}
{% endif %}

{% if SALES_STATE != 'sales-ended' %}
Expand Down
Loading