コード例 #1
0
  /**
   * Returns the player profile page with the submitted info.
   *
   * @return The player profile page, which was just created/edited
   */
  @Security.Authenticated(Secured.class)
  public static Result playerManageSubmit() {
    // adds the new player from the PlayerForm page to the database.
    Form<PlayerFormData> data = Form.form(PlayerFormData.class).bindFromRequest();

    SearchFormData data2 = new SearchFormData();
    Form<SearchFormData> dataForm = Form.form(SearchFormData.class).fill(data2);
    Page<Player> playerPage = Player.find("name asc", 0);
    User user = Secured.getUserInfo(ctx());

    if (data.hasErrors()) {
      Map<String, Boolean> playerSkillMap = PlayerFields.getSkill();
      Map<String, Boolean> playerPosition = PlayerFields.getPosition();
      return badRequest(
          PlayerForm.render(
              "Bad Player Form", data, playerSkillMap, playerPosition, Secured.isLoggedIn(ctx())));
    } else {
      PlayerFormData formData = data.get();
      if (Player.getPlayer(user.getId()) == null) {
        // Player.addPlayer(formData);
      } else {
        Player.updatePlayer(formData, user.getId());
      }

      return ok(
          PlayerList.render(
              playerPage,
              "PlayerList",
              dataForm,
              "none",
              "none",
              Secured.isLoggedIn(ctx()),
              Secured.getUserInfo(ctx())));
    }
  }
コード例 #2
0
 /**
  * Returns the individual player's profile.
  *
  * @param id = the unique id for the profile
  * @return The individual player profile page.
  */
 @Security.Authenticated(Secured.class)
 public static Result playerProfile(long id) {
   Player player = Player.getPlayer(id);
   List<Game> games = Game.findPlayerGames(player.getUser().getName());
   List<Team> teams = Team.getTeams();
   return ok(
       PlayerProfile.render(
           "Player Profile",
           player,
           Secured.isLoggedIn(ctx()),
           Secured.getUserInfo(ctx()),
           games,
           teams));
 }
コード例 #3
0
 /**
  * Returns the player list page with all players.
  *
  * @return The Player profiles list page.
  */
 @Security.Authenticated(Secured.class)
 public static Result players(String sortOrder, Integer page) {
   SearchFormData data2 = new SearchFormData();
   Form<SearchFormData> dataForm = Form.form(SearchFormData.class).fill(data2);
   Page<Player> playerPage = Player.find(sortOrder, page);
   return ok(
       PlayerList.render(
           playerPage,
           "PlayerList",
           dataForm,
           "none",
           "none",
           Secured.isLoggedIn(ctx()),
           Secured.getUserInfo(ctx())));
 }
コード例 #4
0
  /**
   * Returns the player list page based on name search.
   *
   * @return The Player profiles list page.
   */
  @Security.Authenticated(Secured.class)
  public static Result playerNameSearch() {
    SearchFormData data2 = new SearchFormData();
    Form<SearchFormData> dataForm = Form.form(SearchFormData.class).fill(data2);

    Form<SearchFormData> data = Form.form(SearchFormData.class).bindFromRequest();
    SearchFormData formData = data.get();
    Page<Player> playerPage = Player.find("name", formData.name, "name asc", 1);

    return ok(
        PlayerList.render(
            playerPage,
            "PlayerList",
            dataForm,
            "name",
            formData.name,
            Secured.isLoggedIn(ctx()),
            Secured.getUserInfo(ctx())));
  }
コード例 #5
0
  /**
   * Returns the player form page to edit player's profiles.
   *
   * @return The player form page
   */
  @Security.Authenticated(Secured.class)
  public static Result playerManage() {
    PlayerFormData data2 = new PlayerFormData();
    Form<PlayerFormData> dataForm = Form.form(PlayerFormData.class).fill(data2);

    // Map of players skill levels and positions.
    // When user selects either their skill or position that skill or position is set as true.
    Map<String, Boolean> playerSkillMap = PlayerFields.getSkill();
    Map<String, Boolean> playerPosition = PlayerFields.getPosition();

    Page<Player> playerPage = Player.find("name asc", 1);
    return ok(
        PlayerForm.render(
            "Player Form", dataForm, playerSkillMap, playerPosition, Secured.isLoggedIn(ctx())));
  }
コード例 #6
0
  @Security.Authenticated(Secured.class)
  public static Result playerEdit(long id) {
    PlayerFormData playerData = new PlayerFormData(Player.getPlayer(id));
    Form<PlayerFormData> playerFormData = Form.form(PlayerFormData.class).fill(playerData);

    // Map of players skill levels and positions.
    // When user selects either their skill or position that skill or position is set as true.
    Map<String, Boolean> playerSkillMap = PlayerFields.getSkill();
    Map<String, Boolean> playerPosition = PlayerFields.getPosition();

    return ok(
        PlayerForm.render(
            "Player Form",
            playerFormData,
            playerSkillMap,
            playerPosition,
            Secured.isLoggedIn(ctx())));
  }