Skip to content

Commit

Permalink
Make emails optional when creating events/groups
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Kabo committed Jan 17, 2022
1 parent 1873af0 commit 4ef3273
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
10 changes: 4 additions & 6 deletions routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ router.post('/newevent', async (req, res) => {
.then((event) => {
addToLog("createEvent", "success", "Event " + eventID + "created");
// Send email with edit link
if (sendEmails) {
if (req.body.creatorEmail && sendEmails) {
req.app.get('hbsInstance').renderView('./views/emails/createevent.handlebars', { eventID, editToken, siteName, siteLogo, domain, cache: true, layout: 'email.handlebars' }, function (err, html) {
const msg = {
to: req.body.creatorEmail,
Expand Down Expand Up @@ -736,11 +736,9 @@ router.post('/importevent', (req, res) => {

let creatorEmail;
if (req.body.creatorEmail) {
creatorEmail = req.body.creatorEmail
creatorEmail = req.body.creatorEmail;
} else if (importedEventData.organizer) {
creatorEmail = importedEventData.organizer.val.replace("MAILTO:", "");
} else {
res.status(500).send("Please supply an email address on the previous page.");
}

const event = new Event({
Expand Down Expand Up @@ -768,7 +766,7 @@ router.post('/importevent', (req, res) => {
.then(() => {
addToLog("createEvent", "success", "Event " + eventID + " created");
// Send email with edit link
if (sendEmails) {
if (creatorEmail && sendEmails) {
req.app.get('hbsInstance').renderView('./views/emails/createevent.handlebars', { eventID, editToken, siteName, siteLogo, domain, cache: true, layout: 'email.handlebars' }, function (err, html) {
const msg = {
to: req.body.creatorEmail,
Expand Down Expand Up @@ -839,7 +837,7 @@ router.post('/neweventgroup', (req, res) => {
.then(() => {
addToLog("createEventGroup", "success", "Event group " + eventGroupID + " created");
// Send email with edit link
if (sendEmails) {
if (req.body.creatorEmail && sendEmails) {
req.app.get('hbsInstance').renderView('./views/emails/createeventgroup.handlebars', { eventGroupID, editToken, siteName, siteLogo, domain, cache: true, layout: 'email.handlebars' }, function (err, html) {
const msg = {
to: req.body.creatorEmail,
Expand Down
12 changes: 5 additions & 7 deletions views/event.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
Welcome to your event! We've just sent you an email with your secret editing link, which you can also see in the address bar above. Haven't got the email? Check your spam or junk folder. To share your event, use the link you can see just above this message - that way your attendees won't be able to edit or delete your event!
<p>Welcome to your event!</p>
<p>Your secret editing password for this event is: <strong>{{eventData.editToken}}</strong>. It's been saved in your browser storage, and if you supplied your email, it's also been sent to you. If you didn't supply your email, you <strong>must save it somewhere safe</strong>, because it won't be shown again!</p>
<p>To share your event, use the link you can see just above this message - that way your attendees won't be able to edit or delete your event!</p>
</div>
{{/if}}
<div class="card mb-4" id="eventDescription">
Expand Down Expand Up @@ -507,12 +509,8 @@
$("#image-preview").css("background-image", "url('/events/{{eventData.image}}')");
$("#image-preview").css("background-size", "cover");
$("#image-preview").css("background-position", "center center");
{{#if editingEnabled}}
{{#unless eventHasConcluded}}
$('#eventStart').datepicker().data('datepicker').selectDate(moment('{{parsedStart}}', 'YYYYMMDD[T]HHmmss').toDate());
$('#eventEnd').datepicker().data('datepicker').selectDate(moment('{{parsedEnd}}', 'YYYYMMDD[T]HHmmss').toDate());
{{/unless}}
{{/if}}
$('#eventStart').datepicker().data('datepicker').selectDate(moment('{{parsedStart}}', 'YYYYMMDD[T]HHmmss').toDate());
$('#eventEnd').datepicker().data('datepicker').selectDate(moment('{{parsedEnd}}', 'YYYYMMDD[T]HHmmss').toDate());
new ClipboardJS('#copyEventLink');
autosize($('textarea'));
$("#exportICS").click(function(){
Expand Down
6 changes: 3 additions & 3 deletions views/newevent.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
<div class="container mb-4">
<div class="row">
<div class="col-sm-4 p-2">
<button type="button" id="showNewEventFormButton" class="btn btn-lg btn-secondary w-100"><i class="fas fa-file"></i> Create a new event</button>
<button type="button" id="showNewEventFormButton" class="btn btn-secondary w-100"><i class="fas fa-file"></i> Create a new event</button>
</div>
<div class="col-sm-4 p-2">
<button type="button" id="showImportEventFormButton" class="btn btn-lg btn-secondary w-100"><i class="fas fa-file-import"></i> Import an existing event</button>
<button type="button" id="showImportEventFormButton" class="btn btn-secondary w-100"><i class="fas fa-file-import"></i> Import an existing event</button>
</div>
<div class="col-sm-4 p-2">
<button type="button" id="showNewEventGroupFormButton" class="btn btn-lg btn-secondary w-100"><i class="fas fa-folder-open"></i> Create a new event group </button>
<button type="button" id="showNewEventGroupFormButton" class="btn btn-secondary w-100"><i class="fas fa-folder-open"></i> Create a new event group </button>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions views/partials/neweventform.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
<div class="form-group row">
<label for="creatorEmail" class="col-sm-2 col-form-label">Your email</label>
<div class="form-group col-sm-10">
<input type="email" class="form-control" id="creatorEmail" name="creatorEmail" placeholder="We won't spam you <3" data-validation="email required">
<small class="form-text">We will send your secret editing link to this email address.</small>
<input type="email" class="form-control" id="creatorEmail" name="creatorEmail" placeholder="We won't spam you <3 (optional)" data-validation="email" data-validation-optional="true">
<small class="form-text">If you provide your email, we will send your secret editing password here, and use it to notify you of updates to the event.</small>
</div>
</div>
<div class="form-group row">
Expand Down
4 changes: 2 additions & 2 deletions views/partials/neweventgroupform.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
<div class="form-group row">
<label for="creatorEmail" class="col-sm-2 col-form-label">Your email</label>
<div class="form-group col-sm-10">
<input type="email" class="form-control" id="creatorEmail" name="creatorEmail" placeholder="We won't spam you <3" data-validation="email required">
<small class="form-text">We will send your secret editing link to this email address.</small>
<input type="email" class="form-control" id="creatorEmail" name="creatorEmail" placeholder="We won't spam you <3 (optional)" data-validation="email" data-validation-optional="true">
<small class="form-text">If you provide your email, we will send your secret editing password here, and use it to notify you of updates to the event.</small>
</div>
</div>
<div class="form-group row">
Expand Down

0 comments on commit 4ef3273

Please sign in to comment.