Ejemplo n.º 1
0
  @RequestMapping("/admin")
  public String admin(
      HttpSession session,
      @RequestParam(required = false, value = "password") String password,
      @RequestParam(required = false, value = "view") String groupId,
      @RequestParam(required = false, value = "item") String itemId,
      Model model)
      throws Exception {

    if (password != null) session.setAttribute("campodejazayeri-admin-password", password);
    if (!"PASSWORD".equals(session.getAttribute("campodejazayeri-admin-password"))) {
      return "admin-authenticate";
    }

    ViewQuery query =
        new ViewQuery().designDocId("_design/groups").viewName("groups").includeDocs(true);
    List<InvitationGroup> groups = db.queryView(query, InvitationGroup.class);
    model.addAttribute("groups", groups);

    List<String> attendees = new ArrayList<String>();
    List<String> notAttending = new ArrayList<String>();
    for (InvitationGroup g : groups) {
      for (Invitee inv : g.getAttending()) attendees.add(g.getGroupName() + ": " + inv.getName());
      for (Invitee inv : g.getSaidNo()) notAttending.add(g.getGroupName() + ": " + inv.getName());
    }
    model.addAttribute("numAttendees", attendees.size());
    model.addAttribute("attendees", attendees);
    model.addAttribute("numNotAttending", notAttending.size());
    model.addAttribute("notAttending", notAttending);

    List<String> attendingWednesday = new ArrayList<String>();
    List<String> attendingThursday = new ArrayList<String>();
    List<String> attendingFriday = new ArrayList<String>();
    List<String> attendingRehearsal = new ArrayList<String>();
    List<String> attendingCeremony = new ArrayList<String>();
    List<String> attendingFiesta = new ArrayList<String>();

    for (InvitationGroup g : groups) {
      for (Invitee i : g.getInvitees()) {
        if (test(i.getAttendingWednesday())) attendingWednesday.add(format(g, i));
        if (test(i.getAttendingThursday())) attendingThursday.add(format(g, i));
        if (test(i.getAttendingFriday())) attendingFriday.add(format(g, i));
        if (test(i.getAttendingRehearsal())) attendingRehearsal.add(format(g, i));
        if (test(i.getAttendingCeremony())) attendingCeremony.add(format(g, i));
        if (test(i.getAttendingFiesta())) attendingFiesta.add(format(g, i));
      }
    }

    model.addAttribute("attendingWednesday", attendingWednesday);
    model.addAttribute("attendingThursday", attendingThursday);
    model.addAttribute("attendingFriday", attendingFriday);
    model.addAttribute("attendingRehearsal", attendingRehearsal);
    model.addAttribute("attendingCeremony", attendingCeremony);
    model.addAttribute("attendingFiesta", attendingFiesta);

    List<String> englishGroups = new ArrayList<String>();
    List<String> spanishGroups = new ArrayList<String>();
    for (InvitationGroup g : groups) {
      if ("en".equals(g.getLanguage()) && g.getAttending().size() > 0) {
        englishGroups.add(g.getId() + " - " + g.getGroupName());
      } else if ("es".equals(g.getLanguage()) && g.getAttending().size() > 0) {
        spanishGroups.add(g.getId() + " - " + g.getGroupName());
      }
    }
    model.addAttribute("englishComing", englishGroups);
    model.addAttribute("spanishComing", spanishGroups);

    if (groupId != null) {
      InvitationGroup group = db.get(InvitationGroup.class, groupId);
      model.addAttribute("group", group);
    }

    return null;
  }
Ejemplo n.º 2
0
 /**
  * Auto generated method comment
  *
  * @param g
  * @param i
  * @return
  */
 private String format(InvitationGroup g, Invitee i) {
   return "<span style=\"font-size: 0.5em\">" + g.getGroupName() + "</span> - " + i.getName();
 }