Skip to content

Commit

Permalink
Fix multiple wrong messages appearing when edit/deleting events
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlieCrisp committed Jul 13, 2018
1 parent 076f1a1 commit 7bad59d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 15 deletions.
5 changes: 0 additions & 5 deletions Sources/HaCWebsiteLib/Controllers/EventApiController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,21 @@ struct EventApiController {
Log.info("Updating event in database failed due to missing parameters in api call")
response.statusCode = HTTPStatusCode.badRequest
try response.send("There were missing parameters in your api call. Please consult the API documentation. \n").end()
return
} catch EventParsingError.noSuchEvent {
Log.info("Updating event in database failed due to the event not existing")
response.statusCode = HTTPStatusCode.badRequest
try response.send("It appears there is no such event with that id.\n").end()
return
} catch {
Log.info("Updating event in database failed due to unknown reason")
response.statusCode = HTTPStatusCode.badRequest
try response.send("Could not update event for unknown reason. \n").end()
return
}
Log.info("Event updated in database sucessfully")
try response.send("The event has been updated sucessfully.\n").end()
return
} else {
Log.info("Editing event in database failed for unkown reason")
response.statusCode = HTTPStatusCode.badRequest
try response.send("Please use JSON for post data\n").end()
return
}
next()
}
Expand Down
2 changes: 0 additions & 2 deletions Sources/HaCWebsiteLib/Views/EventsPortal/AddEventForm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ struct AddEventForm: Nodeable {
if (xhr.readyState === 4 && xhr.status === 200) {
alert(\"Event added successfully\");
window.location.href = \"/beta/events-portal\";
} else {
alert(\"There seems to have been a problem\");
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ struct DeleteEventPage: Nodeable {
if (xhr.readyState === 4 && xhr.status === 200) {
alert(\"Event deleted successfully\");
window.location.href = \"/beta/events-portal\";
} else {
alert(\"There seems to have been a problem\");
}
};
Expand Down
10 changes: 4 additions & 6 deletions Sources/HaCWebsiteLib/Views/EventsPortal/EditEventPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ struct EditEventPage: Nodeable {
xhr.open(\"POST\", url, true);
xhr.setRequestHeader(\"Content-Type\", \"application/json\");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
alert(\"Event edited successfully\");
window.location.href = \"/beta/events-portal\";
} else {
alert(\"There seems to have been a problem\");
}
if (xhr.readyState === 4 && xhr.status === 200) {
alert(\"Event edited successfully\");
window.location.href = \"/beta/events-portal\";
}
};
var data = JSON.stringify(
Expand Down

0 comments on commit 7bad59d

Please sign in to comment.