Exemplo n.º 1
0
  // src: 1 = viewAdvertisements
  // src: 2 = viewMyOwnAdvertisements
  @Security.Authenticated(Secured.class)
  public static Result deleteTutAdvertisement(Long id, Long src) {
    Student s = Student.find.byId(request().username());
    TutorAdvertisement ta = TutorAdvertisement.find.byId(id);

    try {
      if (ta.student.email.equals(s.email)) {
        ta.delete();
      }
    } catch (NullPointerException e) {

    }
    if (src == 1) {
      return ok(
          viewAdvertisements.render(
              Student.find.byId(request().username()),
              StudentAdvertisement.find.all(),
              TutorAdvertisement.find.all()));
    } else {
      return ok(
          viewOwnAdvertisements.render(
              Student.find.byId(request().username()),
              StudentAdvertisement.find.all(),
              TutorAdvertisement.find.all()));
    }
  }
Exemplo n.º 2
0
 @Security.Authenticated(Secured.class)
 public static Result addNewTutAdvertisement(Long src) {
   return ok(
       postNewTutorAdvertisement.render(
           Student.find.byId(request().username()),
           form(TutorAdvertisementForm.class),
           TutorAdvertisement.findFromUser(request().username()),
           src));
 }
Exemplo n.º 3
0
    public String validate() {

      if (test != true && test != false) {
        test = true;
      }

      if (studies.length() == 0 | description.length() == 0) {
        return "Please fill in all required forms";
      }

      if (request().username() == null) {
        return "username is null, make sure you are logged in";
      }

      models.TutorAdvertisement.create(
          Student.find.byId(request().username()), studies, description, price, test);
      return null;
    }