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

Create system to invite speakers to the CfP #1349

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions apps/cfp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def edit_proposal(proposal_id):
del form.email

if form.validate_on_submit():
if proposal.state not in ["new", "edit"]:
if proposal.state not in ["new", "edit", "manual-review"]:
flash("This submission can no longer be edited.")
return redirect(url_for(".proposals"))

Expand Down Expand Up @@ -462,7 +462,7 @@ def edit_proposal(proposal_id):

return redirect(url_for(".edit_proposal", proposal_id=proposal_id))

if request.method != "POST" and proposal.state in ["new", "edit"]:
if request.method != "POST" and proposal.state in ["new", "edit", "manual-review"]:
if proposal.type in ("talk", "performance"):
form.length.data = proposal.length

Expand Down
45 changes: 45 additions & 0 deletions apps/cfp_review/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@
Proposal,
ROUGH_LENGTHS,
Venue,
PYTHON_CFP_TYPES,
)
from models.cfp_tag import Tag
from models.user import User
from models.purchase import Ticket
from .forms import (
CFPInviteForm,
UpdateTalkForm,
UpdatePerformanceForm,
UpdateWorkshopForm,
Expand Down Expand Up @@ -1232,4 +1234,47 @@ def proposals_summary():
)


@cfp_review.route("/invite-speaker", methods=["GET", "POST"])
@admin_required
def invite_speaker():
form = CFPInviteForm()

if form.validate_on_submit():
if form.add.data:
email, name = form.email.data, form.name.data
user = User(email, name)
db.session.add(user)

proposal = PYTHON_CFP_TYPES[form.proposal_type.data](
title=form.title.data,
description=form.description.data,
user=user,
state="manual-review",
)

db.session.add(proposal)
db.session.commit()

code = user.login_code(app.config["SECRET_KEY"])
msg = EmailMessage(
f"You've been invited to submit a {proposal.human_type} to EMF",
from_email=from_email("CONTENT_EMAIL"),
to=[email],
)
msg.body = render_template(
"emails/invited-speaker.txt", user=user, code=code, proposal=proposal
)
msg.send()

app.logger.info(f"Created new user, {user} & proposal {proposal}")

flash(
f"Created new user, {user.name}, they have been emailed an invite link. "
)

return redirect(url_for(".invite_speaker"))

return render_template("cfp_review/invite-speaker.html", form=form)


from . import venues # noqa
12 changes: 11 additions & 1 deletion apps/cfp_review/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
)
from wtforms.validators import DataRequired, Optional, NumberRange, ValidationError

from models.cfp import Venue, ORDERED_STATES
from models.cfp import HUMAN_CFP_TYPES, Venue, ORDERED_STATES
from models.cfp_tag import Tag
from ..common.forms import Form, HiddenIntegerField, EmailField
from ..admin.users import NewUserForm

from dateutil.parser import parse as parse_date

Expand Down Expand Up @@ -410,3 +411,12 @@ class ReversionForm(Form):
proposal_id = HiddenIntegerField("Proposal ID")
txn_id = HiddenIntegerField("Transaction ID")
revert = SubmitField("Revert to this version")


class CFPInviteForm(NewUserForm):
proposal_type = SelectField(
"Proposal Type",
choices=[tuple(i) for i in HUMAN_CFP_TYPES.items() if i[0] != "lightning"],
)
title = StringField("Title", default="[How should this appear in the schedule?]")
description = StringField("Description", default="[A more detailed description]")
2 changes: 2 additions & 0 deletions templates/cfp_review/_nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
<li role="separator" class="divider"></li>
{{ menuitem('Anonymisation', '.anonymisation', proposal_counts['checked']) }}
{{ menuitem('Review', '.review_list') }}
<li role="separator" class="divider"></li>
{{ menuitem('Invite Speaker', '.invite_speaker') }}
</ul>
</li>
{% endif %}
Expand Down
13 changes: 13 additions & 0 deletions templates/cfp_review/invite-speaker.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% from "_formhelpers.html" import render_dl_field %}
{% extends "cfp_review/base.html" %}
{% block body %}
<form method="POST" class="form">
{{ form.hidden_tag() }}
{{ render_dl_field(form.name) }}
{{ render_dl_field(form.email) }}
{{ render_dl_field(form.proposal_type) }}
{{ render_dl_field(form.title) }}
{{ render_dl_field(form.description) }}
{{ form.add(class_="btn btn-primary debounce") }}
</form>
{% endblock %}
18 changes: 18 additions & 0 deletions templates/emails/invited-speaker.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% extends "emails/base.txt" %}
{% block body %}
Hi {{ user.name }},

This is to let you know that you now have an account on our website for Electromagnetic Field {{ event_year }}!

You can log into this account by visiting:

{{ external_url('users.login', code=code, next=url_for('cfp.edit_proposal', proposal_id=proposal.id)) }}

Once you've logged in please fill in the details for your {{proposal.human_type}}.

If you think you've been added in error or you have any problems, please let us know by replying to this email.

Love,

All the EMF team
{% endblock %}
Loading