Skip to content

Commit

Permalink
Add email field to register form
Browse files Browse the repository at this point in the history
  • Loading branch information
vidya-ram committed Oct 27, 2023
1 parent b6df4d5 commit 1fb74a1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions funnel/forms/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
nullable_strip_filters,
validate_and_convert_json,
video_url_list_validator,
strip_filters,
)

__all__ = [
Expand Down Expand Up @@ -369,6 +370,18 @@ class ProjectRegisterForm(forms.Form):
filters=nullable_json_filters,
validators=[validate_and_convert_json],
)
rsvp_email = forms.EmailField(
__("Email address"),
validators=[
forms.validators.DataRequired(),
],
filters=strip_filters,
render_kw={
'autocorrect': 'off',
'autocapitalize': 'off',
'autocomplete': 'email',
},
)

def validate_form(self, field: forms.Field) -> None:
if self.form.data and not self.schema:
Expand Down
5 changes: 5 additions & 0 deletions funnel/forms/sync_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ class ProjectBoxofficeForm(forms.Form):
__("Tickets on this project represent memberships to the account"),
default=False,
)
form_helper_txt = forms.StringField(
__("Form helper text"),
filters=[forms.filters.strip()],
description=__(""),
)
register_button_txt = forms.StringField(
__("Register button text"),
filters=[forms.filters.strip()],
Expand Down
8 changes: 8 additions & 0 deletions funnel/templates/rsvp_modal.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
<div id="register-form">
<json-form :jsonschema="jsonSchema" :formid="'rsvp-form'" @handle-submit-response="handleAjaxPost"></json-form>
</div>
<div class="mui-textfield mui-textfield--float-label">
<input id="rsvp-email" type="text" name="rsvp_email" value="{{ current_auth.user.email }}" />
<label for="rsvp-email">Email</label>
<p class="mui-form__helptext"></p>
</div>
{%- if form_helper_txt %}
<p class="mui--text-body2 top-padding zero-bottom-margin">{{ form_helper_txt }}</p>
{% endif %}
<p class="mui--text-body2 top-padding zero-bottom-margin">{% trans %}This will share your name and email address or phone number with the project’s promoter so they can keep you updated. You can cancel your registration at any time{% endtrans %}</p>
<div class="mui--text-right">
<button class="mui-btn mui-btn--raised" type="submit" name="submit" value="yes" data-cy="confirm">{% trans %}Confirm{% endtrans %}</button>
Expand Down
4 changes: 4 additions & 0 deletions funnel/views/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ def edit_boxoffice_data(self) -> ReturnView:
register_form_schema=boxoffice_data.get('register_form_schema'),
register_button_txt=boxoffice_data.get('register_button_txt', ''),
has_membership=boxoffice_data.get('has_membership', False),
form_helper_txt=boxoffice_data.get('form_helper_txt'),
),
model=Project,
)
Expand All @@ -602,6 +603,7 @@ def edit_boxoffice_data(self) -> ReturnView:
'register_button_txt'
] = form.register_button_txt.data
self.obj.boxoffice_data['has_membership'] = form.has_membership.data
self.obj.boxoffice_data['form_helper_txt'] = form.form_helper_txt.data
db.session.commit()
flash(_("Your changes have been saved"), 'info')
return render_redirect(self.obj.url_for())
Expand Down Expand Up @@ -668,6 +670,7 @@ def rsvp_modal(self) -> ReturnRenderWith:
'project': self.obj.current_access(datasets=('primary',)),
'form': form,
'json_schema': self.obj.boxoffice_data.get('register_form_schema'),
'form_helper_txt': self.obj.boxoffice_data.get('form_helper_txt'),
}

@route('register', methods=['POST'])
Expand All @@ -687,6 +690,7 @@ def register(self) -> ReturnView:
schema=self.obj.boxoffice_data.get('register_form_schema', {}),
)
if rsvp_form.validate_on_submit():
print(rsvp_form.form.data)
rsvp = Rsvp.get_for(self.obj, current_auth.user, create=True)
new_registration = not rsvp.state.YES
rsvp.rsvp_yes()
Expand Down

0 comments on commit 1fb74a1

Please sign in to comment.