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
  public static Result feed() {
    final User user = Mupi.getLocalUser(session());
    if (user == null || user.profile == null) {
      session("ref", request().getHeader(HttpHeaders.REFERER));
      return ok(
          index.render(
              MyUsernamePasswordAuthProvider.LOGIN_FORM,
              MyUsernamePasswordAuthProvider.SIGNUP_FORM));
    } else if (session("ref") != null && !session().get("ref").equalsIgnoreCase("null")) {
      String url = session("ref");
      session().remove("ref");
      return redirect(url);
    } else if (user.getProfile().getInterests().isEmpty()) {
      return redirect(routes.Interest.interestManager());
    } else if (user.getProfile().getStatus() == MupiParams.FIRST_LOGIN) {
      return redirect(routes.Profile.profile());
    } else {
      Long interest = getLocalInterest();
      Long location = getLocalLocation();

      models.Interest i;
      if (interest == null) i = null;
      else i = models.Interest.find.byId(interest);
      models.Location l;
      if (location == null) l = null;
      else l = models.Location.find.byId(location);

      return ok(
          views.html.feed.render(
              user,
              user.getProfile().getInterests(),
              user.getProfile().getLocations(),
              i,
              l,
              Publication.findByInterests(
                  models.Interest.getIds(user.getProfile().getInterests()), 0l),
              Promotion.findByInterests(
                  models.Interest.getIds(user.getProfile().getInterests()), 0l),
              form(models.Promotion.class),
              PROMOTE_MEETUP_FORM,
              HOST_MEETUP_FORM,
              MyUsernamePasswordAuthProvider.LOGIN_FORM,
              MyUsernamePasswordAuthProvider.SIGNUP_FORM));
    }
  }