@Path("/advance/{id}")
  @GET
  @Produces("text/html")
  public Response advanceGet(@PathParam("id") final String encoded) {

    String[] params = courseService.getCourseSignupFromEncrypted(encoded);
    if (log.isDebugEnabled()) {
      for (int i = 0; i < params.length; i++) {
        log.debug("decoded parameter [" + params[i] + "]");
      }
    }
    String signupId = params[0];
    // This is the status that is being advanced to.
    String emailStatus = params[1];
    Status status = toStatus(emailStatus);
    CourseSignup signup = courseService.getCourseSignupAnyway(signupId);
    Map<String, Object> model = new HashMap<>();
    model.put("signup", signup);
    model.put("encoded", encoded);

    // Check that the status we're trying to advance to is valid
    if (!statusProgression.next(signup.getStatus()).contains(status)) {
      model.put("errors", Collections.singletonList("The signup has already been dealt with."));
    } else {
      // We only put the status in if we're happy for it to be changed.
      model.put("status", emailStatus);
    }

    addStandardAttributes(model);

    return Response.ok(new Viewable("/static/advance", model)).build();
  }
  @Path("/advance/{id}")
  @POST
  @Produces("text/html")
  public Response advancePost(
      @PathParam("id") final String encoded, @FormParam("formStatus") final String formStatus) {

    if (null == encoded) {
      return Response.noContent().build();
    }
    String[] params = courseService.getCourseSignupFromEncrypted(encoded);

    String signupId = params[0];
    Status status = toStatus(params[1]);
    String placementId = params[2];

    CourseSignup signup = courseService.getCourseSignupAnyway(signupId);
    if (null == signup) {
      return Response.noContent().build();
    }
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("signup", signup);
    if (!statusProgression.next(signup.getStatus()).contains(status)) {
      model.put("errors", Collections.singletonList("The signup has already been dealt with."));
    } else {
      try {
        switch (formStatus.toLowerCase()) {
          case "accept":
            courseService.accept(signupId, true, placementId);
            break;
          case "approve":
            courseService.approve(signupId, true, placementId);
            break;
          case "confirm":
            courseService.confirm(signupId, true, placementId);
            break;
          case "reject":
            courseService.reject(signupId, true, placementId);
            break;
          default:
            throw new IllegalStateException("No mapping for action of: " + formStatus);
        }
      } catch (IllegalStateException ise) {
        model.put("errors", Collections.singletonList(ise.getMessage()));
      }
    }

    addStandardAttributes(model);
    return Response.ok(new Viewable("/static/ok", model)).build();
  }