summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2013-09-03 07:02:59 -0700
committerJesse Morgan <jesse@jesterpm.net>2013-09-03 07:03:26 -0700
commit235e27865559a72a903be28fd33cfeb8759730b4 (patch)
treea13565dc68c52d213bb78baeb648a6917f7ad267
parentaace86e8d6dfd7d5db7e882d631c5ea91983ccdb (diff)
New account page improvements and renumbered questions.
-rw-r--r--devfiles/questions/01.json (renamed from devfiles/questions/1.json)4
-rw-r--r--devfiles/questions/02.json (renamed from devfiles/questions/2.json)6
-rw-r--r--devfiles/questions/03.json (renamed from devfiles/questions/3.json)6
-rw-r--r--devfiles/questions/04.json (renamed from devfiles/questions/4.json)8
-rw-r--r--devfiles/questions/04a.json (renamed from devfiles/questions/4a.json)6
-rw-r--r--devfiles/questions/05.json (renamed from devfiles/questions/5.json)6
-rw-r--r--devfiles/questions/06.json (renamed from devfiles/questions/6.json)6
-rw-r--r--devfiles/questions/07.json (renamed from devfiles/questions/7.json)6
-rw-r--r--devfiles/questions/08.json (renamed from devfiles/questions/8.json)6
-rw-r--r--devfiles/questions/09.json (renamed from devfiles/questions/9.json)4
-rw-r--r--devfiles/questions/10.json2
-rwxr-xr-xdevfiles/scripts/bootstrap-cassandra.sh6
-rwxr-xr-xdevfiles/scripts/compile-questions.sh17
-rw-r--r--src/com/p4square/f1oauth/F1OAuthHelper.java19
-rw-r--r--src/com/p4square/grow/frontend/NewAccountResource.java20
-rw-r--r--src/grow.properties2
-rw-r--r--src/templates/pages/newaccount.html.ftl15
17 files changed, 88 insertions, 51 deletions
diff --git a/devfiles/questions/1.json b/devfiles/questions/01.json
index 30899e1..daa9c5e 100644
--- a/devfiles/questions/1.json
+++ b/devfiles/questions/01.json
@@ -1,5 +1,5 @@
{
- "id": "1",
+ "id": "01",
"type": "slider",
"question": "I Believe God",
"answers": {
@@ -8,5 +8,5 @@
"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"
+ "nextQuestion": "02"
}
diff --git a/devfiles/questions/2.json b/devfiles/questions/02.json
index f619cdd..86a3426 100644
--- a/devfiles/questions/2.json
+++ b/devfiles/questions/02.json
@@ -1,5 +1,5 @@
{
- "id": "2",
+ "id": "02",
"type": "image",
"question": "I see God this way",
"answers": {
@@ -10,6 +10,6 @@
"a5": { "score": "1" },
"a6": { "score": "1" }
},
- "previousQuestion": "1",
- "nextQuestion": "3"
+ "previousQuestion": "01",
+ "nextQuestion": "03"
}
diff --git a/devfiles/questions/3.json b/devfiles/questions/03.json
index cedfc79..3dd2b65 100644
--- a/devfiles/questions/3.json
+++ b/devfiles/questions/03.json
@@ -1,5 +1,5 @@
{
- "id": "3",
+ "id": "03",
"type": "circle",
"question": "In my life, Jesus is",
"topleft": "Leader & Savior and I generally apply his teaching",
@@ -14,6 +14,6 @@
"-1.00,1.00": { "score": "3" }
},
- "previousQuestion": "2",
- "nextQuestion": "4"
+ "previousQuestion": "02",
+ "nextQuestion": "04"
}
diff --git a/devfiles/questions/4.json b/devfiles/questions/04.json
index da83cd1..a3f66e2 100644
--- a/devfiles/questions/4.json
+++ b/devfiles/questions/04.json
@@ -1,13 +1,13 @@
{
- "id": "4",
+ "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": "5" }
+ "nextQuestion": "05" }
},
- "previousQuestion": "3",
- "nextQuestion": "4a"
+ "previousQuestion": "03",
+ "nextQuestion": "04a"
}
diff --git a/devfiles/questions/4a.json b/devfiles/questions/04a.json
index a9036e1..9977ec7 100644
--- a/devfiles/questions/4a.json
+++ b/devfiles/questions/04a.json
@@ -1,5 +1,5 @@
{
- "id": "4a",
+ "id": "04a",
"type": "text",
"question": "I accepted Jesus Christ as my Savior...",
"answers": {
@@ -8,6 +8,6 @@
"a3": { "text": "5 - 6 years ago", "type": "none" },
"a4": { "text": "7+ years ago", "type": "none" }
},
- "previousQuestion": "3",
- "nextQuestion": "5"
+ "previousQuestion": "03",
+ "nextQuestion": "05"
}
diff --git a/devfiles/questions/5.json b/devfiles/questions/05.json
index 6070acb..f1abade 100644
--- a/devfiles/questions/5.json
+++ b/devfiles/questions/05.json
@@ -1,5 +1,5 @@
{
- "id": "5",
+ "id": "05",
"type": "slider",
"question": "I share my faith in Jesus...",
"answers": {
@@ -8,6 +8,6 @@
"a3": { "text": "Sometimes", "score": "3" },
"a4": { "text": "Frequently", "score": "4" }
},
- "previousQuestion": "4",
- "nextQuestion": "6"
+ "previousQuestion": "04",
+ "nextQuestion": "06"
}
diff --git a/devfiles/questions/6.json b/devfiles/questions/06.json
index 1965bfb..c6788cb 100644
--- a/devfiles/questions/6.json
+++ b/devfiles/questions/06.json
@@ -1,5 +1,5 @@
{
- "id": "6",
+ "id": "06",
"type": "circle",
"question": "I believe the Bible is:",
"topleft": "Inspired word of God and I try to read it regularly",
@@ -14,6 +14,6 @@
"-1.00,1.00": { "score": "3" }
},
- "previousQuestion": "5",
- "nextQuestion": "7"
+ "previousQuestion": "05",
+ "nextQuestion": "07"
}
diff --git a/devfiles/questions/7.json b/devfiles/questions/07.json
index 3386137..be714da 100644
--- a/devfiles/questions/7.json
+++ b/devfiles/questions/07.json
@@ -1,5 +1,5 @@
{
- "id": "7",
+ "id": "07",
"type": "slider",
"question": "I believe following the Bible\'s teachings is",
"answers": {
@@ -8,6 +8,6 @@
"a3": { "text": "Encouraged by God", "score": "3" },
"a4": { "text": "Essential", "score": "4" }
},
- "previousQuestion": "6",
- "nextQuestion": "8"
+ "previousQuestion": "06",
+ "nextQuestion": "08"
}
diff --git a/devfiles/questions/8.json b/devfiles/questions/08.json
index 3c0f07c..4775554 100644
--- a/devfiles/questions/8.json
+++ b/devfiles/questions/08.json
@@ -1,5 +1,5 @@
{
- "id": "8",
+ "id": "08",
"type": "image",
"question": "My spiritual life resembles...",
"answers": {
@@ -7,6 +7,6 @@
"a2": { "score": "2", "type": "none" },
"a3": { "score": "1", "type": "none" }
},
- "previousQuestion": "7",
- "nextQuestion": "9"
+ "previousQuestion": "07",
+ "nextQuestion": "09"
}
diff --git a/devfiles/questions/9.json b/devfiles/questions/09.json
index c49dd56..dab424e 100644
--- a/devfiles/questions/9.json
+++ b/devfiles/questions/09.json
@@ -1,5 +1,5 @@
{
- "id": "9",
+ "id": "09",
"type": "circle",
"question": "Prayer for me is:",
"topleft": "Important and I pray regularly",
@@ -14,6 +14,6 @@
"-1.00,1.00": { "score": "3" }
},
- "previousQuestion": "8",
+ "previousQuestion": "08",
"nextQuestion": "10"
}
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/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<String, Object> 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!
- </#if>
- </@noticebox>
+ </@noticebox>
+ <#else>
+ <@noticebox>
+ </@noticebox>
+ </#if>
<@content>
<p>
Fill out the form below to create a new Puyallup Foursquare InFellowship account.
</p>
- <form action="${dynamicRoot}/createaccount" method="post">
+ <form action="${dynamicRoot}/newaccount.html" method="post">
<p><label for="firstnameField">First Name:</label> <input id="firstnameField" type="text" name="firstname" /></p>
<p><label for="lastnameField">Last Name:</label> <input id="lastnameField" type="text" name="lastname" /></p>
<p><label for="emailField">Email:</label> <input id="emailField" type="text" name="email" /></p>