From 235e27865559a72a903be28fd33cfeb8759730b4 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Tue, 3 Sep 2013 07:02:59 -0700 Subject: New account page improvements and renumbered questions. --- devfiles/questions/01.json | 12 ++++++++++++ devfiles/questions/02.json | 15 +++++++++++++++ devfiles/questions/03.json | 19 +++++++++++++++++++ devfiles/questions/04.json | 13 +++++++++++++ devfiles/questions/04a.json | 13 +++++++++++++ devfiles/questions/05.json | 13 +++++++++++++ devfiles/questions/06.json | 19 +++++++++++++++++++ devfiles/questions/07.json | 13 +++++++++++++ devfiles/questions/08.json | 12 ++++++++++++ devfiles/questions/09.json | 19 +++++++++++++++++++ devfiles/questions/1.json | 12 ------------ devfiles/questions/10.json | 2 +- devfiles/questions/2.json | 15 --------------- devfiles/questions/3.json | 19 ------------------- devfiles/questions/4.json | 13 ------------- devfiles/questions/4a.json | 13 ------------- devfiles/questions/5.json | 13 ------------- devfiles/questions/6.json | 19 ------------------- devfiles/questions/7.json | 13 ------------- devfiles/questions/8.json | 12 ------------ devfiles/questions/9.json | 19 ------------------- devfiles/scripts/bootstrap-cassandra.sh | 6 +++--- devfiles/scripts/compile-questions.sh | 17 +++++++++++++++++ src/com/p4square/f1oauth/F1OAuthHelper.java | 19 ++++++++++++++----- .../p4square/grow/frontend/NewAccountResource.java | 20 ++++++++++++++------ src/grow.properties | 2 ++ src/templates/pages/newaccount.html.ftl | 15 ++++++++------- 27 files changed, 207 insertions(+), 170 deletions(-) create mode 100644 devfiles/questions/01.json create mode 100644 devfiles/questions/02.json create mode 100644 devfiles/questions/03.json create mode 100644 devfiles/questions/04.json create mode 100644 devfiles/questions/04a.json create mode 100644 devfiles/questions/05.json create mode 100644 devfiles/questions/06.json create mode 100644 devfiles/questions/07.json create mode 100644 devfiles/questions/08.json create mode 100644 devfiles/questions/09.json delete mode 100644 devfiles/questions/1.json delete mode 100644 devfiles/questions/2.json delete mode 100644 devfiles/questions/3.json delete mode 100644 devfiles/questions/4.json delete mode 100644 devfiles/questions/4a.json delete mode 100644 devfiles/questions/5.json delete mode 100644 devfiles/questions/6.json delete mode 100644 devfiles/questions/7.json delete mode 100644 devfiles/questions/8.json delete mode 100644 devfiles/questions/9.json diff --git a/devfiles/questions/01.json b/devfiles/questions/01.json new file mode 100644 index 0000000..daa9c5e --- /dev/null +++ b/devfiles/questions/01.json @@ -0,0 +1,12 @@ +{ + "id": "01", + "type": "slider", + "question": "I Believe God", + "answers": { + "a1": { "text": "Is a figure in religious teaching, but not personally significant to me", "score": "1" }, + "a2": { "text": "Created the earth and us, and from that point His not actively involved in our lives", "score": "2" }, + "a3": { "text": "Created the earth and everything in it, and is involved to some extent", "score": "3" }, + "a4": { "text": "Is creator and ultimate authority in all things, and holds the future of all creation in His hands", "score": "4" } + }, + "nextQuestion": "02" +} diff --git a/devfiles/questions/02.json b/devfiles/questions/02.json new file mode 100644 index 0000000..86a3426 --- /dev/null +++ b/devfiles/questions/02.json @@ -0,0 +1,15 @@ +{ + "id": "02", + "type": "image", + "question": "I see God this way", + "answers": { + "a1": { "score": "2" }, + "a2": { "score": "1" }, + "a3": { "score": "3" }, + "a4": { "score": "1" }, + "a5": { "score": "1" }, + "a6": { "score": "1" } + }, + "previousQuestion": "01", + "nextQuestion": "03" +} diff --git a/devfiles/questions/03.json b/devfiles/questions/03.json new file mode 100644 index 0000000..3dd2b65 --- /dev/null +++ b/devfiles/questions/03.json @@ -0,0 +1,19 @@ +{ + "id": "03", + "type": "circle", + "question": "In my life, Jesus is", + "topleft": "Leader & Savior and I generally apply his teaching", + "topright": "Leader & Savior and obedience is essential", + "bottomleft": "The Son of God, and I\'m learning more about him", + "bottomright": "An important person or figure in history", + + "answers": { + "1.00,1.00": { "score": "4" }, + "1.00,-1.00": { "score": "1" }, + "-1.00,-1.00": { "score": "2" }, + "-1.00,1.00": { "score": "3" } + }, + + "previousQuestion": "02", + "nextQuestion": "04" +} diff --git a/devfiles/questions/04.json b/devfiles/questions/04.json new file mode 100644 index 0000000..a3f66e2 --- /dev/null +++ b/devfiles/questions/04.json @@ -0,0 +1,13 @@ +{ + "id": "04", + "type": "text", + "question": "I accepted Jesus Christ as my Savior...", + "answers": { + "a1": { "text": "In my current church.", "type": "none" }, + "a2": { "text": "Somewhere else.", "type": "none" }, + "a3": { "text": "I have not accepted Jesus Christ as my savior.", "score": "0", "type": "trump", + "nextQuestion": "05" } + }, + "previousQuestion": "03", + "nextQuestion": "04a" +} diff --git a/devfiles/questions/04a.json b/devfiles/questions/04a.json new file mode 100644 index 0000000..9977ec7 --- /dev/null +++ b/devfiles/questions/04a.json @@ -0,0 +1,13 @@ +{ + "id": "04a", + "type": "text", + "question": "I accepted Jesus Christ as my Savior...", + "answers": { + "a1": { "text": "1 - 2 years ago", "type": "none" }, + "a2": { "text": "3 - 4 years ago", "type": "none" }, + "a3": { "text": "5 - 6 years ago", "type": "none" }, + "a4": { "text": "7+ years ago", "type": "none" } + }, + "previousQuestion": "03", + "nextQuestion": "05" +} diff --git a/devfiles/questions/05.json b/devfiles/questions/05.json new file mode 100644 index 0000000..f1abade --- /dev/null +++ b/devfiles/questions/05.json @@ -0,0 +1,13 @@ +{ + "id": "05", + "type": "slider", + "question": "I share my faith in Jesus...", + "answers": { + "a1": { "text": "Never", "score": "1" }, + "a2": { "text": "Rarely", "score": "2" }, + "a3": { "text": "Sometimes", "score": "3" }, + "a4": { "text": "Frequently", "score": "4" } + }, + "previousQuestion": "04", + "nextQuestion": "06" +} diff --git a/devfiles/questions/06.json b/devfiles/questions/06.json new file mode 100644 index 0000000..c6788cb --- /dev/null +++ b/devfiles/questions/06.json @@ -0,0 +1,19 @@ +{ + "id": "06", + "type": "circle", + "question": "I believe the Bible is:", + "topleft": "Inspired word of God and I try to read it regularly", + "topright": "Authoritative and essential to my life and I read it daily", + "bottomleft": "Pretty good wisdome, compiled that I occasionally read", + "bottomright": "A collection of moral stories, but generally not relevant to me", + + "answers": { + "1.00,1.00": { "score": "4" }, + "1.00,-1.00": { "score": "1" }, + "-1.00,-1.00": { "score": "2" }, + "-1.00,1.00": { "score": "3" } + }, + + "previousQuestion": "05", + "nextQuestion": "07" +} diff --git a/devfiles/questions/07.json b/devfiles/questions/07.json new file mode 100644 index 0000000..be714da --- /dev/null +++ b/devfiles/questions/07.json @@ -0,0 +1,13 @@ +{ + "id": "07", + "type": "slider", + "question": "I believe following the Bible\'s teachings is", + "answers": { + "a1": { "text": "Outdated", "score": "1" }, + "a2": { "text": "Good Idea", "score": "2" }, + "a3": { "text": "Encouraged by God", "score": "3" }, + "a4": { "text": "Essential", "score": "4" } + }, + "previousQuestion": "06", + "nextQuestion": "08" +} diff --git a/devfiles/questions/08.json b/devfiles/questions/08.json new file mode 100644 index 0000000..4775554 --- /dev/null +++ b/devfiles/questions/08.json @@ -0,0 +1,12 @@ +{ + "id": "08", + "type": "image", + "question": "My spiritual life resembles...", + "answers": { + "a1": { "score": "3", "type": "none" }, + "a2": { "score": "2", "type": "none" }, + "a3": { "score": "1", "type": "none" } + }, + "previousQuestion": "07", + "nextQuestion": "09" +} diff --git a/devfiles/questions/09.json b/devfiles/questions/09.json new file mode 100644 index 0000000..dab424e --- /dev/null +++ b/devfiles/questions/09.json @@ -0,0 +1,19 @@ +{ + "id": "09", + "type": "circle", + "question": "Prayer for me is:", + "topleft": "Important and I pray regularly", + "topright": "Constant, conversational, a lifestyle, and absolutely indespensible in my life", + "bottomleft": "Helpful I think, and I pray occassionally", + "bottomright": "Not important, I don\'t believe it\'s helpful or useful", + + "answers": { + "1.00,1.00": { "score": "4" }, + "1.00,-1.00": { "score": "1" }, + "-1.00,-1.00": { "score": "2" }, + "-1.00,1.00": { "score": "3" } + }, + + "previousQuestion": "08", + "nextQuestion": "10" +} diff --git a/devfiles/questions/1.json b/devfiles/questions/1.json deleted file mode 100644 index 30899e1..0000000 --- a/devfiles/questions/1.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "id": "1", - "type": "slider", - "question": "I Believe God", - "answers": { - "a1": { "text": "Is a figure in religious teaching, but not personally significant to me", "score": "1" }, - "a2": { "text": "Created the earth and us, and from that point His not actively involved in our lives", "score": "2" }, - "a3": { "text": "Created the earth and everything in it, and is involved to some extent", "score": "3" }, - "a4": { "text": "Is creator and ultimate authority in all things, and holds the future of all creation in His hands", "score": "4" } - }, - "nextQuestion": "2" -} diff --git a/devfiles/questions/10.json b/devfiles/questions/10.json index 1a84b84..d76520c 100644 --- a/devfiles/questions/10.json +++ b/devfiles/questions/10.json @@ -8,6 +8,6 @@ "a3": { "text": "Enjoyable", "score": "3" }, "a4": { "text": "Lifestyle", "score": "4" } }, - "previousQuestion": "9", + "previousQuestion": "09", "nextQuestion": "11" } diff --git a/devfiles/questions/2.json b/devfiles/questions/2.json deleted file mode 100644 index f619cdd..0000000 --- a/devfiles/questions/2.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "id": "2", - "type": "image", - "question": "I see God this way", - "answers": { - "a1": { "score": "2" }, - "a2": { "score": "1" }, - "a3": { "score": "3" }, - "a4": { "score": "1" }, - "a5": { "score": "1" }, - "a6": { "score": "1" } - }, - "previousQuestion": "1", - "nextQuestion": "3" -} diff --git a/devfiles/questions/3.json b/devfiles/questions/3.json deleted file mode 100644 index cedfc79..0000000 --- a/devfiles/questions/3.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "id": "3", - "type": "circle", - "question": "In my life, Jesus is", - "topleft": "Leader & Savior and I generally apply his teaching", - "topright": "Leader & Savior and obedience is essential", - "bottomleft": "The Son of God, and I\'m learning more about him", - "bottomright": "An important person or figure in history", - - "answers": { - "1.00,1.00": { "score": "4" }, - "1.00,-1.00": { "score": "1" }, - "-1.00,-1.00": { "score": "2" }, - "-1.00,1.00": { "score": "3" } - }, - - "previousQuestion": "2", - "nextQuestion": "4" -} diff --git a/devfiles/questions/4.json b/devfiles/questions/4.json deleted file mode 100644 index da83cd1..0000000 --- a/devfiles/questions/4.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "id": "4", - "type": "text", - "question": "I accepted Jesus Christ as my Savior...", - "answers": { - "a1": { "text": "In my current church.", "type": "none" }, - "a2": { "text": "Somewhere else.", "type": "none" }, - "a3": { "text": "I have not accepted Jesus Christ as my savior.", "score": "0", "type": "trump", - "nextQuestion": "5" } - }, - "previousQuestion": "3", - "nextQuestion": "4a" -} diff --git a/devfiles/questions/4a.json b/devfiles/questions/4a.json deleted file mode 100644 index a9036e1..0000000 --- a/devfiles/questions/4a.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "id": "4a", - "type": "text", - "question": "I accepted Jesus Christ as my Savior...", - "answers": { - "a1": { "text": "1 - 2 years ago", "type": "none" }, - "a2": { "text": "3 - 4 years ago", "type": "none" }, - "a3": { "text": "5 - 6 years ago", "type": "none" }, - "a4": { "text": "7+ years ago", "type": "none" } - }, - "previousQuestion": "3", - "nextQuestion": "5" -} diff --git a/devfiles/questions/5.json b/devfiles/questions/5.json deleted file mode 100644 index 6070acb..0000000 --- a/devfiles/questions/5.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "id": "5", - "type": "slider", - "question": "I share my faith in Jesus...", - "answers": { - "a1": { "text": "Never", "score": "1" }, - "a2": { "text": "Rarely", "score": "2" }, - "a3": { "text": "Sometimes", "score": "3" }, - "a4": { "text": "Frequently", "score": "4" } - }, - "previousQuestion": "4", - "nextQuestion": "6" -} diff --git a/devfiles/questions/6.json b/devfiles/questions/6.json deleted file mode 100644 index 1965bfb..0000000 --- a/devfiles/questions/6.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "id": "6", - "type": "circle", - "question": "I believe the Bible is:", - "topleft": "Inspired word of God and I try to read it regularly", - "topright": "Authoritative and essential to my life and I read it daily", - "bottomleft": "Pretty good wisdome, compiled that I occasionally read", - "bottomright": "A collection of moral stories, but generally not relevant to me", - - "answers": { - "1.00,1.00": { "score": "4" }, - "1.00,-1.00": { "score": "1" }, - "-1.00,-1.00": { "score": "2" }, - "-1.00,1.00": { "score": "3" } - }, - - "previousQuestion": "5", - "nextQuestion": "7" -} diff --git a/devfiles/questions/7.json b/devfiles/questions/7.json deleted file mode 100644 index 3386137..0000000 --- a/devfiles/questions/7.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "id": "7", - "type": "slider", - "question": "I believe following the Bible\'s teachings is", - "answers": { - "a1": { "text": "Outdated", "score": "1" }, - "a2": { "text": "Good Idea", "score": "2" }, - "a3": { "text": "Encouraged by God", "score": "3" }, - "a4": { "text": "Essential", "score": "4" } - }, - "previousQuestion": "6", - "nextQuestion": "8" -} diff --git a/devfiles/questions/8.json b/devfiles/questions/8.json deleted file mode 100644 index 3c0f07c..0000000 --- a/devfiles/questions/8.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "id": "8", - "type": "image", - "question": "My spiritual life resembles...", - "answers": { - "a1": { "score": "3", "type": "none" }, - "a2": { "score": "2", "type": "none" }, - "a3": { "score": "1", "type": "none" } - }, - "previousQuestion": "7", - "nextQuestion": "9" -} diff --git a/devfiles/questions/9.json b/devfiles/questions/9.json deleted file mode 100644 index c49dd56..0000000 --- a/devfiles/questions/9.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "id": "9", - "type": "circle", - "question": "Prayer for me is:", - "topleft": "Important and I pray regularly", - "topright": "Constant, conversational, a lifestyle, and absolutely indespensible in my life", - "bottomleft": "Helpful I think, and I pray occassionally", - "bottomright": "Not important, I don\'t believe it\'s helpful or useful", - - "answers": { - "1.00,1.00": { "score": "4" }, - "1.00,-1.00": { "score": "1" }, - "-1.00,-1.00": { "score": "2" }, - "-1.00,1.00": { "score": "3" } - }, - - "previousQuestion": "8", - "nextQuestion": "10" -} diff --git a/devfiles/scripts/bootstrap-cassandra.sh b/devfiles/scripts/bootstrap-cassandra.sh index e0813a0..128767e 100755 --- a/devfiles/scripts/bootstrap-cassandra.sh +++ b/devfiles/scripts/bootstrap-cassandra.sh @@ -12,13 +12,13 @@ $TOOLS/scripts/setup-cassandra.sh # Bootstrap keyspace TEMPFILE=`mktemp` -cat $DEVFILES/cassandra-bootstrap.cql > $TEMPFILE +cat $DEVFILES/scripts/cassandra-bootstrap.cql > $TEMPFILE # Fill with questions -./compile-questions.sh >> $TEMPFILE +$DEVFILES/scripts/compile-questions.sh >> $TEMPFILE # Fill with videos -./compile-videos.sh >> $TEMPFILE +$DEVFILES/scripts/compile-videos.sh >> $TEMPFILE # GO! #cat $TEMPFILE | less diff --git a/devfiles/scripts/compile-questions.sh b/devfiles/scripts/compile-questions.sh index 16be5b1..7f108b8 100755 --- a/devfiles/scripts/compile-questions.sh +++ b/devfiles/scripts/compile-questions.sh @@ -1,9 +1,26 @@ # Dump Cassandra commands to setup questions + +FIRST="" +COUNT=0 + for i in $DEVFILES/questions/*.json; do id=`basename $i .json` + if [ -z "$FIRST" ]; then + FIRST=$id + fi echo "set strings['/questions/${id}']['value'] = '" cat $i echo "';" + COUNT=$((COUNT + 1)) done +# Create Summary +cat << EOF +set strings['/questions']['value'] = ' +{ + "first": "$FIRST", + "count": $COUNT +} +'; +EOF diff --git a/src/com/p4square/f1oauth/F1OAuthHelper.java b/src/com/p4square/f1oauth/F1OAuthHelper.java index 4f55043..f6f736f 100644 --- a/src/com/p4square/f1oauth/F1OAuthHelper.java +++ b/src/com/p4square/f1oauth/F1OAuthHelper.java @@ -13,7 +13,9 @@ import org.restlet.Response; import org.restlet.Request; import org.restlet.data.ChallengeResponse; import org.restlet.data.ChallengeScheme; +import org.restlet.data.MediaType; import org.restlet.data.Method; +import org.restlet.data.Status; import org.restlet.engine.util.Base64; import org.restlet.representation.StringRepresentation; @@ -108,21 +110,28 @@ public class F1OAuthHelper extends OAuthHelper { return processAccessTokenRequest(request); } - public void createAccount(String firstname, String lastname, String email, String redirect) + public boolean createAccount(String firstname, String lastname, String email, String redirect) throws OAuthException { String req = String.format("{\n\"account\":{\n\"firstName\":\"%s\",\n" + "\"lastName\":\"%s\",\n\"email\":\"%s\",\n" + "\"urlRedirect\":\"%s\"\n}\n}", firstname, lastname, email, redirect); - Request request = new Request(Method.POST, mBaseUrl + "/Accounts"); + Request request = new Request(Method.POST, mBaseUrl + "Accounts"); request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_OAUTH)); - request.setEntity(new StringRepresentation(req)); + request.setEntity(new StringRepresentation(req, MediaType.APPLICATION_JSON)); Response response = getResponse(request); - if (!response.getStatus().isSuccess()) { - throw new OAuthException(response.getStatus()); + Status status = response.getStatus(); + if (Status.SUCCESS_NO_CONTENT.equals(status)) { + return true; + + } else if (Status.CLIENT_ERROR_CONFLICT.equals(status)) { + return false; + + } else { + throw new OAuthException(status); } } } diff --git a/src/com/p4square/grow/frontend/NewAccountResource.java b/src/com/p4square/grow/frontend/NewAccountResource.java index e0b857a..f37a33e 100644 --- a/src/com/p4square/grow/frontend/NewAccountResource.java +++ b/src/com/p4square/grow/frontend/NewAccountResource.java @@ -46,10 +46,12 @@ public class NewAccountResource extends FreeMarkerPageResource { mGrowFrontend = (GrowFrontend) getApplication(); mHelper = mGrowFrontend.getHelper(); - mErrorMessage = null; + mErrorMessage = ""; - mLoginPageUrl = ""; - mVerificationPage = ""; + mLoginPageUrl = mGrowFrontend.getConfig().getString("postAccountCreationPage", + getRequest().getRootRef().toString()); + mVerificationPage = mGrowFrontend.getConfig().getString("dynamicRoot", "") + + "/verification.html"; } /** @@ -66,7 +68,9 @@ public class NewAccountResource extends FreeMarkerPageResource { } Map root = getRootObject(); - root.put("errorMessage", mErrorMessage); + if (mErrorMessage.length() > 0) { + root.put("errorMessage", mErrorMessage); + } return new TemplateRepresentation(t, root, MediaType.TEXT_HTML); @@ -100,7 +104,11 @@ public class NewAccountResource extends FreeMarkerPageResource { } try { - mHelper.createAccount(firstname, lastname, email, mLoginPageUrl); + if (!mHelper.createAccount(firstname, lastname, email, mLoginPageUrl)) { + mErrorMessage = "An account with that address already exists."; + return get(); + } + getResponse().redirectSeeOther(mVerificationPage); return new StringRepresentation("Redirecting to " + mVerificationPage); @@ -110,6 +118,6 @@ public class NewAccountResource extends FreeMarkerPageResource { } private boolean isEmpty(String s) { - return s != null && s.trim().length() > 0; + return s == null || s.trim().length() == 0; } } diff --git a/src/grow.properties b/src/grow.properties index 88bee42..6dd282c 100644 --- a/src/grow.properties +++ b/src/grow.properties @@ -12,6 +12,8 @@ dev.dynamicRoot = *.f1BaseUrl = staging.fellowshiponeapi.com *.f1ChurchCode = pfseawa +prod.postAccountCreationPage = http://foursquaregrow.com/login.html + # Backend Settings dev.clusterName = Dev Cluster diff --git a/src/templates/pages/newaccount.html.ftl b/src/templates/pages/newaccount.html.ftl index 780a5c8..edfd196 100644 --- a/src/templates/pages/newaccount.html.ftl +++ b/src/templates/pages/newaccount.html.ftl @@ -2,19 +2,20 @@ <#include "/macros/common-page.ftl"> <@commonpage> - <@noticebox> - <#if errorMessage??> + <#if errorMessage??> + <@noticebox class="visible"> ${errorMessage?html} - <#else> - Welcome! - - + + <#else> + <@noticebox> + + <@content>

Fill out the form below to create a new Puyallup Foursquare InFellowship account.

-
+

-- cgit v1.2.3