예제 #1
0
  private void testRetrievePost(List<String> tags) {
    Post newPost = getPostWithTags(tags);
    Post.create(newPost);
    Post retrievedPost = Post.get(newPost.id);
    assertNotNull("An post should have been returned", retrievedPost);
    assertEquals("title of retrieved post should have been same", title, retrievedPost.title);
    assertTrue(
        "title of retrieved post should have been same",
        Math.abs(price - retrievedPost.price) < DELTA);
    assertEquals(
        "title of retrieved post should have been same", postDuration, retrievedPost.postDuration);
    assertEquals("title of retrieved post should have been same", city, retrievedPost.city);
    assertEquals("title of retrieved post should have been same", state, retrievedPost.state);
    assertEquals("title of retrieved post should have been same", country, retrievedPost.country);
    assertEquals("title of retrieved post should have been same", zipcode, retrievedPost.zipcode);

    if (tags == null || tags.size() == 0) {
      assertEquals("There should have been same zero tags", 0, retrievedPost.tags.size());
    } else {
      assertEquals(
          "There should have been same number of tags", tags.size(), retrievedPost.tags.size());
      for (PostTag postTag : retrievedPost.tags) {
        assertTrue("The tag was not found", tags.contains(postTag.tag));
      }
    }
  }
예제 #2
0
  public Result approve(Long key) {
    if (log.isDebugEnabled()) log.debug("approve <- " + key);

    Post post = postDAO.get(key);
    if (log.isDebugEnabled()) log.debug("post : " + post);
    if (post == null) return notFound();

    ContentStatus status = post.getStatus();
    if (status == NEW || status == UPDATED) {
      User user = HttpUtils.loginUser(ctx());
      post.setStatus(APPROVED);
      post.setApprovedBy(user);
      post.setApprovedOn(new Date());
      postDAO.update(post);

      List<ContentReport> reports = contentReportDAO.findForContent(ContentType.POST, key);
      for (ContentReport report : reports) {
        if (report.getStatus() == ContentReport.Status.NEW) {
          report.setStatus(ContentReport.Status.IGNORED);
          report.setUpdatedBy(user);
          contentReportDAO.update(report);
        }
      }
      return ok(toJson(ImmutableMap.of("status", "ok", "key", key)));
    } else {
      return badRequest(
          toJson(
              ImmutableMap.of(
                  "status", "error", "message", "wrong status", "status", status.name())));
    }
  }
예제 #3
0
파일: Admin.java 프로젝트: nateki/yabe
 public static void save(Long id, String title, String content, String tags) {
   Post post;
   if (id == null) {
     // Create post
     User author = User.find("byEmail", Security.connected()).first();
     post = new Post(author, title, content);
   } else {
     // Retrieve post
     post = Post.findById(id);
     // Edit
     post.title = title;
     post.content = content;
     post.tags.clear();
   }
   // Set tags list
   for (String tag : tags.split("\\s+")) {
     if (tag.trim().length() > 0) {
       post.tags.add(Tag.findOrCreateByName(tag));
     }
   }
   // Validate
   validation.valid(post);
   if (validation.hasErrors()) {
     render("@form", post);
   }
   // Save
   post.save();
   index();
 }
예제 #4
0
 @Test
 public void testDeletePost() {
   Post post = getPostWithTags(null);
   Post.create(post);
   Post retrievedPost = Post.find.byId(post.id);
   assertNotNull("You should have got an post back", retrievedPost);
   Post.delete(post.id);
   retrievedPost = Post.find.byId(post.id);
   assertNull("You should not have got an post back", retrievedPost);
 }
예제 #5
0
 private Post getPostWithTags(List<String> tags) {
   Post newPost = new Post(title, price, postDuration, city, state, country, zipcode);
   if (tags != null) {
     newPost.tags = new ArrayList<PostTag>(tags.size());
     for (String tag : tags) {
       newPost.tags.add(new PostTag(newPost, tag));
     }
   }
   return newPost;
 }
예제 #6
0
 @Test
 public void testCascadeDelete() {
   Forum help = Forum.find("byName", "Play help").first();
   assertEquals(4, Topic.count());
   assertEquals(7, Post.count());
   help.delete();
   assertEquals(1, Topic.count());
   assertEquals(1, Post.count());
   User guillaume = User.find("byName", "Guillaume").first();
   assertEquals(0L, (long) guillaume.getTopicsCount());
 }
예제 #7
0
파일: BasicTest.java 프로젝트: Tri125/Yade
  @Test
  public void useTheCommentsRelation() {
    // Create a new user and save it
    User bob = new User("*****@*****.**", "secret", "Bob").save();

    // Create a new post
    Post bobPost = new Post(bob, "My first post", "Hello world").save();

    // Post a first comment
    bobPost.addComment("Jeff", "Nice post");
    bobPost.addComment("Tom", "I knew that !");

    // Count things
    assertEquals(1, User.count());
    assertEquals(1, Post.count());
    assertEquals(2, Comment.count());

    // Retrieve Bob's post
    bobPost = Post.find("byAuthor", bob).first();
    assertNotNull(bobPost);

    // Navigate to comments
    assertEquals(2, bobPost.comments.size());
    assertEquals("Jeff", bobPost.comments.get(0).author);

    // Delete the post
    bobPost.delete();

    // Check that all comments have been deleted
    assertEquals(1, User.count());
    assertEquals(0, Post.count());
    assertEquals(0, Post.count());
    assertEquals(0, Comment.count());
  }
예제 #8
0
  public static void deletePost(Long post_ID) throws SQLException {
    Post post = null;

    String deletePostStr =
        String.format("DELETE from %s where postid = ?", Post.dquote(POST), post_ID);

    Connection conn = null;
    PreparedStatement deleteP = null;

    if (post_ID != null) {
      try {
        conn = DB.getConnection();
        deleteP = conn.prepareStatement(deletePostStr);
        ResultSet rs = deleteP.executeQuery();

        if (rs.next()) {
          Logger.debug("Failed to delete the Post.");
        }
        deleteP.close();
        conn.close();
      } catch (SQLException e) {
        Logger.debug("Failed while trying to delete the post.");
      }
    } else {
      Logger.debug("Post id is null.");
    }
  }
예제 #9
0
파일: Admin.java 프로젝트: nateki/yabe
 public static void form(Long id) {
   if (id != null) {
     Post post = Post.findById(id);
     render(post);
   }
   render();
 }
예제 #10
0
파일: Post.java 프로젝트: eduardoassis/yabe
 public static List<Post> findTaggedWith(String... tags) {
   return Post.find(
           "select distinct p from Post p join p.tags as t where t.name in (:tags) group by p.id, p.author, p.title, p.content,p.postedAt having count(t.id) = :size")
       .bind("tags", tags)
       .bind("size", tags.length)
       .fetch();
 }
예제 #11
0
  @Test
  public void testDeletePostWithTags() {
    Post post = getPostWithTags(Arrays.asList(tag1, tag2));
    Post.create(post);

    Post retrievedPost = Post.find.byId(post.id);
    assertNotNull("You should have got an post back", retrievedPost);
    List<PostTag> postTags = PostTag.findTagsByPostId(post.id);
    assertEquals("You should have got 2 tags back", 2, postTags.size());

    Post.delete(post.id);
    retrievedPost = Post.find.byId(post.id);
    assertNull("You should not have got an post back", retrievedPost);
    postTags = PostTag.findTagsByPostId(post.id);
    assertEquals("You should have got 2 tags back", 0, postTags.size());
  }
예제 #12
0
  /**
   * FindById Searches the database for a Group object by the object id.
   *
   * @param connection The jdbc connection
   * @param id The id to select by
   */
  public static Post FindByID(Long post_ID) throws SQLException {
    Post post = null;
    PreparedStatement findPostId = null;
    Connection conn = null;

    String sql = String.format("SELECT * from %s where postid = ?", Post.dquote(POST), post_ID);

    if (post_ID != null) {
      try {
        conn = DB.getConnection();
        findPostId = conn.prepareStatement(sql);
        findPostId.setLong(1, post_ID);

        ResultSet rs = findPostId.executeQuery();

        if (rs.next()) {
          post =
              new Post(
                  rs.getString(Post.CONTENT),
                  rs.getString(Post.TYPE),
                  rs.getTimestamp(Post.TIMESTAMP),
                  rs.getLong(Post.USER_ID),
                  rs.getLong(Post.WALL_ID),
                  rs.getLong(Post.POST_ID));
        }

        findPostId.close();
        conn.close();
        return post;
      } catch (SQLException e) {
        Logger.debug("Error retrieving post.", e);
      }
    }
    return post;
  }
예제 #13
0
  @Test
  public void getRatingFromUserAndPostSucceeds() {
    User user = getInstance(UserDAO.class).get("facebook::testuser");
    Post post = getInstance(PostDAO.class).get(-11L);

    PostRatingPK key = new PostRatingPK(user.getKey(), post.getKey());
    PostRating pr = new PostRating();
    pr.setValue(5);
    pr.setKey(key);

    PostRatingDAO postRatingDAO = getInstance(PostRatingDAO.class);
    postRatingDAO.create(pr);

    PostRating postRating = postRatingDAO.get(user, post);
    assertThat(postRating).isNotNull();
    assertThat(postRating.getValue()).isEqualTo(5);
  }
예제 #14
0
  public static void postComment(
      Long postId,
      @Required(message = "Author is required") String author,
      @Required(message = "A message is required") String content,
      @Required(message = "Please type the code") String code,
      String randomID) {
    Post post = Post.findById(postId);

    if (!Play.id.equals("test")) {
      validation.equals(code, Cache.get(randomID)).message("Invalid code. Please type it again");
    }
    if (validation.hasErrors()) {
      render("Application/show.html", post);
    }

    post.addComment(author, content);
    flash.success("Thanks for posting %s", author);
    Cache.delete(randomID);
    show(postId);
  }
예제 #15
0
  public Result remove(Long key) {
    if (log.isDebugEnabled()) log.debug("remove <- " + key);

    Post post = postDAO.get(key);
    if (log.isDebugEnabled()) log.debug("post : " + post);
    if (post == null) return notFound();

    User user = HttpUtils.loginUser(ctx());
    post.setStatus(REMOVED);
    post.setUpdatedBy(user);
    postDAO.update(post);

    List<ContentReport> reports = contentReportDAO.findForContent(ContentType.POST, key);
    for (ContentReport report : reports) {
      if (report.getStatus() == ContentReport.Status.NEW) {
        report.setStatus(ContentReport.Status.PROCESSED);
        report.setUpdatedBy(user);
        contentReportDAO.update(report);
      }
    }
    return ok(toJson(ImmutableMap.of("status", "ok", "key", key)));
  }
예제 #16
0
파일: Test3.java 프로젝트: nikitozeg/TEST
  public void createPost() {
    // Create a new user and save it
    User bob = new User("*****@*****.**", "secret", "Bob").save();

    // Create a new post
    new Post(bob, "My first post", "Hello world").save();

    // Test that the post has been created
    assertEquals(1, Post.count());

    // Retrieve all posts created by Bob
    List<Post> bobPosts = Post.find("byAuthor", bob).fetch();

    // Tests
    assertEquals(1, bobPosts.size());
    Post firstPost = bobPosts.get(0);
    assertNotNull(firstPost);
    assertEquals(bob, firstPost.author);
    assertEquals("My first post", firstPost.title);
    assertEquals("Hello world", firstPost.content);
    assertNotNull(firstPost.postedAt);
  }
예제 #17
0
  @Test
  public void getDownVotedKeysSucceeds() {
    PostRatingDAO postRatingDAO = getInstance(PostRatingDAO.class);
    UserDAO userDAO = getInstance(UserDAO.class);
    PostDAO postDAO = getInstance(PostDAO.class);

    User user = userDAO.get("facebook::testuser");
    Set<Long> upVotedKeys = postRatingDAO.getDownVotedPostKeys(user);
    assertThat(upVotedKeys.size()).isEqualTo(0);

    Post post = postDAO.get(-11L);

    PostRatingPK key = new PostRatingPK(user.getKey(), post.getKey());
    PostRating pr = new PostRating();
    pr.setValue(-1);
    pr.setKey(key);
    pr.setKey(key);
    postRatingDAO.create(pr);
    post.setRating(post.getRating() - 1);
    postRatingDAO.resetVotedPostKeyCache(user);

    upVotedKeys = postRatingDAO.getDownVotedPostKeys(user);
    assertThat(upVotedKeys.size()).isEqualTo(1);
  }
예제 #18
0
파일: Admin.java 프로젝트: phaus/agora
 public static void index() {
   if (activeUser.isAdmin()) {
     Map<String, Long> stats = new TreeMap<String, Long>();
     stats.put("Dates", DateDim.count());
     stats.put("Sections", Section.count());
     stats.put("Forums", Forum.count());
     stats.put("Entries", Entry.count());
     stats.put("Threads", Thread.count());
     stats.put("Posts", Post.count());
     stats.put("Users", User.count());
     stats.put("Tags", Tag.count());
     render(stats);
   } else {
     forbidden();
   }
 }
예제 #19
0
 @Test
 public void testUpdatePost() {
   Post post = getPostWithTags(null);
   Post.create(post);
   Long id = post.id;
   Post retrievedPost = Post.get(id);
   assertNotNull("You should have got an post back", retrievedPost);
   assertEquals("Title should have been same as when created", title, retrievedPost.title);
   String newTitle = "Changed the title";
   retrievedPost.title = newTitle;
   Post.update(retrievedPost);
   Post updatedPost = Post.get(id);
   assertNotNull("You should have got an post back", updatedPost);
   // This is failing on juint while using inmemory db.. need to check.. the update seems not
   // working
   // assertEquals("Title should have been same as when created", newTitle, updated.title);
 }
예제 #20
0
파일: Post.java 프로젝트: eduardoassis/yabe
 public static List<Post> findTaggedWith(String tag) {
   return Post.find("select distinct p from Post p join p.tags as t where t.name = ?", tag)
       .fetch();
 }
예제 #21
0
 /**
  * Get the number of posts unread by this user in a given thread
  *
  * @param thread
  * @return
  */
 public long getUnreadPostCount(Thread thread) {
   return Post.count("thread = ? and not ? member of e.readers", thread, this);
 }
예제 #22
0
 public static void listTagged(String tag) {
   List<Post> posts = Post.findTaggedWith(tag);
   render(tag, posts);
 }
예제 #23
0
  @Override
  public void onStart(Application app) {

    Category food = null;
    Category travel = null;
    Category sport = null;
    Category other = null;
    Company admin = null;
    Company bitCamp = null;
    long ownedCoupinID1 = 0;
    long ownedCoupinID2 = 0;
    int quantity = 1;
    int status = Coupon.Status.ACTIVE;
    String picture = Play.application().configuration().getString("defaultProfilePicture");

    if (!Company.exists("Admin")) {
      bitCamp =
          new Company(
              "Admin",
              "*****@*****.**",
              HashHelper.createPassword("bitadmin"),
              new Date(),
              picture,
              adress,
              city,
              contact);
      bitCamp.status = Status.ACTIVE;
      bitCamp.save();
    }

    if (!Company.exists("BitCamp")) {
      bitCamp =
          new Company(
              "BitCamp",
              "*****@*****.**",
              HashHelper.createPassword("bitcamp"),
              new Date(),
              picture,
              adress,
              city,
              contact);
      bitCamp.status = Status.ACTIVE;
      bitCamp.save();
    }

    if (Category.exists("Food") == false) {
      food =
          new Category(
              "Food",
              "http://res.cloudinary.com/bitfiles/image/upload/v1430902947/staticImages/food.png");
      food.save();
    }
    if (Category.exists("Travel") == false) {
      travel =
          new Category(
              "Travel",
              "http://res.cloudinary.com/bitfiles/image/upload/v1430902953/staticImages/travel.png");
      travel.save();
    }
    if (Category.exists("Sport") == false) {
      sport =
          new Category(
              "Sport",
              "http://res.cloudinary.com/bitfiles/image/upload/v1430902950/staticImages/sport.png");
      sport.save();
    }

    if (Category.exists("Other") == false) {
      other = new Category("Other");
      other.save();
    }

    if (Coupon.checkByName(nameCoupon1) == false) {
      Coupon.createCoupon(
          nameCoupon1,
          80,
          new Date(),
          "http://res.cloudinary.com/bitfiles/image/upload/v1430853980/staticImages/cp1.jpg",
          travel,
          descriptionCoupon1,
          remarkCoupon1,
          5,
          25,
          new Date(),
          bitCamp,
          status);
    }
    if (Coupon.checkByName(nameCoupon2) == false) {

      ownedCoupinID1 =
          Coupon.createCoupon(
              nameCoupon2,
              40,
              new Date(),
              "http://res.cloudinary.com/bitfiles/image/upload/v1430853989/staticImages/cp2.jpg",
              other,
              descriptionCoupon2,
              remarkCoupon2,
              5,
              20,
              new Date(),
              bitCamp,
              status);
    }
    /* creating a coupon that is not expired */
    if (Coupon.checkByName(nameCoupon3) == false) {
      SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
      String dateString = "01/01/2051";
      Date date = null;
      try {
        date = df.parse(dateString);
      } catch (ParseException e) {
        e.printStackTrace();
      }
      ownedCoupinID2 =
          Coupon.createCoupon(
              nameCoupon3,
              20,
              date,
              "http://res.cloudinary.com/bitfiles/image/upload/v1430854001/staticImages/cp3.jpg",
              food,
              descriptionCoupon3,
              remarkCoupon3,
              2,
              5,
              new Date(),
              bitCamp,
              status);
    }

    if (Coupon.checkByName(nameCoupon4) == false) {
      SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
      String dateString = "05/05/2020";
      Date date = null;
      try {
        date = df.parse(dateString);
      } catch (ParseException e) {
        e.printStackTrace();
      }
      Coupon.createCoupon(
          nameCoupon4,
          350,
          date,
          "http://res.cloudinary.com/bitfiles/image/upload/v1430854005/staticImages/cp4.jpg",
          travel,
          descriptionCoupon4,
          remarkCoupon4,
          5,
          30,
          new Date(),
          bitCamp,
          status);
    }

    if (Coupon.checkByName(nameCoupon5) == false) {
      SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
      String dateString = "05/05/2020";
      Date date = null;
      try {
        date = df.parse(dateString);
      } catch (ParseException e) {
        e.printStackTrace();
      }

      Coupon.createCoupon(
          nameCoupon5,
          17,
          date,
          "http://res.cloudinary.com/bitfiles/image/upload/v1430854008/staticImages/cp5.jpg",
          food,
          descriptionCoupon5,
          remarkCoupon5,
          5,
          30,
          new Date(),
          bitCamp,
          status);
    }

    if (Coupon.checkByName(nameCoupon6) == false) {
      SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
      String dateString = "05/05/2020";
      Date date = null;
      try {
        date = df.parse(dateString);
      } catch (ParseException e) {
        e.printStackTrace();
      }
      Coupon.createCoupon(
          nameCoupon6,
          34,
          date,
          "http://res.cloudinary.com/bitfiles/image/upload/v1430854011/staticImages/cp6.jpg",
          travel,
          descriptionCoupon6,
          remarkCoupon6,
          5,
          30,
          new Date(),
          bitCamp,
          status);
    }

    if (Coupon.checkByName(nameCoupon7) == false) {
      SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
      String dateString = "05/05/2020";
      Date date = null;
      try {
        date = df.parse(dateString);
      } catch (ParseException e) {
        e.printStackTrace();
      }
      Coupon.createCoupon(
          nameCoupon7,
          219,
          date,
          "http://res.cloudinary.com/bitfiles/image/upload/v1430854013/staticImages/cp7.jpg",
          travel,
          descriptionCoupon7,
          remarkCoupon7,
          5,
          30,
          new Date(),
          bitCamp,
          status);
    }

    if (Coupon.checkByName(nameCoupon8) == false) {
      SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
      String dateString = "05/05/2020";
      Date date = null;
      try {
        date = df.parse(dateString);
      } catch (ParseException e) {
        e.printStackTrace();
      }
      Coupon.createCoupon(
          nameCoupon8,
          25,
          date,
          "http://res.cloudinary.com/bitfiles/image/upload/v1430854016/staticImages/cp8.jpg",
          sport,
          descriptionCoupon8,
          remarkCoupon8,
          5,
          30,
          new Date(),
          bitCamp,
          status);
    }

    if (Coupon.checkByName(nameCoupon9) == false) {
      SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
      String dateString = "05/05/2020";
      Date date = null;
      try {
        date = df.parse(dateString);
      } catch (ParseException e) {
        e.printStackTrace();
      }
      Coupon.createCoupon(
          nameCoupon9,
          239,
          date,
          "http://res.cloudinary.com/bitfiles/image/upload/v1430854019/staticImages/cp9.jpg",
          travel,
          descriptionCoupon9,
          remarkCoupon9,
          5,
          30,
          new Date(),
          bitCamp,
          status);
    }

    if (User.check("*****@*****.**") == false) {
      User.createUser(
          "Admin",
          "",
          new Date(),
          "",
          "",
          "",
          "*****@*****.**",
          HashHelper.createPassword("bitadmin"),
          true,
          picture);
      EmailVerification setVerified = new EmailVerification(1, true);
      setVerified.save();
    }

    if (User.check("*****@*****.**") == false) {
      User user =
          new User(
              "Jesenko",
              "Gavric",
              new Date(),
              "",
              "",
              "",
              "*****@*****.**",
              HashHelper.createPassword("johndoe"),
              false,
              picture);

      user.save();
      EmailVerification setVerified = new EmailVerification(2, true);
      setVerified.save();
      Coupon c1 = Coupon.find(ownedCoupinID1);
      Coupon c2 = Coupon.find(ownedCoupinID2);
      TransactionCP.createTransaction(
          "AH-324ASDas", "bitSale", c1.price, quantity, c1.price, "TOKEN01010", user, c1);
      c1.maxOrder = c1.maxOrder - quantity;
      c1.statistic.bought(quantity);
      c1.save();
      TransactionCP.createTransaction(
          "AH-324ASsadD", "bitSale", c2.price, quantity, c2.price, "TOKEN2222", user, c2);
      c2.maxOrder = c2.maxOrder - quantity;
      c2.statistic.bought(quantity);
      c2.save();
    }

    if (User.check("*****@*****.**") == false) {
      User.createUser(
          "Vedad",
          "Zornic",
          new Date(),
          "",
          "",
          "",
          "*****@*****.**",
          HashHelper.createPassword("johndoe"),
          false,
          picture);
      EmailVerification setVerified = new EmailVerification(3, true);
      setVerified.save();
      Subscriber sb = new Subscriber(User.findByEmail("*****@*****.**"));
      sb.save();
    }

    if (FAQ.checkByQuestion("Želim kupiti današnju ponudu. Kako da to učinim?") == false) {
      FAQ.createFAQ(
          "Želim kupiti današnju ponudu. Kako da to učinim?",
          "Morate biti "
              + "registrovani i ulogovani na stranicu. Ukoliko još nemate nalog,"
              + " registracija je besplatna i traje manje od 30 sekundi, a također se "
              + "možete uvezati sa Vašim Facebook nalogom. Kada se ulogujete kliknite na"
              + " dugme Kupi i pratite jednostavne korake.");
    }

    if (FAQ.checkByQuestion("Na koji način plaćam ponudu i je li sigurno?") == false) {
      FAQ.createFAQ(
          "Na koji način plaćam ponudu i je li sigurno?",
          "Plaćanje možete obaviti na"
              + " jedan od sljedećih načina:"
              + "1.	Putem eKredita – eKredit možete uplatiti u banci ili pošti na naš transkcijski "
              + "račun, a on će Vam biti dodijeljen sljedeći radni dan ili najkasnije 48 sati nakon"
              + " uplate. Kada Vaš eKredit bude prikazan na Vašem profilu možete obaviti željenu kupovinu. "
              + "Više informacija možete pronaći na ovom linku nakon prijave na Vaš profil."
              + "2.	Putem kartice – Plaćanje je zbog sigurnosti, jednostavnije realizacije i brzine "
              + "obrade zahtjeva limitirano na kreditne i debitne MasterCard, Maestro i VISA kartice. "
              + "Plaćanje je potpuno sigurno, a više o tome možete pročitati na - sigurnost plaćanja."
              + "3.	Dio plaćate eKreditom, a dio karticom – Prilikom kupovine potrebno je da unesete iznos "
              + "eKredita koji želite da Vam se odbije i dalje idete na „Nastavi kupovinu“. Unesete sve"
              + " potrebne podatke i na taj način će Vam se jedan dio odbiti u vidu eKredita a ostatak"
              + " vrijednosti će biti rezervisan na Vašoj kartici."
              + "4. Gotovinska uplata kupona ili ekredita - uplatu možete izvršiti na eKupon prodajnim mjestima u"
              + " BBI tržnom centru i Grand centru na Ilidži. "
              + "5. Kupovina poklon bona na ime i prezime osobe koju želite bez obzira da li je registrovan korisnik ili ne.");
    }

    if (FAQ.checkByQuestion("Šta se dešava ako ponuda dana ne dosegne minimalan broj kupaca?")
        == false) {
      FAQ.createFAQ(
          "Šta se dešava ako ponuda dana ne dosegne minimalan broj kupaca?",
          "Da bi ponuda "
              + "uspjela mora dostići minimalan broj kupaca koji se određuje u dogovoru s partnerima."
              + "U slučaju da se ne kupi dovoljan broj kupona, ponuda propada i ništa Vam se ne naplaćuje. "
              + "Da izbjegnete ovakve situacije, pozovite što više osoba da se uključe na ponudu na "
              + "kojoj ste učestvovali.");
    }
    // Creating 10 testing posts.
    if (Post.all().size() < 1) {
      for (int i = 0; i < 10; i++) {
        Post.createPost(
            "Man must explore, and this is exploration at its greatest",
            "Problems look mighty small from 150 miles up",
            post_content,
            "http://res.cloudinary.com/bitfiles/image/upload/v1430859169/staticImages/explore.jpg",
            new Date(),
            User.find(true),
            "no,tag");
      }
    }
  }
예제 #24
0
 private void testPostCreate(List<String> tags) {
   Post newPost = getPostWithTags(tags);
   Post.create(newPost);
   assertNotNull("An post should have been returned", Post.get(newPost.id));
 }
예제 #25
0
 public static void show(Long id) {
   Post post = Post.findById(id);
   String randomID = Codec.UUID();
   render(post, randomID);
 }
예제 #26
0
 public static void index() {
   Post frontPost = Post.find("order by postedAt desc").first();
   List<Post> olderPosts = Post.find("order by postedAt desc").from(1).fetch(10);
   render(frontPost, olderPosts);
 }
예제 #27
0
  @Test
  public void testTags() {

    // Create a new user and save it
    User bob = new User("*****@*****.**", "secret", "Bob").save();

    // Create a new post
    Post bobPost = new Post(bob, "My first post", "Hello world").save();
    Post anotherBobPost = new Post(bob, "Hop", "Hello world").save();

    // Well
    assertEquals(0, Post.findTaggedWith("Red").size());

    // Tag it now
    bobPost.tagItWith("Red").tagItWith("Blue").save();
    anotherBobPost.tagItWith("Red").tagItWith("Green").save();

    // Check
    assertEquals(2, Post.findTaggedWith("Red").size());
    assertEquals(1, Post.findTaggedWith("Blue").size());
    assertEquals(1, Post.findTaggedWith("Green").size());

    // Check for multiple tags
    assertEquals(1, Post.findTaggedWith("Red", "Blue").size());
    assertEquals(1, Post.findTaggedWith("Red", "Green").size());
    assertEquals(0, Post.findTaggedWith("Red", "Green", "Blue").size());
    assertEquals(0, Post.findTaggedWith("Green", "Blue").size());

    // Check for tag cloud
    List<Map> cloud = Tag.getCloud();
    assertEquals(
        "[{tag=Blue, pound=1}, {tag=Green, pound=1}, {tag=Red, pound=2}]", cloud.toString());
  }
예제 #28
0
파일: Post.java 프로젝트: eduardoassis/yabe
 public Post next() {
   return Post.find("postedAt > ? order by postedAt asc", postedAt).first();
 }
예제 #29
0
파일: User.java 프로젝트: astolarz/OpenBook
 public List<Post> news() {
   return Post.find(
           "SELECT p FROM Post p, IN(p.author.friendedBy) u WHERE u.from.id = ?1 and (U.accepted = true or u.to.id = ?1) order by p.updatedAt desc",
           this.id)
       .fetch();
 }
예제 #30
0
파일: Post.java 프로젝트: eduardoassis/yabe
 public Post previous() {
   return Post.find("postedAt < ? order by postedAt desc", postedAt).first();
 }