summaryrefslogtreecommitdiff
path: root/src/com/p4square
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/p4square')
-rw-r--r--src/com/p4square/grow/frontend/ChapterCompletePage.java54
-rw-r--r--src/com/p4square/grow/frontend/GrowFrontend.java1
-rw-r--r--src/com/p4square/grow/frontend/TrainingPageResource.java2
3 files changed, 37 insertions, 20 deletions
diff --git a/src/com/p4square/grow/frontend/ChapterCompletePage.java b/src/com/p4square/grow/frontend/ChapterCompletePage.java
index e8d5ca4..221519f 100644
--- a/src/com/p4square/grow/frontend/ChapterCompletePage.java
+++ b/src/com/p4square/grow/frontend/ChapterCompletePage.java
@@ -51,7 +51,10 @@ public class ChapterCompletePage extends FreeMarkerPageResource {
mConfig = mGrowFrontend.getConfig();
mJsonClient = new JsonRequestClient(getContext().getClientDispatcher());
- mTrainingRecordProvider = new TrainingRecordProvider<String>(new JsonRequestProvider<TrainingRecord>(getContext().getClientDispatcher(), TrainingRecord.class)) {
+ mTrainingRecordProvider = new TrainingRecordProvider<String>(
+ new JsonRequestProvider<TrainingRecord>(
+ getContext().getClientDispatcher(),
+ TrainingRecord.class)) {
@Override
public String makeKey(String userid) {
return getBackendEndpoint() + "/accounts/" + userid + "/training";
@@ -68,14 +71,7 @@ public class ChapterCompletePage extends FreeMarkerPageResource {
*/
@Override
protected Representation get() {
- Template t = mGrowFrontend.getTemplate("templates/stage-complete.ftl");
-
try {
- if (t == null) {
- setStatus(Status.CLIENT_ERROR_NOT_FOUND);
- return ErrorPage.TEMPLATE_NOT_FOUND;
- }
-
Map<String, Object> root = getRootObject();
// Get the training summary
@@ -110,16 +106,35 @@ public class ChapterCompletePage extends FreeMarkerPageResource {
}
}
- // Skip the chapter complete message for "Introduction"
- if ("introduction".equals(mChapter)) {
- String nextPage = mConfig.getString("dynamicRoot", "");
- nextPage += "/account/training/" + nextChapter;
- getResponse().redirectSeeOther(nextPage);
- return new StringRepresentation("Redirecting to " + nextPage);
- }
-
root.put("stage", mChapter);
root.put("nextstage", nextChapter);
+
+ /*
+ * We will display one of two transitional pages:
+ *
+ * If the next chapter has a forward page, display the forward page.
+ * Else, if this chapter is not "Introduction", display the chapter
+ * complete message.
+ */
+ Template t = mGrowFrontend.getTemplate("templates/stage-"
+ + nextChapter + "-forward.ftl");
+
+ if (t == null) {
+ // Skip the chapter complete message for "Introduction"
+ if ("introduction".equals(mChapter)) {
+ String nextPage = mConfig.getString("dynamicRoot", "");
+ nextPage += "/account/training/" + nextChapter;
+ getResponse().redirectSeeOther(nextPage);
+ return new StringRepresentation("Redirecting to " + nextPage);
+ }
+
+ t = mGrowFrontend.getTemplate("templates/stage-complete.ftl");
+ if (t == null) {
+ setStatus(Status.CLIENT_ERROR_NOT_FOUND);
+ return ErrorPage.TEMPLATE_NOT_FOUND;
+ }
+ }
+
return new TemplateRepresentation(t, root, MediaType.TEXT_HTML);
} catch (Exception e) {
@@ -145,14 +160,17 @@ public class ChapterCompletePage extends FreeMarkerPageResource {
final JsonResponse response = mJsonClient.get(getBackendEndpoint() + uri);
final Status status = response.getStatus();
if (!status.isSuccess() && !Status.CLIENT_ERROR_NOT_FOUND.equals(status)) {
- LOG.warn("Error making backend request for '" + uri + "'. status = " + response.getStatus().toString());
+ LOG.warn("Error making backend request for '" + uri
+ + "'. status = " + response.getStatus().toString());
}
return response;
}
int chapterIndex(String chapter) {
- if ("teacher".equals(chapter)) {
+ if ("leader".equals(chapter)) {
+ return 5;
+ } else if ("teacher".equals(chapter)) {
return 4;
} else if ("disciple".equals(chapter)) {
return 3;
diff --git a/src/com/p4square/grow/frontend/GrowFrontend.java b/src/com/p4square/grow/frontend/GrowFrontend.java
index aaf51a4..4b193d0 100644
--- a/src/com/p4square/grow/frontend/GrowFrontend.java
+++ b/src/com/p4square/grow/frontend/GrowFrontend.java
@@ -108,7 +108,6 @@ public class GrowFrontend extends FMFacade {
accountRouter.attach("/assessment", SurveyPageResource.class);
accountRouter.attach("/training/{chapter}/completed", ChapterCompletePage.class);
accountRouter.attach("/training/{chapter}/videos/{videoId}.json", VideosResource.class);
- accountRouter.attach("/training/leader", GroupLeaderTrainingPageResource.class);
accountRouter.attach("/training/{chapter}", TrainingPageResource.class);
accountRouter.attach("/training", TrainingPageResource.class);
accountRouter.attach("/feed/{topic}", FeedResource.class);
diff --git a/src/com/p4square/grow/frontend/TrainingPageResource.java b/src/com/p4square/grow/frontend/TrainingPageResource.java
index ae2f3a7..a1e7789 100644
--- a/src/com/p4square/grow/frontend/TrainingPageResource.java
+++ b/src/com/p4square/grow/frontend/TrainingPageResource.java
@@ -48,7 +48,7 @@ import com.p4square.grow.provider.Provider;
public class TrainingPageResource extends FreeMarkerPageResource {
private static final Logger LOG = Logger.getLogger(TrainingPageResource.class);
- private static final String[] CHAPTERS = { "introduction", "seeker", "believer", "disciple", "teacher" };
+ private static final String[] CHAPTERS = { "introduction", "seeker", "believer", "disciple", "teacher", "leader" };
private static final Comparator<Map<String, Object>> VIDEO_COMPARATOR = new Comparator<Map<String, Object>>() {
@Override
public int compare(Map<String, Object> left, Map<String, Object> right) {