Beispiel #1
0
  @Restrict(Mupi.USER_ROLE)
  public static Result nextPublications(Long last) {
    final models.Profile p = Mupi.getLocalUser(session()).profile;
    Long i = getLocalInterest();
    Long l = getLocalLocation();
    models.Interest iObj = null;
    models.Location lObj = null;
    if (i != null) iObj = models.Interest.find.byId(i);
    if (l != null) lObj = models.Location.find.byId(l);

    List<models.Publication> pubs = new ArrayList<models.Publication>();

    if (i == null || i == -1) {
      if (l == null || l == -1) {
        pubs =
            Publication.findByInterests(models.Interest.getIds(p.getInterests()), last).getList();
      } else {
        pubs =
            Publication.findByInterestsLocation(models.Interest.getIds(p.getInterests()), l, last)
                .getList();
      }
    } else {
      if (l == null || l == -1) {
        pubs = Publication.findByInterest(i, last).getList();
      } else {
        pubs = Publication.findByInterestLocation(i, l, last).getList();
      }
    }

    if (pubs.isEmpty()) return AjaxResponse.build(2, "");
    else return AjaxResponse.build(0, pubList.render(pubs, iObj, lObj).body());
  }
Beispiel #2
0
  @Restrict(Mupi.USER_ROLE)
  public static Result renderFeedContent(
      int status,
      Page<models.Publication> l_pubs,
      Page<models.Promotion> l_prom,
      models.Interest i,
      models.Location l) {

    final models.Profile p = Mupi.getLocalUser(session()).profile;
    final String iSession;
    if (i == null) iSession = "-1";
    else iSession = i.getId().toString();
    final String lSession;
    if (l == null) lSession = "-1";
    else lSession = l.getId().toString();

    session().put("interest", iSession);
    session().put("location", lSession);

    return AjaxResponse.build(
        status,
        feedContent
            .render(
                p.getLocations(),
                p.getInterests(),
                l_pubs,
                l_prom,
                i,
                l,
                PROMOTION_FORM,
                PROMOTE_MEETUP_FORM,
                HOST_MEETUP_FORM,
                MyUsernamePasswordAuthProvider.LOGIN_FORM,
                MyUsernamePasswordAuthProvider.SIGNUP_FORM)
            .body());
  }